• Sales: 1-800-961-2888
  • Support: 1-800-961-4454

Installing NGINX and PHP-FPM - Conclusion


The End…

Now that you have gone through the whole guide and you have installed and created all of the files needed for your installation, you will need to restart NGINX and PHP-FPM. After you restart both services it will be up and working. You will have NGINX running Fast-CGI with PHP-FPM. Your Installation will be running on all separate UNIX Sockets with separate owners per socket ensuring a more secure environment. Furthermore, your NGINX Setup will be fast and furious. In my own speed tests I’ve conducted, my site running on NGINX vs. My Site Running on Apache, my NGINX site was over 3x faster in both response and action. All while on a small 256MB Virtual Server, which in my opinion is ridiculously awesome!

Here is a quick Command to restart Both NGINX and PHP-FPM

 

service nginx restart; service php5-fpm restart

 

If there was no error that popped up, you can now go to your domain that you have setup and you will be running good old NGINX and PHP-FPM.

Enjoy!

 

 

Another Note..

Just to reiterate, this works and needs nothing else, you can change things to better suit your environment though there is almost nothing else that you need to get the services up and running. Secondly, I have not conveniently left something out of this document. At more than 2500 words, I think I gave too much insight, though I hope this helps.

I would also like to say Thank you to my fellow Rackers, in particular Patrick Cantu, without our bickering about if this could be done, I would have never thought about doing this nor would I have ever done it. I would also like to say thank you to the people over at DotDeb. You people are what make the Open Source Community a great place to develop. You can read more about DotDeb and their repositories here.



© 2011-2013 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER

6 Comments

Hi Kevin great article, I had a couple questions if you could help me out I'd greatly appreciate it.

I followed along but got lost after I create the php5-fpm folder in /var/run/ am I suppose to put something in there? The second place I got lost was in the /etc/php5/fpm/pool.d/ folder there'
s currently a www.conf file which I'm guessing is there by default. In order to get php-fpm to use sockets instead of TCP I need to create a new file e.g. mydomain.conf and put the information you left as a template for new pool files? Once that's there how do I tell each virtual host to reference those files?

Any help is greatly appreciated!

Hi Don,

I am happy that you have been through the article and I hope that you have been able to get started with NGINX and PHP-FPM. I feel once you get going with NGINX you will never look back. :D

Your questions are all related. The /var/run/php5-fpm/ directory is an empty directory. There are no files that you will have to place there, though this is where your file sockets will exist once you have a proper "pool" setup.

The "pool" setup is one where you are creating a "pool" per domain that you would like to be owned by a specific user. You are right that the "www.conf" file is there by default. You can modify that file to fit your installation, or you can use template provided in the tutorial. I deleted the default file, as I did not need it.

PHP-FPM and NGINX are completely separate though work together. When you setup your virtualhost you are pointing the virtualhost php processes to a file socket that will be created by your "pool" and stored in the previously created directory.

To illustrate this, In the virtual host setup section of this article there is a line :
"fastcgi_pass unix:/var/run/php5-fpm/DOMAINNAME.socket;"

This is the point where you are telling NGINX to listen on a file socket. which will not exist until instructed to by PHP-FPM and stored in the /var/run/php5-fpm/ directory.

I hope this further explains the process, please let me know if you have any further questions.

i recommend to use Ubuntu with nginx, php-fpm, and mysql, apc
I found working tutorial, Which is auto configurered to workwith joomla, wordpress, permalink rewrites.

http://www.discusswire.com/setting-nginx-php-fpm-ubuntu-10-04/

Really great tutorial dude thanks. I have followed 3 so far as I am new to nginx and this one was the first and only one to work. Thanks for taking the time to create it.

as it is not specified, just a little note in case of server reboot

add the following within the file */etc/init.d/php5-fpm*

create_pidfiledir() {
if [ ! -d /var/run/php5-fpm ]
then
mkdir -p /var/run/php5-fpm
fi
}

Then add create_pidfiledir into the "start" function

Then add that script in the boot sequence

# update-rc.d php5-fpm defaults

Great Article! You saved me a lot of time. Big thanks!

Add new comment