Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Feb 13, 2013 7:30 pm 
Offline
Senior Newbie

Joined: Tue Jan 08, 2013 1:52 pm
Posts: 13
I recently followed the documented instructions on setting up a LEMP infrastructure and installing Wordpress on top of it. All went well.

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


Top
   
PostPosted: Wed Feb 13, 2013 7:45 pm 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
1. See if there are any fpm processes running with: ps axl | grep fpm

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.


Top
   
PostPosted: Wed Feb 13, 2013 7:58 pm 
Offline
Senior Newbie

Joined: Tue Jan 08, 2013 1:52 pm
Posts: 13
Thanks for the quick reply.

Ran
Code:
ps axl | grep fpm


The result was (which I'm not sure how to interpret) ...

Code:
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


Top
   
PostPosted: Thu Feb 14, 2013 3:52 pm 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
wgpubs wrote:
Thanks for the quick reply.

Ran
Code:
ps axl | grep fpm


The result was (which I'm not sure how to interpret) ...

Code:
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 wrote:
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 fastcgi_pass line in your nginx config ( /etc/nginx/sites-avalible/<sitename> ) that will tell you where it is sending fastcgi requests. This should match the listening port set on the 'listen = <whatever>' line in /etc/php5/fpm/pool.d/www.conf. At most you will have to change the listen line in www.conf and restart php-fpm. In my nginx config I have fastcgi_pass 'unix:/tmp/phpfpm.sock;' and in /etc/php5/fpm/pool.d/www.conf I have 'listen = /tmp/phpfpm.sock'. You don't need the 'unix:' prefix in www.conf.

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.


Top
   
PostPosted: Thu Feb 14, 2013 8:19 pm 
Offline
Senior Newbie

Joined: Thu Feb 05, 2009 4:26 pm
Posts: 10
sednet wrote:
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)


Top
   
PostPosted: Fri Feb 15, 2013 1:07 am 
Offline
Senior Newbie

Joined: Tue Jan 08, 2013 1:52 pm
Posts: 13
Thanks much for the detailed reply.

So right now I have this:

Code:
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 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.


Top
   
PostPosted: Fri Feb 15, 2013 5:01 am 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
wgpubs wrote:
Thanks much for the detailed reply.

So right now I have this:

Code:
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.


Top
   
PostPosted: Fri Feb 15, 2013 8:15 pm 
Offline
Senior Newbie

Joined: Tue Jan 08, 2013 1:52 pm
Posts: 13
Everything worked per your instructions.

Thanks again!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group