I previously set up a lamp environment on the server and wanted to switch to nginx with better performance as the server software.I want to upgrade php5 to php7 again.

There is no need to repeat the details of installing nginx:sudo apt-get install nginx, modify the port of apache before starting ng.

Install php7

Download the source code and unzip it.

#cd php7 ***
#./configure --prefix =/usr/local/php7 --with-config-file-path =/usr/local/php7/etc --with-mcrypt =/usr/include --with-mysql=mysqlnd- -with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable- sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache
#make install

In order not to conflict with 5, the folder uses php7, the installation response is reported as an error during installation.

Docking nginx

nginx itself cannot process php scripts and needs to be sent to the php interpreter for processing.nginx generally sends requests to the fastcgi management process for processing,The fascgi management process selects the cgi child process to process the results and returns it to nginx.

#cp php.ini-production /usr/local/php7/etc/php.ini
#cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
#chmod + x /etc/init.d/php7-fpm
#cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
#cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

Start php-fpm

#service php7-fpm start

If the log file path does not exist in the middle, it is manually created and given write permission.

#service php7-fpm start
starting php-fpm [07-apr-2016 11:16:11] error:[pool www] cannot get gid for group "nobody"
[07-apr-2016 11:16:11] error:fpm initialization failed

When encountering this error,To add a nobody group, groupadd nobody, restart.

nginx configuration

This is when accessing the php file is turned into a download file,Because ng is not configured for response processing.

location ~ \ .php ${
      fastcgi_index index.php;
      fastcgi_param script_filename $document_root $fastcgi_script_name;
      include fastcgi_params;
  • Previous CodeIgniter method for generating static pages
  • Next Use DOM to control HTML elements in JS