nginx下的站点配置(端口和hosts)两种模式
来源:互联网 发布:egd网络黄金骗局3.15 编辑:程序博客网 时间:2024/06/03 21:53
一般默认是80端口,以hosts模式配置多站点可以设置如下:
server {
listen 80;
server_name allwood-com.cn;
root "D:/phpStudy/WWW/allwood-com";
charset utf-8;
index index.php index.html index.htm;
location / {
index index.html index.htm index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APP_ENV 'test';
#fastcgi_param PATH_INFO $request_uri;
}
}
server {
listen 80;
server_name tp_wood.cn;
root "D:/phpStudy/WWW/tp_wood";
charset utf-8;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?s=/$1;
}
location ~ \.php$ {
root "D:/phpStudy/WWW/tp_wood";
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
client_max_body_size 5m;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
这是两个nginx两个配置,对应的hostst配置就如下:
127.0.0.1 allwood-com.cn
127.0.0.1 tp_wood.cn
这样就完成了两个站点的配置了。如果不想配置hosts,可以配置端口;
server {
listen 8090;
server_name www.ykg.com ykg.cn;
root "D:/phpStudy/WWW/ykg/public";
location / {
index index.html index.htm index.php;
#autoindex on;
autoindex off;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
server {
listen 8080;
server_name www.testredis.com testredis.cn;
root "D:/phpStudy/WWW/laravel/public";
location / {
index index.html index.htm index.php;
#autoindex on;
autoindex off;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
这样的配置也是ok的。
- nginx下的站点配置(端口和hosts)两种模式
- centos7下gitlab的配置(nginx冲突、端口更改)
- Nginx实现多个站点使用一个端口(配置Nginx的虚拟主机)
- Nginx实现多个站点使用一个端口(配置Nginx的虚拟主机)
- Nginx实现多个站点使用一个端口(配置Nginx的虚拟主机)
- Nginx实现多个站点使用一个端口(配置Nginx的虚拟主机)
- Nginx实现多个站点使用一个端口(配置Nginx的虚拟主机)
- 在ubuntu利用nginx反响代理在一个端口下配置多个站点
- webpack配置ip和端口号的两种方式
- 配置Apache 和 配置Nginx 的默认站点
- centOS下的nginx1.8.0多站点配置(同一IP,不同端口)
- nginx服务器下配置多个站点的方法
- nginx服务器下配置多个站点的方法
- WAMP多站点的配置和自拟定端口号
- Nginx 的多站点配置
- Nginx 的多站点配置
- Nginx 的多站点配置
- Nginx 的多站点配置
- 转自网上的 关于链表的基本操作
- iOS开发 适配iOS10以及Xcode8
- PHP异常问题的处理
- php编译安装详解(二)
- easyui的自适应大小设置
- nginx下的站点配置(端口和hosts)两种模式
- Oracle中B-Tree索引与Bitmap位图索引的锁代价比较研究
- 构造树
- spring mvc 处理错误接口 不用返回404
- C#文件下载、文件分块下载实例(一)
- cherry-pick 同时修改commit message
- understanding linux usb ehci device driver(1)
- java中的网络通讯
- 二叉树学习总结:二叉树的基本操作、遍历二叉树、中序线索化二叉树、中序遍历线索二叉树