VPS侦探论坛

 找回密码
 注册
查看: 3797|回复: 1

关于lnmp1.2 配置多个域名访问单个IP多个站点的问题

[复制链接]
发表于 2015-12-17 16:57:43 | 显示全部楼层 |阅读模式

配置文件都做好了,不知道哪里出现问题,aaa.com,bbb.com都已经指定A记录到了服务器。建立了两个网站目录,
aaa.com 对应 /home/wwwroot/default     vhost目录下面建立了 aaa.com.conf
bbb.com 对应 /home/wwwroot/bbs          vhost目录下面建立了 bbb.com.conf
但是不管访问那个IP 都指向 /home/wwwroot/default 这个目录下面的站点。


下面是nginx.comf的配置代码:
  1. user  www www;

  2. worker_processes auto;

  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.         multi_accept on;
  12.     }

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

  17.         server_names_hash_bucket_size 128;
  18.         client_header_buffer_size 32k;
  19.         large_client_header_buffers 4 32k;
  20.         client_max_body_size 50m;

  21.         sendfile   on;
  22.         tcp_nopush on;

  23.         keepalive_timeout 60;

  24.         tcp_nodelay on;

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

  32.         gzip on;
  33.         gzip_min_length  1k;
  34.         gzip_buffers     4 16k;
  35.         gzip_http_version 1.1;
  36.         gzip_comp_level 2;
  37.         gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
  38.         gzip_vary on;
  39.         gzip_proxied   expired no-cache no-store private auth;
  40.         gzip_disable   "MSIE [1-6]\.";

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

  43.         server_tokens off;
  44.         #log format
  45.         log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  46.                 '$status $body_bytes_sent "$http_referer" '
  47.                 '"$http_user_agent" $http_x_forwarded_for';
  48.                 access_log off;

  49. include /usr/local/nginx/conf/vhost/*.conf;
  50. }
复制代码



下面是aaa.com.conf的配置文件:
  1. server
  2.     {
  3.         listen 8080;
  4.         #listen [::]:80;
  5.         server_name aaa.com;
  6.         root  /home/wwwroot/default;
  7.         index index.html index.htm index.php default.html default.htm default.php;

  8.         #error_page   404   /404.html;
  9.         location ~ [^/]\.php(/|$)
  10.         {
  11.             # comment try_files $uri =404; to enable pathinfo
  12.             try_files $uri =404;
  13.             fastcgi_pass  unix:/tmp/php-cgi.sock;
  14.             fastcgi_index index.php;
  15.             include fastcgi.conf;
  16.             #include pathinfo.conf;
  17.         }

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

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

  26.         access_log  /home/wwwlogs/access.log  access;
  27. }
复制代码




下面是bbb.com.conf的配置文件:
  1. server
  2.     {
  3.         listen 80;
  4.         #listen [::]:80;
  5.         server_name bbb.com;
  6.         index index.html index.htm index.php default.html default.htm default.php;
  7.         root  /home/wwwroot/bbs;

  8.         #error_page   404   /404.html;
  9.         location ~ [^/]\.php(/|$)
  10.         {
  11.             # comment try_files $uri =404; to enable pathinfo
  12.             try_files $uri =404;
  13.             fastcgi_pass  unix:/tmp/php-cgi.sock;
  14.             fastcgi_index index.php;
  15.             include fastcgi.conf;
  16.             #include pathinfo.conf;
  17.         }

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

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

  26.         access_log off;
  27.     }
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2015-12-17 20:08:16 | 显示全部楼层

回复 1# 的帖子



aaa.com 是8080端口
bbb.com是80端口
你这个只有一个80端口上的虚拟主机怎么可能直接访问域名访问到一个只有8080端口的虚拟主机

只有一种可能你修改完原始配置后没有重启nginx,只要解析过去的都会到default默认虚拟主机上
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-28 15:26 , Processed in 0.028823 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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