PHP 7 + Nginx configuration and installation tutorial details

Source: Internet
Author: User
Tags php error log
This document describes PHP7 + Nginx configuration and installation in steps, for more information about PHP7 + Nginx configuration and installation, see the following section.

The code is as follows:


Yum install pcre-devel openssl-devel-y

The code is as follows:


Tar xf nginx-1.10.0.tar.gz
Cd nginx-1.10.0

The code is as follows:


./Configure -- user = www \
-- Group = www \
-- Prefix =/data/server/nginx \
With-http_stub_status_module \
-- Without-http-cache \
With-http_ssl_module \
With-http_gzip_static_module

The code is as follows:


Make & make install

The code is as follows:


Tar xf php-7.0.6.tar.bz2
Cd php-7.0.6

The code is as follows:


Jpegsrc.v6b.tar.gz
Libpng-1.2.50.tar.gz
Freetype-2.1.10.tar.gz

# Install mongosrc.v6b.tar.gz # Create a folder for storing programs first. Otherwise, the error mkdir/usr/local/mongo.6/{bin, lib, include, will be reported, man/man1}-pvtar xf ready src.v6b.tar.gz cd jpeg-6b /. /configure -- prefix =/usr/local/cmd.6/make & make install # install the libpng-1.2.50.tar.gztar xf libpng-1.2.50.tar.gzcd. /configure -- prefix =/usr/local/libpng.1.2.50make & make install # install freetype-2.1.10.tar.gztar xf freetype-2.1.10.tar.gzcd freetype-2.1.10. /configure -- prefix =/usr/local/freetype.2.1.10/make & make install

The code is as follows:


Make & make install

The code is as follows:


Cp php. ini-production/u01/data/server/php/etc/php. ini

Configure php. ini

# In Line 3-set PHP's opcache and memcache Extension Library zend_extension = opcache. soextension = memcache. so #722 lines left and right-set PHP Extension Library path extension_dir = "/u01/data/server/php7/lib/php/extensions/no-debug-non-zts-20151012/" # avoid PHP information exposed in http expose_php = Off # avoid exposing the error message display_errors = Off for php calling mysql # enable PHP error log (path configured in php-fpm.conf) log_errors = On # set the PHP time zone date. timezone = PRC # enable opcache (about 1733 rows. enable = 1 # set the directory that PHP scripts allow access # open_basedir =/usr/share/nginx/html;

6. configure php-fpm

Php-fpm.conf process service master profile

# Set the error log path error_log =/var/log/php-fpm/error. log # introduce www. configuration in conf file include =/usr/local/php7/etc/php-fpm.d /*. conf # set the maximum number of files opened by the main process rlimit_files = 102400www. conf process service extension configuration file # Set user and user group user = wwwgroup = www # set php listening mode # listen = 127.0.0.1: 9000 # pay attention to setting PHP socket file permissions here, the default value is root, and Nginx cannot be accessed. Listen =/var/run/php-fpm/php-fpm.sock # enable slow log slowlog =/var/log/php-fpm/php-slow.logrequest_slowlog_timeout = 10 s # set the number of working processes (depending on the actual situation settings) pm. max_children = 50 # note that pm. start_servers cannot be smaller than pm. min_spare_serverspm.start_servers = 5. min _spare_servers = 5. max_spare_servers = 10 pm. max_requests = 10240 # set the php session directory (both the user and user group are www) php_value [session. save_handler] = filesphp_value [session. save_path] =/var/tmp/php/session

7. provide the php-fpm startup script

#! /bin/sh#prefix=/u01/data/server/php7exec_prefix=${prefix}php_fpm_BIN=${exec_prefix}/sbin/php-fpmphp_fpm_CONF=${prefix}/etc/php-fpm.confphp_fpm_PID=${prefix}/var/run/php-fpm.pidphp_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"wait_for_pid () {try=0while test $try -lt 35 ; docase "$1" in'created')if [ -f "$2" ] ; thentry=''breakfi;;'removed')if [ ! -f "$2" ] ; thentry=''breakfi;;esacecho -n .try=`expr $try + 1`sleep 1done}case "$1" instart)echo -n "Starting php-fpm "$php_fpm_BIN --daemonize $php_optsif [ "$?" != 0 ] ; thenecho " failed"exit 1fiwait_for_pid created $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed"exit 1elseecho " done"fi;;stop)echo -n "Gracefully shutting down php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -QUIT `cat $php_fpm_PID`wait_for_pid removed $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed. Use force-quit"exit 1elseecho " done"fi;;status)if [ ! -r $php_fpm_PID ] ; thenecho "php-fpm is stopped"exit 0fiPID=`cat $php_fpm_PID`if ps -p $PID | grep -q $PID; thenecho "php-fpm (pid $PID) is running..."elseecho "php-fpm dead but pid file exists"fi;;force-quit)echo -n "Terminating php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -TERM `cat $php_fpm_PID`wait_for_pid removed $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed"exit 1elseecho " done"fi;;restart)$0 stop$0 start;;reload)echo -n "Reload service php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -USR2 `cat $php_fpm_PID`echo " done";;*)echo "Usage: $0 {start|stop|force-quit|restart|reload|status}"exit 1;;esac

8. start the php-fpm program

/Etc/init. d/php-fpm start # Modify the socket file permission chown-R/var/run/php-fpm/

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.