Install php7 + php5 in nginx and php7php5 in nginx

Source: Internet
Author: User

Install php7 + php5 in nginx and php7php5 in nginx


Previously, I set up a lamp environment on the server. I want to use nginx with higher performance as the server software and upgrade php5 to php7.

To install nginx, do not go into details: sudo apt-get install nginx. Modify the apache port before starting ng.

Install php7

Download the source code in the and unzip it.

Copy codeThe Code is as follows: # cd php7 ***
#. /Configure -- prefix =/usr/local/php7 -- with-config-file-path =/usr/local/php7/etc -- with-mcrypt =/usr/include --- 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

If it is not in conflict with 5, PHP 7 is used in the folder, and an error is reported during installation.

Connect to nginx

Nginx itself cannot process php scripts and must be sent to the php interpreter for processing. Nginx generally sends a request to the fastcgi management process for processing. The fascgi management process selects the cgi sub-process for processing the result and returns nginx.

Copy codeThe Code is 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 codeThe Code is as follows: # service php7-fpm start

If the path of the log file does not exist in the middle, you can manually create and grant the write permission.

Copy codeThe Code is 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

When this error occurs, add a nobody group groupadd nobody and restart.

Nginx Configuration

This indicates that the PHP file is changed to the downloaded file because ng does not configure Response Processing.

location ~ \.php$ {      fastcgi_pass;      fastcgi_index index.php;      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;      include    fastcgi_params;    }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.