Installing Nginx
Install PHP
Check the currently installed PHP package
If you have a PHP package installed, remove them first
[email protected] ~]# Yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring . x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
Configuring the Yum Source
[email protected] ~]# Yum install epel--IVH http://rpms.famillecollet.com/enterprise/ remi-release-7.rpm
Installing php5.6.x
[email protected] ~]# yum install--enablerepo=remi--enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-m Crypt Php-mysqlnd php-phpunit-phpunit Php-pecl-xdebug php-pecl-xhprof
View version
[[email protected] ~]# PHP--version
Installing PHP-FPM
[email protected] ~]# Yum install--enablerepo=remi--enablerepo=remi-php56 php-fpm
Configuration and optimization php-fpm
[Email protected] ~]# vim/etc/php-fpm.d/www.conf
after completing the PHP-FPM, configure it to run the user
[Email protected] ~]# vim etc/php-=-g Nginx
Modify Nginx configuration file to support PHP-FPM
[Email protected] ~]# vim/etc/nginx/nginx.conf
Add Blue Font
Worker_processes1; events {Worker_connections1024x768;} HTTP {include mime.types; Default_type Application/octet-stream; Sendfile on; Keepalive_timeout $; server {Listen the; server_name localhost; Location/{root HTML; Index index.html index.htm; Location~ \.php$ {root html; Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi_script_name; Include Fastcgi_params;} } error_page - 502 503 504/50x.html; Location= /50x.html {root html; } }}
With the location directive, all PHP-suffix files are handed to 127.0.0.1:9000, where the IP address and port are the IP addresses and ports that the fastcgi process listens to.
The fastcgi_param directive specifies the home directory where the PHP dynamic program is placed, that is, the path specified in the $fastcgi_script_name, which is the/usr/local/nginx/html directory. It is recommended that this directory be consistent with the root directory specified by the Nginx virtual host, but it can also be inconsistent.
The Fastcgi_params file is a parameter configuration file for the fastcgi process, and after installing Nginx, a file such as this is generated by default, which is included in the fastcgi parameter configuration file via the include directive.
Create a index.php file under/usr/share/nginx/html/
[[email protected] ~]# vim/usr/share/nginx/html/index.php Insert the following content <? php Echo phpinfo ();? >
Start PHP-FPM and Nginx
[Email protected] ~]# systemctl start php-fpm
[[email protected] ~]# systemctl start Nginx
To view the number of processes
[[Email protected] ~]# PS aux | Grep-c PHP-FPM
View IP address and port-related information for listening
9000
[Email protected] ~]# Ps-ef|grep php-cgi
access to HTTP://IP address/index.php, you can see the PHP information
Reference Documentation:
http://www.linuxidc.com/Linux/2010-05/26149.htmhttp://www.nginx.cn/231.html https://www.cnblogs.com/mangguoxiansheng/p/5967745.htmlhttps:// www.cnblogs.com/txtfashion/p/3669524.htmlhttp://blog.51cto.com/ixdba/806622http:// www.thinkphp.cn/topic/48196.html
Nginx PHP-FPM