Nginx和PHP-FPM结合

PHP-FPM运行模式:

1.socket 
listen = /usr/local/php/var/run/www.sock

2.tcp
listen = 127.0.0.1:9000

Nginx结合PHP-FPM的两种模式:

1.socket
fastcgi_pass unix:/usr/local/php/var/run/www.sock;
2.tcp
fastcgi_pass  127.0.0.1:9000;
Nginx支持PHP程序:
location ~ \.php$ {       
	fastcgi_index index.php;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
	include fastcgi_params;
}

测试php动态脚本:

1.配置文件语法检测

nginx -t

2.配置index.php默认首页的优选级

location / {
	index index.php index.html
}

3.nginx结合php

vi /etc/nginx/default.d/php.conf
location ~ \.php$ {       
	fastcgi_index index.php;
	#fastcgi_pass unix:/run/php-fpm/www.sock;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
	include fastcgi_params;
}

4.重启nginx或重载nginx

/usr/local/nginx/sbin/nginx -s reload
pkill -HUP nginx

5.客户端测试

http://192.168.2.1
RIPRO主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
靠谱资源下载 » Nginx和PHP-FPM结合

发表评论

提供最优质的资源集合

立即查看 了解详情