VPS侦探论坛

 找回密码
 注册
查看: 7299|回复: 4

绑定的域名默认转到服务器根目录下/home/wwwroot/

[复制链接]
发表于 2012-2-28 16:10:20 | 显示全部楼层 |阅读模式

cat /usr/local/nginx/conf/nginx.conf
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwlogs/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 50m;

  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 default;
  42.                 server_name 76.163.25.39;
  43.                 index index.html index.htm index.php;
  44.                 root  /home/wwwroot/;

  45.                 location / {
  46.                         try_files $uri @apache;
  47.                         }

  48.                 location @apache {
  49.                         internal;
  50.                         proxy_pass http://127.0.0.1:88;
  51.                         include proxy.conf;
  52.                         }

  53.                 location ~ .*\.(php|php5)?$
  54.                         {
  55.                                 proxy_pass http://127.0.0.1:88;
  56.                                 include proxy.conf;
  57.                         }

  58.                 location /status {
  59.                         stub_status on;
  60.                         access_log   off;
  61.                 }

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

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

  70.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  71.              '$status $body_bytes_sent "$http_referer" '
  72.              '"$http_user_agent" $http_x_forwarded_for';
  73.                 access_log  /home/wwwlogs/access.log  access;
  74.         }
  75. include vhost/*.conf;
  76. }
复制代码




情况如下:
最开始安装lnmpa时添加了一个域名叫www.mininginbrazil.com,这个网站目录就在/home/wwwroot/下,现在我想把它的目录改为/home/wwwroot/mininginbrazil.com
上面是我更改后的配置,然后我再添加/root/vhost.sh 添加域名mininginbrazil.com,结果,在浏览器打开http://www.mininginbrazil.com 结果是我根目录下的的文件(/home/wwwroot/)。静态文件倒是显示的是/home/wwwroot/mininginbrazil.com/下的
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-2-28 16:10:52 | 显示全部楼层

这是apache的配置文件



cat /usr/local/apache/conf/httpd.conf
  1. # ErrorLog: The location of the error log file.
  2. # If you do not specify an ErrorLog directive within a <VirtualHost>
  3. # container, error messages relating to that virtual host will be
  4. # logged here.  If you *do* define an error logfile for a <VirtualHost>
  5. # container, that host's errors will be logged there and not here.
  6. #
  7. ErrorLog "logs/error_log"
  8. #
  9. # LogLevel: Control the number of messages logged to the error_log.
  10. # Possible values include: debug, info, notice, warn, error, crit,
  11. # alert, emerg.
  12. #
  13. LogLevel warn
  14. <IfModule log_config_module>
  15.     #
  16.     # The following directives define some format nicknames for use with
  17.     # a CustomLog directive (see below).
  18.     #
  19.     LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
  20.     LogFormat "%h %l %u %t "%r" %>s %b" common
  21.     <IfModule logio_module>
  22.       # You need to enable mod_logio.c to use %I and %O
  23.       LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio
  24.     </IfModule>
  25.     #
  26.     # The location and format of the access logfile (Common Logfile Format).
  27.     # If you do not define any access logfiles within a <VirtualHost>
  28.     # container, they will be logged here.  Contrariwise, if you *do*
  29.     # define per-<VirtualHost> access logfiles, transactions will be
  30.     # logged therein and *not* in this file.
  31.     #
  32.     CustomLog "logs/access_log" common
  33.     #
  34.     # If you prefer a logfile with access, agent, and referer information
  35.     # (Combined Logfile Format) you can use the following directive.
  36.     #
  37.     #CustomLog "logs/access_log" combined
  38. </IfModule>
  39. <IfModule alias_module>
  40.     #
  41.     # Redirect: Allows you to tell clients about documents that used to
  42.     # exist in your server's namespace, but do not anymore. The client
  43.     # will make a new request for the document at its new location.
  44.     # Example:
  45.     # Redirect permanent /foo http://www.example.com/bar
  46.     #
  47.     # Alias: Maps web paths into filesystem paths and is used to
  48.     # access content that does not live under the DocumentRoot.
  49.     # Example:
  50.     # Alias /webpath /full/filesystem/path
  51.     #
  52.     # If you include a trailing / on /webpath then the server will
  53.     # require it to be present in the URL.  You will also likely
  54.     # need to provide a <Directory> section to allow access to
  55.     # the filesystem path.
  56.     #
  57.     # ScriptAlias: This controls which directories contain server scripts.
  58.     # ScriptAliases are essentially the same as Aliases, except that
  59.     # documents in the target directory are treated as applications and
  60.     # run by the server when requested rather than as documents sent to the
  61.     # client.  The same rules about trailing "/" apply to ScriptAlias
  62.     # directives as to Alias.
  63.     #
  64.     ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
  65. </IfModule>
  66. <IfModule cgid_module>
  67.     #
  68.     # ScriptSock: On threaded servers, designate the path to the UNIX
  69.     # socket used to communicate with the CGI daemon of mod_cgid.
  70.     #
  71.     #Scriptsock logs/cgisock
  72. </IfModule>
  73. #
  74. # "/usr/local/apache/cgi-bin" should be changed to whatever your ScriptAliased
  75. # CGI directory exists, if you have that configured.
  76. #
  77. <Directory "/usr/local/apache/cgi-bin">
  78.     AllowOverride None
  79.     Options None
  80.     Order allow,deny
  81.     Allow from all
  82. </Directory>
  83. #
  84. # DefaultType: the default MIME type the server will use for a document
  85. # if it cannot otherwise determine one, such as from filename extensions.
  86. # If your server contains mostly text or HTML documents, "text/plain" is
  87. # a good value.  If most of your content is binary, such as applications
  88. # or images, you may want to use "application/octet-stream" instead to
  89. # keep browsers from trying to display binary files as though they are
  90. # text.
  91. #
  92. DefaultType text/plain
  93. RewriteEngine on
  94. AddType text/html .shtml
  95. AddHandler cgi-script .cgi .pl .plx .ppl .perl
  96. AddHandler server-parsed .shtml
  97. <IfModule mime_module>
  98.     #
  99.     # TypesConfig points to the file containing the list of mappings from
  100.     # filename extension to MIME-type.
  101.     #
  102.     TypesConfig conf/mime.types
  103.     #
  104.     # AddType allows you to add to or override the MIME configuration
  105.     # file specified in TypesConfig for specific file types.
  106.     #
  107.     #AddType application/x-gzip .tgz
  108.     #
  109.     # AddEncoding allows you to have certain browsers uncompress
  110.     # information on the fly. Note: Not all browsers support this.
  111.     #
  112.     #AddEncoding x-compress .Z
  113.     #AddEncoding x-gzip .gz .tgz
  114.     #
  115.     # If the AddEncoding directives above are commented-out, then you
  116.     # probably should define those extensions to indicate media types:
  117.     #
  118.     AddType application/x-compress .Z
  119.     AddType application/x-gzip .gz .tgz
  120.     #
  121.     # AddHandler allows you to map certain file extensions to "handlers":
  122.     # actions unrelated to filetype. These can be either built into the server
  123.     # or added with the Action directive (see below)
  124.     #
  125.     # To use CGI scripts outside of ScriptAliased directories:
  126.     # (You will also need to add "ExecCGI" to the "Options" directive.)
  127.     #
  128.     #AddHandler cgi-script .cgi
  129.     # For type maps (negotiated resources):
  130.     #AddHandler type-map var
  131.     #
  132.     # Filters allow you to process content before it is sent to the client.
  133.     #
  134.     # To parse .shtml files for server-side includes (SSI):
  135.     # (You will also need to add "Includes" to the "Options" directive.)
  136.     #
  137.     #AddType text/html .shtml
  138.     #AddOutputFilter INCLUDES .shtml
  139.     AddType application/perl .pl .plx .ppl .perl
  140.     AddType application/x-img .img
  141.     AddType application/x-httpd-php .php .php3 .php4 .php5 .php6
  142.     AddType application/x-httpd-php-source .phps
  143.     AddType application/cgi .cgi
  144.     AddType text/x-sql .sql
  145.     AddType text/x-log .log
  146.     AddType text/x-config .cnf conf
  147.     AddType text/x-registry .reg
  148.     AddType text/html .shtml
  149.     AddType application/x-tar .tgz
  150.     AddType application/rar .rar
  151.     AddType application/x-compressed .rar
  152.     AddType application/x-rar .rar
  153.     AddType application/x-rar-compressed .rar
  154.     AddType text/vnd.wap.wml .wml
  155. </IfModule>
  156. #
  157. # The mod_mime_magic module allows the server to use various hints from the
  158. # contents of the file itself to determine its type.  The MIMEMagicFile
  159. # directive tells the module where the hint definitions are located.
  160. #
  161. #MIMEMagicFile conf/magic
  162. #
  163. # Customizable error responses come in three flavors:
  164. # 1) plain text 2) local redirects 3) external redirects
  165. #
  166. # Some examples:
  167. #ErrorDocument 500 "The server made a boo boo."
  168. #ErrorDocument 404 /missing.html
  169. #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
  170. #ErrorDocument 402 http://www.example.com/subscription_info.html
  171. #
  172. #
  173. # EnableMMAP and EnableSendfile: On systems that support it,
  174. # memory-mapping or the sendfile syscall is used to deliver
  175. # files.  This usually improves server performance, but must
  176. # be turned off when serving from networked-mounted
  177. # filesystems or if support for these functions is otherwise
  178. # broken on your system.
  179. #
  180. #EnableMMAP off
  181. #EnableSendfile off
  182. # LoadModule perl_module modules/mod_perl.so
  183. LoadModule php5_module        modules/libphp5.so
  184. Include conf/extra/rpaf.conf

  185. # Supplemental configuration
  186. #
  187. # The configuration files in the conf/extra/ directory can be
  188. # included to add extra features or to modify the default configuration of
  189. # the server, or you may simply copy their contents here and change as
  190. # necessary.
  191. # Server-pool management (MPM specific)
  192. Include conf/extra/httpd-mpm.conf
  193. # Multi-language error messages
  194. Include conf/extra/httpd-multilang-errordoc.conf
  195. # Fancy directory listings
  196. Include conf/extra/httpd-autoindex.conf
  197. # Language settings
  198. Include conf/extra/httpd-languages.conf
  199. # User home directories
  200. #Include conf/extra/httpd-userdir.conf
  201. # Real-time info on requests and configuration
  202. Include conf/extra/httpd-info.conf
  203. # Virtual hosts
  204. Include conf/extra/httpd-vhosts.conf
  205. # Local access to the Apache HTTP Server Manual
  206. #Include conf/extra/httpd-manual.conf
  207. # Distributed authoring and versioning (WebDAV)
  208. #Include conf/extra/httpd-dav.conf
  209. # Various default settings
  210. Include conf/extra/httpd-default.conf
  211. # Secure (SSL/TLS) connections
  212. #Include conf/extra/httpd-ssl.conf
  213. #
  214. # Note: The following must must be present to support
  215. #       starting without SSL on platforms with no /dev/random equivalent
  216. #       but a statically compiled-in mod_ssl.
  217. #

  218. Include conf/vhost/*.conf
  219. Include conf/vhost/*.conf
复制代码

[ 本帖最后由 sbmzhcn 于 2012-2-28 16:15 编辑 ]
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2012-2-28 16:19:18 | 显示全部楼层

上面显示不全,我就改了这个。


#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName 76.163.25.39:88
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/home/wwwroot/"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-2-28 17:11:31 | 显示全部楼层



目前 的情况是、: mininginbrazil.com可以到/home/wwwroot/miniginbrazil.com下
但是www.mininginbrazil.com仍然只能到/home/wwwroot/很奇怪啊!
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-2-28 18:33:23 | 显示全部楼层

/usr/local/apache/conf/extra/httpd-vhosts.conf 没改吧,改后重启生效
而且www.mininginbrazil.com 这个也得绑定在你的虚拟主机里才行,不帮肯定是到/home/wwwroot/

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

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-16 21:52 , Processed in 0.026701 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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