nginx多站点配置,以及隐藏index.php
2017-11-09 22:50
831 查看
一、nginx多站点的配置
1、默认安装的nginx在/etc/nginx下,则执行以下命令sudo mkdir /etc/nginx/conf.d
这个conf.d作为我们放置多站点的目录
图中的admin.conf和api.conf就是我们新建的配置文件
2、在配置文件中写入你的网站配置
server { listen 80; server_name 你的域名,比如testA; root 网站的根目录; index index.php index.html; if (!-e $request_filename) { rewrite ^/(.*) /index.php/$1 last; } location ~* \.php { fastcgi_pass unix:/var/run/php5-fpm.sock; # fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; include fastcgi_params; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ /\.git { deny all; } }
如上即是testA网站的配置,这里只需要修改root路径为项目根目录,然后写上域名即可。
3、多站点配置文件完成之后,需要在总配置处引入一下多站点配置
(1)cd /etc/nginx
(2)vim nginx.conf
(3)
4、最后记得重启一下nginx服务,即可访问你所配置的站点
sudo service nginx restart
二、配置文件中隐藏index.php
if (!-e $request_filename) { rewrite ^/(.*) /index.php/$1 last; }
上面这句代码即可
end
相关文章推荐
- thinkphp的nginx配置,以及重写隐藏index.php入口文件
- Nginx隐藏index.php和配置vhost
- studyphp环境软件Nginx隐藏index.php和Pathinfo模式配置例子
- YII2 nginx配置pathinfo模式与隐藏入口index.php
- ThinkPHP5 Nginx下的配置——支持pathinfo访问和隐藏入口文件index.php的rewrite规则
- ubuntu LNMP nginx 隐藏index.php 配置文件
- nginx配置pathinfo模式和隐藏index.php
- Nginx服务器下ThinkPHP5访问出现404以及URL隐藏index.php
- Nginx隐藏index.php和Pathinfo模式配置例子
- nginx服务器 配置 ThinkPHP隐藏Index.php
- Nginx配置隐藏index.php和PATH_INFO支持
- Nginx配置REWRITE隐藏index.php
- Nginx配置-伪静态,隐藏index.php大入口
- Nginx配置 隐藏入口文件index.php
- nginx配置隐藏入口文件index.php详解
- Nginx配置PATHINFO隐藏index.php
- lnmp 一键安装包 nginx配置tp5 phpinfo模式 隐藏index.php
- centos7 thinphp5 Nginx隐藏index.php和Pathinfo模式配置
- Nginx隐藏index.php和Pathinfo模式配置例子
- nginx 404页面处理以及pathInfo和隐藏index.php总述