【发布时间】:2018-10-15 00:00:41
【问题描述】:
问题:无法访问在一台 nginx 服务器下处理的两个网站,即<<ip-address>> & <<ip-address>>/web2
数字海洋上的配置:
- 1 滴 / Ubuntu 18 / LEMP
- 我在 CodeIgniter 框架中有两个测试 PHP 网站
- 第一个网站的文件夹配置:
/var/www/html/web1/ - 第二个网站的文件夹配置:
/var/www/html/web2/
两个站点的 Nginx Server Block 配置
web1.com
server {
listen 80;
root /var/www/html/web1;
index index.php index.html index.htm index.nginx-debian.html;
server_name <<ip-address>>;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
web2.com
server {
listen 80;
root /var/www/html/web2;
index index.php index.html index.htm index.nginx-debian.html;
server_name <<ip-address>>/web2;
location /web2/ {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
我对nginx服务器完全陌生,我是根据数字海洋下的一个社区提供的文档来做的。
请帮忙!
谢谢。
【问题讨论】:
-
那么,问题是没有任何效果?你最终在两个网址上都在同一个网站上?你最终进入了 404 页面?
-
是的,它不起作用。两个 URL 都应该访问不同的网站 目前,它试图从
web1站点找到web2作为控制器,因此出错。 -
你得到什么错误信息?
标签: php codeigniter nginx nginx-config