nginx虚拟机配置(支持php)
由于本人水平有限,以下记录仅作参考。
下面贴出我的一份正常运行的nginx服务器虚拟机配置。/usr/local/nginx/conf/vhost/www.xsll.com.conf
server {
listen ; #虚拟主机监听端口
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/ =;
if (!-e $request_filename){
rewrite ^/(.*)?$ /$.php?last;
}
} error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
location ~ \.php$ {
#root html;
try_files $uri = ;
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 = -
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode =
user = www
group = www
pm = dynamic
pm.max_children =
pm.start_servers =
pm.min_spare_servers =
pm.max_spare_servers =
request_terminate_timeout =
request_slowlog_timeout =
slowlog = var/log/slow.log
可以看到在虚拟主机配置的38行:fastcgi_pass unix:/tmp/php-cgi.sock;这个路径正式php配置文件中第7行:listen = /tmp/php-cgi.sock;这样nginx虚拟机就支持了PHP程序解析了。
nginx虚拟机配置(支持php)的更多相关文章
- nginx之 nginx虚拟机配置
1.配置通过域名区分的虚拟机[root@mysql03 nginx]# cat conf/nginx.confworker_processes 1; events { worker_connectio ...
- nginx虚拟机配置
#虚拟主机的配置server {#监听端口listen 80;#服务器域名server_name localhost;#网页的默认编码#charset koi8r;#访问该虚拟主机的日志位置#acce ...
- Nginx安装、平滑升级与虚拟机配置
Nginx 高性能HTTP反向代理服务器,也是 LAMP/POP3/SMTP代理服务器 由内核和模块组成,内核通过找配置文件讲客户端请求映射到一个location(location是Nginx配置中的 ...
- Nginx下配置ThinkPHP的URL Rewrite模式和pathinfo模式支持
前面有关于lnmp环境的搭建,在此就不在赘述.下面就简述thinkPHP如何在nginx下开启url_rewrite和pathinfo模式支持 主要有两个步骤: 一.更改php.ini将;cgi.fi ...
- nginx配置支持http2
1.简介 nginx 配置支持http2.目前大多数网站都是http1.1(如果你没有特别配置过的话) 一切都是为了访问更快. 2.如何查看自己网站的http版本 最简单的方法就F12啊,我这里是火狐 ...
- 转自《https安全链接的配置教程:startSSl免费证书申请与nginx的https支持配置》
一.什么是 SSL 证书,什么是 HTTPS 网站? SSL证书是数字证书的一种,类似于驾驶证.护照和营业执照的电子副本.SSL证书通过在客户端浏览器和Web服务器之间建立一条SSL安全通道(Secu ...
- Nginx配置支持https协议-应用实践
Nginx配置支持https协议-应用实践 https简介 HTTPS 是运行在 TLS/SSL 之上的 HTTP,与普通的 HTTP 相比,在数据传输的安全性上有很大的提升. TLS是传输层安全协议 ...
- nginx 配置支持URL HTML5 History 模式 与 设置代理
拾人牙慧:https://segmentfault.com/q/1010000007140360 nginx 配置支持URL HTML5 History 模式 location / { try_fil ...
- nginx+jwplayer配置flv/MP4点播系统, 视频拖动支持
一 配置nginx 1. 下载 nginx 最新版 http://nginx.org/ 2. 安装依赖库, 以ubuntu为例 apt-get install libpcre3 libpcre3-de ...
随机推荐
- 验证整数 Double 转 int 两种写法
Double 转int 1)之前一直是使用强转 Double num = Double.parseDouble(object.toString()); int n = (int)num; i ...
- python文件名和文件路径操作
Readme: 在日常工作中,我们常常涉及到有关文件名和文件路径的操作,在python里的os标准模块为我们提供了文件操作的各类函数,本文将分别介绍"获得当前路径""获得 ...
- [VirtualBox] 1、NAT模式下端口映射
1.VirtualBox中有4中网络连接方式 VirtualBox中有4中网络连接方式:NAT.Bridged Adapter.Internal.Host-only Adapter,VMWare中有三 ...
- Sql Server——查询(二)
上次写了查询里的一些简单的查询方法,如果说上次的是初级查询,那这次的就是高级查询了. 今天主要是聚合函数.分组查询.连接查询.联合查询.在我看来前三个挺简单的,稍微难理解点的也就最后一个,为什么呢?因 ...
- SUM游戏
题意:就是有一个长度为n的整数序列,两个游戏者A和B轮流取数,A先取.每次玩家只能从左端或者右端取任意数量个数,但不能两端都取. 所有数都被取走后游戏结束,然后统计每个人取走的所有数之和,作为各自的得 ...
- eslint使用
参考文档 http://www.cnblogs.com/hahazexia/p/6393212.html http://blog.guowenfh.com/2016/08/07/ESLint-Rule ...
- 【转】Windows自动连接、断开无线网络
前提是先连接到指定的WiFi网络上. 然后通过 netsh wlan export profile 将网络配置文件导出,然后使用如下命令添加配置文件到指定的网络接口上,再执行连接命令即可. netsh ...
- C#中 计时器用法
有时候我们会需要计算某段代码运行的时间比如一个sql查询,记录一段代码所花费的时间等等代码如下: System.Diagnostics.Stopwatch watch = new System.Dia ...
- ZOJ2401 Zipper 双塔式 DP
遇到双塔DP,写一下. flag是为了避免memset多次导致的时间浪费. #include<cstdio> #include<cstdlib> #include<ios ...
- Sql Server 数据库中调用dll文件
1.首先新建一个空的解决方案,并添加一个类库,代码如下,编译并生产dll using System; using System.Collections.Generic; using System.Da ...