How to switch from PHP FastCGI to PHP-FPM?
But, I believe the tutorial sets up PHP FastCGI instead of PHP-FPM which from what I read is preferred. So:
1. How can I tell which I'm using?
2. What are the step-by-step instructions to switch everything to PHP-FPM?
Thanks
7 Replies
2. uninstall PHP FastCGI, install PHP-fpm, configure PHP-fpm, start PHP-fpm. The exact way you do that will depend on which Linux distribution you are using.
Ran````
ps axl | grep fpm
The result was (which I'm not sure how to interpret) …
0 1000 3574 3535 20 0 4392 840 - S+ pts/0 0:00 grep --color=auto fpm
````
I'm running on Ubuntu 12.10. While I understand the general workflow you gave, I'm not sure about how to do implement them specifically:
1. How do I uninstall PHP FastCGI? (will this break all of the current Wordpress sites I'm running for example?)
2. Installing PHP-FPM? I assume I have it already installed, else I need to do a apt-get php-fpm?
3. How do I configure PHP-FPM? I have no idea what files I need to touch and what needs to change in order to get it running and used in Nginx.
4. How do I start PHP-FPM? I'm assuming something like service php-fpm start?
5. Lastly, what do I need to do in my nginx.conf and individual virtual host files to ensure my WP sites are using PHP-FPM?
Sorry for the need to detail but I'm rather green in the world of PHP as you can tell. Need it baby stepped as much as possible
Thanks
@wgpubs:
Thanks for the quick reply.
Ran````
ps axl | grep fpmThe result was (which I'm not sure how to interpret) …
0 1000 3574 3535 20 0 4392 840 - S+ pts/0 0:00 grep --color=auto fpm
````
ps lists processes. Grep searches text. 'ps axl | grep fpm' finds all processes with fpm in their name. The only process it found was itself. This means php-fpm isn't running.
@wgpubs:
I'm running on Ubuntu 12.10. While I understand the general workflow you gave, I'm not sure about how to do implement them specifically:
1. How do I uninstall PHP FastCGI? (will this break all of the current Wordpress sites I'm running for example?)
2. Installing PHP-FPM? I assume I have it already installed, else I need to do a apt-get php-fpm?
3. How do I configure PHP-FPM? I have no idea what files I need to touch and what needs to change in order to get it running and used in Nginx.
4. How do I start PHP-FPM? I'm assuming something like service php-fpm start?
5. Lastly, what do I need to do in my nginx.conf and individual virtual host files to ensure my WP sites are using PHP-FPM?
Sorry for the need to detail but I'm rather green in the world of PHP as you can tell. Need it baby stepped as much as possible
:)
Firstly php-fpm is better than spawn-fcgi that the linode tutorials tell people to use, but not significantly. Are you really sure it's worth changing?
1. Find the part of the tutorial that told you how to install FastCGI and do the reverse. What tutorial was it? I really don't like the way those tutorials tell people to put unpackaged files all over their filesystems.
2. Yes, 'apt-get php-fpm'. '/etc/init.d/php-fpm status' will tell you if it's running, use '/etc/init.d/php-fpm start' to start and '/etc/init.d/php-fpm stop' to stop.
3. The condig is under /etc/php5/fpm/. You can edit these files in any editor you like but the chances are you don't need to change anything.
4. The 'service' command is a redhat thing, not ubuntu. You can run the commands in answer 2.
5. As long as php-fpm is listening on the right port/socket that's all. There should be a fastcgipass line in your nginx config ( /etc/nginx/sites-avalible/
I hope this makes some sense!
You may want to install APC as well, It speeds php up a lot. Maybe get the above working first before thinking about it.
@sednet:
4. The 'service' command is a redhat thing, not ubuntu. You can run the commands in answer 2.
the 'service' command is included with the 'sysvinit-utils' package, which I believe is installed by default these days (and it even works with upstart jobs)
So right now I have this:
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/example.com/public_html$fastcgi_script_name;
}
For what you said I only need to change the "fastcgi_pass" parameter, and make it match that in the php-fpm
Also, can FastCGI and FPM run concurrently? If I remove FastCGI I'm going to have a number of client sites go down … so if they can run concurrently I'll have time to change one site out at a time.
Thanks again.
@wgpubs:
Thanks much for the detailed reply.
So right now I have this:
location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /srv/www/example.com/public_html$fastcgi_script_name; }
For what you said I only need to change the "fastcgi_pass" parameter, and make it match that in the php-fpm
http://www.conf correct?Also, can FastCGI and FPM run concurrently? If I remove FastCGI I'm going to have a number of client sites go down … so if they can run concurrently I'll have time to change one site out at a time.
Thanks again.
Right. Just update fastcgi_pass for each site and reload nginx. Then check the site actually works. It should as it's running the same php.
You can run two or more php's concurrently. If you leave the old setup running on the old port and setup php-fpm on a new port or socket. Then you can swap sites over one at a time.
Bryanw is right about the service command so either use that or the /etc/init.d/XX scripts, they do the same thing.
Thanks again!