Start
Before the server built a lamp environment, want to change the performance of more powerful Nginx as server software, but also want to upgrade PHP5 to PHP7.
Install nginx do not need to repeat: sudo apt-get install Nginx, start ng before you modify the Apache port.
Install PHP7
Source code in the http://php.net/downloads.php download, and decompression.
Copy Code code as follows:
# 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-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-- Enable-zip--enable-soap--without-pear--with-gettext--enable-session--with-curl-- With-freetype-dir--enable-opcache
# make
# make Install
In order to not conflict with 5, folders are used PHP7, installation of the error of the installation response dependency.
Docking Nginx
Nginx itself cannot handle PHP scripts and needs to be sent to the PHP interpreter for processing. Nginx is generally the request to send fastcgi management process processing, FASCGI management process Select the CGI subprocess processing results and return to be nginx.
Copy Code code as follows:
# 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
Copy Code code as follows:
Halfway through, if you encounter a log file path that does not exist, you manually create and write permissions.
Copy Code code as follows:
# 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
Failed
When you encounter this error, add a nobody group Groupadd nobody and restart.
Configuration of Nginx
This is the access to the PHP file is turned into a download file because NG does not configure response processing.
Location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include fastcgi_params;
}