Nginx 1.4.x on Unix systems

This documentation will cover installing and configuring PHP with
PHP-FPM for a Nginx 1.4.x HTTP server.

This guide will assume that you have built Nginx from source and therefore
all binaries and configuration files are located at
/usr/local/nginx. If this is not the case and you have
obtained Nginx through other means then please refer to the
» Nginx Wiki in order to translate
this manual to your setup.

This guide will cover the basics of configuring an Nginx server to
process PHP applications and serve them on port 80, it is recommended
that you study the Nginx and PHP-FPM documentation if you wish to
optimise your setup past the scope of this documentation.

Please note that throughout this documentation version numbers have been
replaced with an 'x' to ensure this documentation stays correct in the future,
please replace these as necessary with the corresponding version numbers.

It is recomended that you visit the Nginx Wiki
» install page
in order to obtain and install Nginx on your system.

Obtain and unpack the PHP source:

tar zxf php-x.x.x

Configure and build PHP. This is where you customize PHP
with various options, like which extensions will be enabled. Run
./configure --help for a list of available options. In our example
we'll do a simple configure with PHP-FPM and MySQL support.

Following the steps above you will have a running Nginx web server with
support for PHP as a SAPI module. Of course there are
many more configuration options available for Nginx and PHP. For more
information type ./configure --help in the corresponding
source tree.

User Contributed Notes 5 notes

Building from source is not easy if something is a bit different, and I had a hard time with some directory and configuration options. I was floundering around the web until I found this site that translated from Chinese. No one else had the solution. I couldn't get php fpm to start until I changed the directory (Item 2.ERROR: Unable to globalize). I had other issues listed but I was able to solve them. Please don't delete this, it is very useful info.

The original site (it is in Chinese, not my site, but I want to give credit):

If there is no /usr/local/etc/php-fpm.d directory, create the directory.

3.WARNING: Nothing matches the include pattern '/usr/local/etc/php-fpm.d/*.conf' from /usr/local/etc/php-fpm.conf at line 125. ERROR:. No pool defined at least one pool section must be specified in config file ERROR: failed to post process the configuration ERROR: FPM initialization failed

solution:

cp www.conf.default www.conf

4.ERROR: [pool www] can not get gid for group 'nobody' ERROR: FPM initialization failed

solution:

Www.conf open files, user and group users into nginx default settings, usually the default is www-data.