nginx虚拟机配置(支持php)
2015-06-25 19:04
274 查看
由于本人水平有限,以下记录仅作参考。
下面贴出我的一份正常运行的nginx服务器虚拟机配置。/usr/local/nginx/conf/vhost/www.xsll.com.conf
下面我贴出我的php的配置文件/user/local/php/etc/php-fpm.conf
可以看到在虚拟主机配置的38行:fastcgi_pass unix:/tmp/php-cgi.sock;这个路径正式php配置文件中第7行:listen = /tmp/php-cgi.sock;这样nginx虚拟机就支持了PHP程序解析了。
下面贴出我的一份正常运行的nginx服务器虚拟机配置。/usr/local/nginx/conf/vhost/www.xsll.com.conf
server { listen 80; #虚拟主机监听端口 server_name www.xsll.com; #虚拟主机名称 #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; root /home/wwwroot/default/discuz/upload; #你的项目目录 index index.php index.html index.htm; #默认寻找的文件 location / { try_files $uri $uri/ =404; if (!-e $request_filename){ rewrite ^/(.*)?$ /$1.php?last; } } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # 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 html; try_files $uri = 404; fastcgi_pass unix:/tmp/php-cgi.sock; #这一行很重要,路径要与PHP配置文件中的监听路径相同,但前面要加unix:/ fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param SCRIPT_FILENAME /scripts$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; #} }
下面我贴出我的php的配置文件/user/local/php/etc/php-fpm.conf
[global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice [www] listen = /tmp/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www pm = dynamic pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 6 request_terminate_timeout = 100 request_slowlog_timeout = 0 slowlog = var/log/slow.log
可以看到在虚拟主机配置的38行:fastcgi_pass unix:/tmp/php-cgi.sock;这个路径正式php配置文件中第7行:listen = /tmp/php-cgi.sock;这样nginx虚拟机就支持了PHP程序解析了。
相关文章推荐
- nginx 内存池
- 使用Nginx+Keepalived组建高可用负载平衡Web server集群
- nginx学习笔记
- LOGSTASH+ELASTICSEARCH+KIBANA处理NGINX访问日志
- Thread Pools in NGINX Boost Performance 9x!
- nginx 安装问题
- 使用 varnish + nginx + lua 搭建网站的降级系统
- NGINX引入线程池 性能提升9倍
- nginx php-fpm安装配置
- nginx后端代理多台php-fpm服务器;(补充上一篇博客)
- ubuntu下nginx编译安装
- nginx filter
- 提高web性能!nginx和php-fpm分别部署在不同服务器;
- Nginx配置文件nginx.conf中文详解
- Nginx和PHP-FPM的启动、重启、停止脚本
- nginx php解析过慢
- nginx负载均衡配置,宕机自动切换
- nginx location匹配规则
- nginx搭建pathinfo模式支持
- 深入 NGINX: 我们如何设计性能和扩展