PHP 7 Install Guide For Nginx
-
- Get the most recent (stable) PHP Version from http://php.net/downloads.php
- Extract the files
tar zxf php-x.x.x
- Configure the installation
cd php-x.x.x ./configure -enable-fpm make make install
NOTICE:
You might want to check all avaible options with./configure --help
- Set up the ini files:
tar zxf php-x.x.x
- Configure PHP and FPM
Locate "cgi.fix_pathinfo=" in /usr/local/php/php.ini and replace it with
cgi.fix_pathinfo=0
(This prevents nginx from passign non existing files to the PHP-FPM)
- Creating the FPM Config Pool
mkdir /etc/php-fpm.d cp sapi/fpm/www.conf /etc/php-fpm.d/www.conf
- Editing the default conf
Find and modify the following in the freshly copied www.conf:
; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. user = www-data group = www-data
- Start it
/usr/local/bin/php-fpm
- Configuring NGINX
Configure your nginx with these locations to test your installation (you might want to change your root directorys)
location / { root html; index index.php index.html index.htm; } location ~* \.php$ { root html; fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param REQUEST_URI $uri?$args; fastcgi_param SCRIPT_NAME $fastcgi_script_name; }
You can test it with the following php Code:
<!--?php phpinfo(); ?-->
No Comments