VPS侦探论坛

 找回密码
 注册
查看: 26022|回复: 18

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

[复制链接]
发表于 2010-8-4 16:35:31 | 显示全部楼层 |阅读模式

主域名为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文件 路径应该都没错阿。。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2010-8-4 17:44:03 | 显示全部楼层

回复 1# 的帖子



别猜了,贴配置文件吧。
/usr/local/nginx/conf/nginx.conf 和/usr/local/nginx/conf/vhost/ 下面域名.conf 的文件。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2010-8-4 20:55:07 | 显示全部楼层

实际的域名我作了替换

nginx.conf
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwroot/logs/nginx_error.log  crit;

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

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

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 8m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39. server
  40.         {
  41.                 listen       80;
  42.                 server_name abc.com;
  43.                 index index.html index.htm index.php;
  44.                 root  /home/wwwroot;

  45.                 location ~ .*\.(php|php5)?$
  46.                         {
  47.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  48.                                 fastcgi_index index.php;
  49.                                 include fcgi.conf;
  50.                         }

  51.                 location /status {
  52.                         stub_status on;
  53.                         access_log   off;
  54.                 }

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

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

  63.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  64.              '$status $body_bytes_sent "$http_referer" '
  65.              '"$http_user_agent" $http_x_forwarded_for';
  66.                 access_log  /home/wwwroot/logs/access.log  access;
  67.         }
  68. include vhost/*.conf;
  69. }
复制代码
xxx.abc.com.conf
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name xxx.abc.com;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/xxx.abc.com;

  7.                 include none.conf;
  8.                 location ~ .*\.(php|php5)?$
  9.                         {
  10.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  11.                                 fastcgi_index index.php;
  12.                                 include fcgi.conf;
  13.                         }

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

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

  22.                 access_log off;
  23.         }
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2010-8-4 21:01:33 | 显示全部楼层



下面这个  一开始是root xxx.abc.com;  后来我改成 root  /home/wwwroot/xxx.abc.com;  还是不行。。
nginx刚接触,都不是很明白~
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2010-8-5 10:24:45 | 显示全部楼层

回复 4# 的帖子


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

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

 楼主| 发表于 2010-8-5 10:32:13 | 显示全部楼层

回复 5# 的帖子


=.=  肯定重启阿...
重启了好几次了都这样。。
我也怀疑到底有没真正的重启
感觉怎么改都跟没改一样
发表于 2010-8-5 10:40:55 | 显示全部楼层

回复 6# 的帖子


配置是没有问题,发重启时候的信息。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2010-8-5 10:41:32 | 显示全部楼层

又加了个试试
感觉虚拟主机跟没加一样。。。。
访问的还是wwwroot   
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2010-8-5 10:45:13 | 显示全部楼层


  1. [root@localhost lnmp0.4-full]# ./vhost.sh

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

  8. =========================================================================
  9. Please input domain:
  10. (Default domain: www.lnmp.org):pp.abc.com
  11. ===========================
  12. domain=pp.abc.com
  13. ===========================
  14. Do you want to add more domain name? (y/n)
  15. n
  16. Please input the directory for the domain:pp.abc.com :
  17. (Default directory: /home/wwwroot/pp.abc.com):
  18. ===========================
  19. Virtual Host Directory=/home/wwwroot/pp.abc.com
  20. ===========================
  21. ===========================
  22. Allow Rewrite rule? (y/n)
  23. ===========================
  24. n
  25. ===========================
  26. You choose rewrite=none
  27. ===========================
  28. ===========================
  29. Allow access_log? (y/n)
  30. ===========================
  31. n
  32. ===========================
  33. You access log file=.log
  34. ===========================

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

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

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

  50. =========================================================================
  51. You have new mail in /var/mail/root
  52. [root@localhost lnmp0.4-full]# ./lnmp restart
  53. =========================================================================
  54. Manager for LNMP V0.4  ,  Written by Licess
  55. =========================================================================
  56. LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux
  57. This script is a tool to Manage status of lnmp
  58. For more information please visit http://www.lnmp.org

  59. Usage: /root/lnmp {start|stop|reload|restart|kill|status}
  60. =========================================================================
  61. Reload LNMP...
  62. Reload Nginx configure...
  63. the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  64. configuration file /usr/local/nginx/conf/nginx.conf test is successful
  65. kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
  66. Nginx program is reloding!
  67. Shutting down MySQL.                                       [确定]
  68. Starting MySQL.                                            [确定]
  69. Shutting down php_fpm . done
  70. Starting php_fpm  done
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2010-8-5 13:33:42 | 显示全部楼层



楼主试试重启vps
我开始和楼主一样 重启一次vps就好了
 楼主| 发表于 2010-8-5 13:44:40 | 显示全部楼层

回复 10# 的帖子


恩。。我机器重启下试试
没用VPS 直接就是刚装上centos5.5的服务器
发表于 2010-8-5 13:57:53 | 显示全部楼层

原帖由 ql2005 于 2010-8-5 13:44 发表
恩。。我机器重启下试试
没用VPS 直接就是刚装上centos5.5的服务器

很好很强大~
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2010-8-5 14:45:49 | 显示全部楼层
果然重启可以了。。。吐血
那就是说  ./lnmp restart 没有重启nginx?
要是以后加一个虚拟主机就要重启整台服务器一次。。。。 会死人的。。

[ 本帖最后由 ql2005 于 2010-8-5 14:48 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2010-8-5 16:19:12 | 显示全部楼层
/usr/local/nginx/sbin/nginx -s reload  貌似这样可以平滑重启nginx配置

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

发表于 2010-8-5 16:36:06 | 显示全部楼层

回复 13# 的帖子

/root//lnmp restart 这个测试过,没有问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-8 07:25 , Processed in 0.041214 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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