ql2005 发表于 2010-8-4 16:35:31

【求助】vhost新建虚拟主机问题

主域名为abc.com   目录是默认的/home/wwwroot
用vhost新建了一个虚拟主机xx.abc.com目录是 /home/wwwroot/xx.abc.com
然后访问php文件的时候报错 No input file specified.
直接访问html文件 错误404
然后发现访问xx.abc.com/p.php 读取的是wwwroot里的p.php ...
就是说 xx.abc.com并没有访问 /home/wwwroot/xx.abc.com 这个目录,而是访问/home/wwwroot   什么原因呢。。。
看过几个conf文件 路径应该都没错阿。。

licess 发表于 2010-8-4 17:44:03

回复 1# 的帖子

别猜了,贴配置文件吧。
/usr/local/nginx/conf/nginx.conf 和/usr/local/nginx/conf/vhost/ 下面域名.conf 的文件。

ql2005 发表于 2010-8-4 20:55:07

实际的域名我作了替换

nginx.confuserwww www;

worker_processes 1;

error_log/home/wwwroot/logs/nginx_error.logcrit;

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;
        }

http
        {
                include       mime.types;
                default_typeapplication/octet-stream;

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

                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_length1k;
                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;

                #limit_zonecrawler$binary_remote_addr10m;

server
        {
                listen       80;
                server_name abc.com;
                index index.html index.htm index.php;
                root/home/wwwroot;

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_passunix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

                location /status {
                        stub_status on;
                        access_log   off;
                }

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

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

                log_formataccess'$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
                access_log/home/wwwroot/logs/access.logaccess;
        }
include vhost/*.conf;
}xxx.abc.com.confserver
        {
                listen       80;
                server_name xxx.abc.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root/home/wwwroot/xxx.abc.com;

                include none.conf;
                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_passunix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

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

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

                access_log off;
        }

ql2005 发表于 2010-8-4 21:01:33

下面这个一开始是root xxx.abc.com;后来我改成 root/home/wwwroot/xxx.abc.com;还是不行。。
nginx刚接触,都不是很明白~

licess 发表于 2010-8-5 10:24:45

回复 4# 的帖子

重启nginx没有,重启后才会生效。

ql2005 发表于 2010-8-5 10:32:13

回复 5# 的帖子

=.=肯定重启阿...
重启了好几次了都这样。。
我也怀疑到底有没真正的重启
感觉怎么改都跟没改一样

licess 发表于 2010-8-5 10:40:55

回复 6# 的帖子

配置是没有问题,发重启时候的信息。

ql2005 发表于 2010-8-5 10:41:32

又加了个试试
感觉虚拟主机跟没加一样。。。。
访问的还是wwwroot    :L

ql2005 发表于 2010-8-5 10:45:13

# ./vhost.sh

=========================================================================
Add Virtual Host for LNMP V0.4,Written by Licess
=========================================================================
LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux
This script is a tool to add virtual host for nginx
For more information please visit http://www.lnmp.org/

=========================================================================
Please input domain:
(Default domain: www.lnmp.org):pp.abc.com
===========================
domain=pp.abc.com
===========================
Do you want to add more domain name? (y/n)
n
Please input the directory for the domain:pp.abc.com :
(Default directory: /home/wwwroot/pp.abc.com):
===========================
Virtual Host Directory=/home/wwwroot/pp.abc.com
===========================
===========================
Allow Rewrite rule? (y/n)
===========================
n
===========================
You choose rewrite=none
===========================
===========================
Allow access_log? (y/n)
===========================
n
===========================
You access log file=.log
===========================

Press any key to start create virtul host...
Create Virtul Host directory......
set permissions of Virtual Host directory......
You select the exist rewrite rule:/usr/local/nginx/conf/none.conf
Test Nginx configure file......
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful

Restart Nginx......
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l
=========================================================================
Add Virtual Host for LNMP V0.4,Written by Licess
=========================================================================
For more information please visit http://www.lnmp.org/

Your domain:pp.abc.com
Directory of pp.abc.com:/home/wwwroot/pp.abc.com

=========================================================================
You have new mail in /var/mail/root
# ./lnmp restart
=========================================================================
Manager for LNMP V0.4,Written by Licess
=========================================================================
LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux
This script is a tool to Manage status of lnmp
For more information please visit http://www.lnmp.org

Usage: /root/lnmp {start|stop|reload|restart|kill|status}
=========================================================================
Reload LNMP...
Reload Nginx configure...
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l
Nginx program is reloding!
Shutting down MySQL.                                       [确定]
Starting MySQL.                                          [确定]
Shutting down php_fpm . done
Starting php_fpmdone

zjttfs 发表于 2010-8-5 13:33:42

楼主试试重启vps
我开始和楼主一样 重启一次vps就好了:)

ql2005 发表于 2010-8-5 13:44:40

回复 10# 的帖子

恩。。我机器重启下试试
没用VPS 直接就是刚装上centos5.5的服务器:lol

zjttfs 发表于 2010-8-5 13:57:53

原帖由 ql2005 于 2010-8-5 13:44 发表 https://bbs.vpser.net/images/common/back.gif
恩。。我机器重启下试试
没用VPS 直接就是刚装上centos5.5的服务器:lol
很好很强大~:lol

ql2005 发表于 2010-8-5 14:45:49

果然重启可以了。。。吐血
那就是说./lnmp restart 没有重启nginx?
要是以后加一个虚拟主机就要重启整台服务器一次。。。。 会死人的。。:Q :Q

[ 本帖最后由 ql2005 于 2010-8-5 14:48 编辑 ]

ql2005 发表于 2010-8-5 16:19:12

/usr/local/nginx/sbin/nginx -s reload貌似这样可以平滑重启nginx配置

licess 发表于 2010-8-5 16:36:06

回复 13# 的帖子

/root//lnmp restart 这个测试过,没有问题
页: [1] 2
查看完整版本: 【求助】vhost新建虚拟主机问题