各位好:
我在/usr/local/nginx/conf/vhosts下配置两个配置文件,分别为aaa.conf:
内容为:
server
{
listen 80;
server_name aaa.com;
index index.htm index.html index.php;
root /data/www;
location ~\.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
}
另一个为111.conf
server
{
listen 80;
server_name 111.com;
index index.html index.htm index.php;
root /data/wordpress;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/www1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/wordpress$fastcgi_script_name;
}
}
并且我在php-fpm.conf中规定了两个pool,配置如下:
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
listen = /tmp/www.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
slowlog = /tmp/www_slow.log
request_slowlog_timeout = 1
php_admin_value[open_basedir] = /data/www:/tmp/
[www1]
listen = /tmp/www1.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
slowlog = /tmp/www1_slow.log
request_slowlog_timeout = 1
php_admin_value[open_basedir] = /data/wordpress:/tmp/
现在是curl的结果:
[root@wtest vhosts]# curl -x127.0.0.1:80 aaa.com -I
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Thu, 24 Mar 2016 09:42:26 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.37
location: forum.php
[root@wtest vhosts]# curl -x127.0.0.1:80 111.com -I
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.6.2
Date: Thu, 24 Mar 2016 09:42:52 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.37
Location: http://111.com/wp-admin/setup-config.php
但在windows端,我设置的192.169.1.200 www.aaa.com
但无法访问显示404,而直接访问192.169.1.200 则显示的是wordpress的内容
请各位帮忙分析下,这是为什么,为什么不能直接访问aaa.com的内容
我在/usr/local/nginx/conf/vhosts下配置两个配置文件,分别为aaa.conf:
内容为:
server
{
listen 80;
server_name aaa.com;
index index.htm index.html index.php;
root /data/www;
location ~\.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
}
另一个为111.conf
server
{
listen 80;
server_name 111.com;
index index.html index.htm index.php;
root /data/wordpress;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/www1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/wordpress$fastcgi_script_name;
}
}
并且我在php-fpm.conf中规定了两个pool,配置如下:
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
listen = /tmp/www.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
slowlog = /tmp/www_slow.log
request_slowlog_timeout = 1
php_admin_value[open_basedir] = /data/www:/tmp/
[www1]
listen = /tmp/www1.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
slowlog = /tmp/www1_slow.log
request_slowlog_timeout = 1
php_admin_value[open_basedir] = /data/wordpress:/tmp/
现在是curl的结果:
[root@wtest vhosts]# curl -x127.0.0.1:80 aaa.com -I
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Thu, 24 Mar 2016 09:42:26 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.37
location: forum.php
[root@wtest vhosts]# curl -x127.0.0.1:80 111.com -I
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.6.2
Date: Thu, 24 Mar 2016 09:42:52 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.37
Location: http://111.com/wp-admin/setup-config.php
但在windows端,我设置的192.169.1.200 www.aaa.com
但无法访问显示404,而直接访问192.169.1.200 则显示的是wordpress的内容
请各位帮忙分析下,这是为什么,为什么不能直接访问aaa.com的内容
0
你把你的需求 详细的说一遍(即你想做什么)
aaa.conf 和 111.conf 都是监听的 80端口 麻烦你把你这个配置的参考文档发给我看看
正常的配置是 不同的conf配置文件监听不同的端口
比如 aaa.com 监听80 111.conf 监听 81
aaa.conf 和 111.conf 都是监听的 80端口 麻烦你把你这个配置的参考文档发给我看看
正常的配置是 不同的conf配置文件监听不同的端口
比如 aaa.com 监听80 111.conf 监听 81
0
我想在windows端能够两个都能访问,我在windos端host中设置了 现在对应的是192.169.1.200。
我现在是以php 的pool 来限定了两个虚拟主机,应该跟监听端口没有关系吧。
我的nginx的主配置文件,是直接复制的铭哥的资料里的。你要是需要,我可以附在这里。
而我现在在IE访问www.aaa.com,显示的是HTTP 404
但是curl 是正常的
乐橙306 发表于 2016-3-24 18:56
你把你的需求 详细的说一遍(即你想做什么)
aaa.conf 和 111.conf 都是监听的 80端口 麻烦你 ...
我想在windows端能够两个都能访问,我在windos端host中设置了 现在对应的是192.169.1.200。
我现在是以php 的pool 来限定了两个虚拟主机,应该跟监听端口没有关系吧。
我的nginx的主配置文件,是直接复制的铭哥的资料里的。你要是需要,我可以附在这里。
而我现在在IE访问www.aaa.com,显示的是HTTP 404
但是curl 是正常的
0
- 需求大致是这样的
- 看下我理解没
- 若客户端访问aaa.com 那么他就访问服务端/data/www 下的内容
- 若客户端访问111.com 那么他就访问服务端/data/wordpress 下的内容
- 具体怎么实现
- [root@aliyun-63 conf.d]# pwd
- /etc/nginx/conf.d
- [root@aliyun-63 conf.d]# cat sundong.wang.conf
- server {
- listen 80 default_server;
- server_name www.sundong.wang;
- root /usr/share/nginx/html;
- index index.html index.htm;
- }
- [root@aliyun-63 conf.d]# cat sundong.xyz.conf
- server
- {
- listen 80;
- server_name www.sundong.xyz;
- index index.html index.htm index.php;
- root /var/www/html;
- }
- [root@aliyun-63 conf.d]#
- [root@aliyun-63 conf.d]# curl -I www.sundong.wang/1.htm
- HTTP/1.1 200 OK
- Server: nginx/1.0.15
- Date: Fri, 25 Mar 2016 01:49:40 GMT
- Content-Type: text/html
- Content-Length: 11283
- Last-Modified: Thu, 24 Mar 2016 03:31:29 GMT
- Connection: keep-alive
- Accept-Ranges: bytes
- [root@aliyun-63 conf.d]# curl -I www.sundong.xyz/1.htm
- HTTP/1.1 200 OK
- Server: nginx/1.0.15
- Date: Fri, 25 Mar 2016 01:49:45 GMT
- Content-Type: text/html
- Content-Length: 96817
- Last-Modified: Fri, 25 Mar 2016 01:31:21 GMT
- Connection: keep-alive
- Accept-Ranges: bytes
- [root@aliyun-63 conf.d]#
0
- [root@aliyun-63 conf.d]# cd /usr/share/nginx/html
- [root@aliyun-63 html]# ll
- total 4064
- drwxr-xr-x 2 root root 4096 Mar 24 11:31 1_files
- -rw-r--r-- 1 root root 1239730 Mar 24 11:32 1_files.zip
- -rw-r--r-- 1 root root 11283 Mar 24 11:31 1.htm
- drwxr-xr-x 2 root root 4096 Mar 24 11:31 2_files
- -rw-r--r-- 1 root root 1420851 Mar 24 11:32 2_files.zip
- -rw-r--r-- 1 root root 26819 Mar 24 11:31 2.htm
- drwxr-xr-x 2 root root 4096 Mar 24 11:32 3_files
- -rw-r--r-- 1 root root 1370082 Mar 24 11:32 3_files.zip
- -rw-r--r-- 1 root root 53044 Mar 24 11:32 3.htm
- -rw-r--r-- 1 root root 3652 Jun 17 2015 404.html
- -rw-r--r-- 1 root root 3695 Jun 17 2015 50x.html
- -rw-r--r-- 1 root root 3698 Jun 17 2015 index.html
- -rw-r--r-- 1 root root 368 Jun 17 2015 nginx-logo.png
- -rw-r--r-- 1 root root 2811 Jun 17 2015 poweredby.png
- [root@aliyun-63 html]# cd /var/www/html
- [root@aliyun-63 html]# ll
- total 3132
- drwxr-xr-x 2 root root 4096 Mar 25 09:31 1_files
- -rw-r--r-- 1 root root 217099 Mar 25 09:31 1_files.zip
- -rw-r--r-- 1 root root 96817 Mar 25 09:31 1.htm
- drwxr-xr-x 2 root root 4096 Mar 24 11:31 2_files
- -rw-r--r-- 1 root root 1420851 Mar 24 11:32 2_files.zip
- -rw-r--r-- 1 root root 26819 Mar 24 11:31 2.htm
- drwxr-xr-x 2 root root 4096 Mar 24 11:32 3_files
- -rw-r--r-- 1 root root 1370082 Mar 24 11:32 3_files.zip
- -rw-r--r-- 1 root root 53044 Mar 24 11:32 3.htm
- [root@aliyun-63 html]# curl -I www.sundong.wang/2.htm
- HTTP/1.1 200 OK
- Server: nginx/1.0.15
- Date: Fri, 25 Mar 2016 01:52:07 GMT
- Content-Type: text/html
- Content-Length: 26819
- Last-Modified: Thu, 24 Mar 2016 03:31:56 GMT
- Connection: keep-alive
- Accept-Ranges: bytes
- [root@aliyun-63 html]# curl -I www.sundong.wang/3.htm
- HTTP/1.1 200 OK
- Server: nginx/1.0.15
- Date: Fri, 25 Mar 2016 01:52:32 GMT
- Content-Type: text/html
- Content-Length: 53044
- Last-Modified: Thu, 24 Mar 2016 03:32:03 GMT
- Connection: keep-alive
- Accept-Ranges: bytes
- [root@aliyun-63 html]# curl -I www.sundong.xyz/3.htm
- HTTP/1.1 404 Not Found
- Server: nginx/1.0.15
- Date: Fri, 25 Mar 2016 01:52:40 GMT
- Content-Type: text/html
- Content-Length: 169
- Connection: keep-alive
- [root@aliyun-63 html]# curl -I www.sundong.xyz/2.htm
- HTTP/1.1 404 Not Found
- Server: nginx/1.0.15
- Date: Fri, 25 Mar 2016 01:52:46 GMT
- Content-Type: text/html
- Content-Length: 169
- Connection: keep-alive
- [root@aliyun-63 html]#
0
我提问的原因是我在windows端设置的etc/hosts,192.169.1.200 www.aaa.com
而实际上我访问aaa.com出现的内容却是 111.com。
我用的使php-fpm两个不同的pool。
并且我在linux上curl的内容实际上是正确的,但是在windows端显示不正确。
我想知道 windows不正确的原因
而实际上我访问aaa.com出现的内容却是 111.com。
我用的使php-fpm两个不同的pool。
并且我在linux上curl的内容实际上是正确的,但是在windows端显示不正确。
我想知道 windows不正确的原因
0
本帖最后由 we14578 于 2016-3-25 22:24 编辑
域名,www.aaa.com,还有直接访问IP,192.169.1.200,我也试了,但是不知道为什么显示的就是111.com的内容
域名,www.aaa.com,还有直接访问IP,192.169.1.200,我也试了,但是不知道为什么显示的就是111.com的内容
编辑回复