[[Email protected] ~]#wget http://am1.php.net/get/php-7.1.2.tar.gz/from/this/mirror[[Email protected] ~]#tar xzvf php-7.1.2.tar.gz[[Email protected] ~]#CD php-7.1.2/[[Email protected] ~]#./configure--prefix=/usr/local/php--enable-fpm[[email protected] php-7.1.2]#Make&&make InstallTo see if the installation was successfully compiled Php[[email protected] PHP-7.1.2]#php-vPHP 7.1.2 (fpm-fcgi) (built:apr 14 2017 20:21:53) Copyright (c)1997-2017The PHP groupzend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
After compiling the installation, PHP does not have the configuration file php.ini, at this time only need to copy Php.ini-production to/usr/local/lib/php.ini, php.ini files are generally in/usr/local/lib/and/etc directory
[[email protected] php-7.1.2]#CP Php.ini-production/usr/local/lib/php.ini[[email protected] PHP]#/USR/LOCAL/PHP/SBIN/PHP-FPM[14-apr-2017 20:59:49] error:failed to open configuration file'/usr/local/php/etc/php-fpm.conf': No such fileorDirectory (2)[14-apr-2017 20:59:49] error:failed to load configuration file'/usr/local/php/etc/php-fpm.conf'[14-apr-2017 20:59:49] ERROR:FPM initialization failed start PHP-FPM found a lack of configuration files/usr/local/php/etc/php-fpm.conf just copy php at this timeThe-FPM configuration file/usr/local/php/etc/php-fpm.conf.default to the corresponding/usr/local/php/etc/php-of the configuration file provided when PHP is installedfpm.conf [[email protected] etc]#/USR/LOCAL/PHP/SBIN/PHP-FPM[14-apr-2017 21:14:32] Warning:nothing matches the include pattern'/usr/local/php/etc/php-fpm.d/*.conf' from/usr/local/php/etc/php-fpm.conf at line 125. [14-apr-2017 21:14:32] error:no pool defined. At least one pool sections must be specifiedinchconfig file[14-apr-2017 21:14:32] error:failed to post process the configuration[14-apr-2017 21:14:32] ERROR:FPM initialization failed[[email protected] etc]#CP php-fpm.conf.default/usr/local/php/etc/php-fpm.conf[[email protected] etc]#cp/usr/local/php/etc/php-fpm.d/www.conf.default/usr/local/php/etc/php-fpm.d/www.conf[[email protected] etc]#/ETC/INIT.D/PHP-FPM[14-apr-2017 21:23:02] Error:unable to bind listening socket forAddress'127.0.0.1:9000': Address alreadyinchUse (98)[14-apr-2017 21:23:02] ERROR:FPM initialization failed[[email protected] etc]#Netstat-nldp|grep 9000TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3721/php-fpm:maste [[email protected] PHP-7.1.2]#CP sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm[[email protected] php-7.1.2]#chmod a+x/etc/init.d/php-fpm[[email protected] php-7.1.2]#LL/ETC/INIT.D/PHP-FPM-rwxr-xr-x 1 root root 2401 April 21:26/etc/init.d/php-fpm[[email protected] PHP-7.1.2]#/etc/init.d/php-fpm StartStarting PHP-FPM [14-apr-2017 21:28:09] error:unable to bind listening socket forAddress'127.0.0.1:9000': Address alreadyinchUse (98)[14-apr-2017 21:28:09] ERROR:FPM initialization failed failed[[email protected] PHP-7.1.2]#NETSTAT-NLDP |grep 9000TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3721/php-fpm:maste [[email protected] PHP-7.1.2]#Kill 3721[[email protected] php-7.1.2]#NETSTAT-NLDP |grep 9000[[email protected] php-7.1.2]#/etc/init.d/php-fpm StartStarting php-fpm done[[email protected] PHP-7.1.2]#Service PHP-FPM StatusPHP-FPM (PID 3927) isrunning ... [[email protected] PHP-7.1.2]#chkconfig--add php-fpm[[email protected] php-7.1.2]#chkconfig php-fpm--level 345 on
Configuring Nginx support Phpuseradd Nginx-g Nginx[[email protected] php-7.1.2]#vim/usr/local/nginx/conf/nginx.conf user Nginxnginx; worker_processes Auto; Error_log logs/Error.log;#error_log logs/error.log notice;#error_log logs/error.log info;PID Logs/nginx.pid;events {worker_connections1024;} HTTP {include mime.types; Default_type Application/octet-stream; #Log_format main ' $remote _addr-$remote _user [$time _local] "$request" ' #' $status $body _bytes_sent ' $http _referer ' #' "$http _user_agent" "$http _x_forwarded_for"; #access_log Logs/access.log main;Server_tokens off; Sendfile on; Tcp_nopush On;tcp_nodelay on; #keepalive_timeout 0;Keepalive_timeout 30; Send_timeout30; gzip on; server {Listen80; server_name localhost; CharSet UTF -8; #access_log Logs/host.access.log main; Location/{root/data/ Webroot; Index index.php index.html; } error_page404/404. html; #Redirect Server error pages to the static page/50x.html #Error_page 500 502 503 504/50x.html; Location=50x.html {root/data/ Webroot; } #Proxy The PHP scripts to Apache listening on 127.0.0.1:80 # #Location ~ \.php$ { #Proxy_pass http://127.0.0.1; #} #Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # Location ~ \.php$ {root /data/webroot; Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename /data/webroot/$fastcgi _script_name; Include Fastcgi_params; } #deny access to. htaccess files, if Apache ' s document Root #concurs with Nginx ' s one # #Location ~/\.ht { #deny all; #} } #Another virtual host using mix of ip-, name-, and port-based configuration # #server { #Listen 8000; #Listen somename:8080; #server_name somename alias Another.alias; #Location /{ #Root/data/webroot; #index index.html index.htm; # } #} #HTTPS Server # #server { #listen 443 SSL; #server_name localhost; #ssl_certificate Cert.pem; #Ssl_certificate_key Cert.key; #Ssl_session_cache shared:ssl:1m; #ssl_session_timeout 5m; #ssl_ciphers high:!anull:! MD5; #ssl_prefer_server_ciphers on; #Location /{ #root html; #index index.html index.htm; # } #}}
Create test.php Test nginx support PHP below we are in /data/webroot this directory to create a new PHP page test page, the file name is test.php
1 < php2phpinfo (); 3 ?>
then restart PHP and Nginx[[email protected] PHP-7.1.2] # Gracefully shutting down php-fpm. donestarting php-fpm done[[email protected] php -7.1.2]#restarting Nginx (via Systemctl): [ OK ] After restarting PHP and Nginx we enter HTTP in the browser://192.168.42.131/test.php
Finally put your website template into the/data/webroot
Configuration support PHP7 in the <nginx+php>nginx environment