Nginx Installation of php7+php5_php tips

Source: Internet
Author: User
Tags fpm php download

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:
# service PHP7-FPM Start

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;
    }

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: info-contact@alibabacloud.com 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.