Getting Started
I have built a lamp environment on the server before. I want to switch to nginx with stronger performance as the server software, and I also want to upgrade php5 to php7.
No need to go into details when installing nginx: sudo apt-get install nginx
, modify the apache port before starting ng.
Install php7
The source code is downloaded from http://php.net/downloads.php
and unzipped.
# 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 # make install
In order not to conflict with 5, all folders use php7, and the dependencies of the installation response when errors are reported during the installation process.
Connecting to nginx
nginx itself cannot process PHP scripts and needs to be sent to the PHP interpreter for processing. nginx generally sends the request to the fastcgi management process for processing. The fascgi management process selects the cgi sub-process processing result 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 you encounter a log file path that does not exist, create it manually and give it 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 failed
When encountering this error, add a nobody
groupgroupadd nobody
and then restart.
nginx configuration
This is when accessing the php file, it becomes a download file, because ng is not configured for 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; }
Thank you for using PHP.
The above is the detailed content of Install php7 and coexist with php5. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools