VPS侦探论坛

 找回密码
 注册
查看: 6732|回复: 6

lnmp1.1下面多vhost问题

[复制链接]
发表于 2014-11-27 19:07:05 | 显示全部楼层 |阅读模式

lnmp1.1装完之后做了一点简单的优化,随即添加了5个vhost,添加完后,发现4个vhost工作正常,其中一个vhost访问老是404(原来可以访问,添加到5个vhost之后变得无法访问,配置文件都是自动生成,域名都可以ping通),default原来也可以访问,后面也是变成404,

检查日志后,发现都没啥报错

/home/wwwlogs/nginx_error.log,
/home/wwwlogs/access.log,
/usr/local/nginx/logs/errors.log,
/usr/local/php/var/log/php-fpm.log,


检查www.domain.com.log.提示如下:

- - [27/Nov/2014:17:52:27 +0800] "GET /tz.php HTTP/1.1" 404 56 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" -
- - [27/Nov/2014:17:52:37 +0800] "GET /tz.php HTTP/1.1" 404 56 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" -
- - [27/Nov/2014:17:52:42 +0800] "GET / HTTP/1.1" 404 56 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" -
- - [27/Nov/2014:17:57:10 +0800] "GET / HTTP/1.1" 404 56 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" -

请问是啥原因呢?

[ 本帖最后由 xdop 于 2014-11-27 19:15 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2014-11-27 20:25:13 | 显示全部楼层


发报错的配置文件及网站目录情况及权限情况
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2014-11-27 20:56:17 | 显示全部楼层

出错Vhost: oc2.domain.com.conf(最开始可以用)
server
        {
                listen 80;
                #listen [::]:80;
                server_name oc2.domain.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root  /home/wwwroot/oc2.domain.com;

                include other.conf;
                #error_page   404   /404.html;
                location ~ [^/]\.php(/|$)
                        {
                                # comment try_files $uri =404; to enable pathinfo
                                try_files $uri =404;
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fastcgi.conf;
                                #include pathinfo.conf;
                        }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                access_log  /home/wwwlogs/oc2.domain.com.log  access;
        }

#wwwroot 文件夹权限情况
[root@domain wwwroot]# ll      
total 20
drwxr-xr-x 15 root root 4096 Nov 27 10:33 zen.domain.com  # 可以访问
drwxr-xr-x  4 root root 4096 Nov 27 16:21 default #开始可以访问,后来不能访问
drwxrwxrwx  8 root root 4096 Nov 27 17:16 oc2.domain.com  #开始可以访问,后来不能访问
drwxr-xr-x 15 root root 4096 Nov 27 09:45 test.domain.com  # 可以访问
drwxr-xr-x 10 root root 4096 Nov 27 01:50 www.domain.com  # 可以访问

#oc2.domain.com 文件夹权限情况 (这是第2个vhost,原来正常访问,添加到5个vhost,重启后,就不能用)
[root@domain oc2.domain.com]# ll     
total 11036
drwxr-xr-x  6 root root     4096 Nov 18 14:32 admin
drwxr-xr-x  6 root root     4096 Oct  1 04:41 catalog
-rwxrwxrwx  1 root root     1156 Nov 18 16:07 config.php
-rw-r--r--  1 root root      197 Oct  1 04:41 crossdomain.xml
drwxrwxrwx  6 root root     4096 Oct  1 04:41 image
-rwxrwxrwx  1 root root     7230 Nov 18 22:46 index.php
drwxr-xr-x  6 root root     4096 Oct  1 04:41 install
-rw-r--r--  1 root root      383 Oct  1 04:41 php.ini
drwxr-xr-x 11 root root     4096 Oct  1 04:41 system
-rw-r--r--  1 root root 11160964 Nov 18 14:32 upload.zip
drwxrwxrwx  6 root root     4096 Nov 18 22:47 vqmod
-rwxrwxrwx  1 root root    15456 Nov 18 22:39 vqmod-2.5.1-opencart.zip
-rw-r--r--  1 root root    56756 Jan  2  2013 pz.php

#default 文件夹权限情况 (原来正常访问,添加到5个vhost,重启后,就不能用)
[root@domain default]# ll
total 52
-rw-r--r-- 1 root root 42855 Nov 10 22:06 index.php
drwxr-xr-x 6 root root  4096 Jun 18  2013 xcache
drwxr-xr-x 3 root root  4096 Nov 18 15:48 xx

[ 本帖最后由 xdop 于 2014-11-27 21:00 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2014-11-27 20:58:40 | 显示全部楼层



# nginx.conf

user  www www;

worker_processes auto;

error_log  /home/wwwlogs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
        {
                use epoll;
                worker_connections 51200;
                multi_accept on;
        }

http
        {
                include       mime.types;
                default_type  application/octet-stream;

                server_names_hash_bucket_size 128;
                client_header_buffer_size 32k;
                large_client_header_buffers 4 32k;
                client_max_body_size 50m;

                sendfile on;
                tcp_nopush     on;

                keepalive_timeout 60;

                tcp_nodelay on;

                fastcgi_connect_timeout 300;
                fastcgi_send_timeout 300;
                fastcgi_read_timeout 300;
                fastcgi_buffer_size 64k;
                fastcgi_buffers 4 64k;
                fastcgi_busy_buffers_size 128k;
                fastcgi_temp_file_write_size 256k;

                gzip on;
                gzip_min_length  1k;
                gzip_buffers     4 16k;
                gzip_http_version 1.0;
                gzip_comp_level 2;
                gzip_types       text/plain application/x-javascript text/css application/xml;
                gzip_vary on;
                gzip_proxied        expired no-cache no-store private auth;
                gzip_disable        "MSIE [1-6]\.";

                #limit_conn_zone $binary_remote_addr zone=perip:10m;
                ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

                server_tokens off;
                #log format
                log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';

server
        {
                listen 80 default;
                #listen [::]:80 default ipv6only=on;
                server_name tz.domain.com;
                index index.html index.htm index.php;
                root  /home/wwwroot/default;

                #error_page   404   /404.html;
                location ~ [^/]\.php(/|$)
                        {
                                # comment try_files $uri =404; to enable pathinfo
                                try_files $uri =404;
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fastcgi.conf;
                                #include pathinfo.conf;
                        }

                location /nginx_status {
                        stub_status on;
                        access_log   off;
                }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                access_log  /home/wwwlogs/access.log  access;
        }
include vhost/*.conf;
}
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2014-11-28 12:52:41 | 显示全部楼层

配置文件上没问题,将目录属主改成www
前面你访问的tz.php,目录下也没tz.php

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2014-11-28 13:40:31 | 显示全部楼层

原帖由 licess 于 2014-11-28 12:52 发表
配置文件上没问题,将目录属主改成www
前面你访问的tz.php,目录下也没tz.php



default 目录下访问不了后,就将tz.php改成了index.php
 楼主| 发表于 2014-11-28 15:42:52 | 显示全部楼层

问题找到,原来安装xcache后,在php.ini里边添加xcache的配置时,漏掉了下面两个配置,补充后,重启php-fpm,问题解决。
谢谢军哥。

[HOST=oc2.domain.com]
open_basedir=/home/wwwroot/oc2.domain.com/:/tmp/
[PATH=/home/wwwroot/oc2.domain.com]
open_basedir=/home/wwwroot/oc2.domain.com/:/tmp/

[HOST=tz.domain.com]
open_basedir=/home/wwwroot/default/:/tmp/
[PATH=/home/wwwroot/default]
open_basedir=/home/wwwroot/default/:/tmp/
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-4-19 16:43 , Processed in 0.028335 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表