VPS侦探论坛

 找回密码
 注册
查看: 8260|回复: 7

【已解决-结帖】军哥帮忙:LNMP0.8绑定多域名多站点不稳定

[复制链接]
发表于 2012-1-2 23:08:50 | 显示全部楼层 |阅读模式

安装了LNMP0.8,并按教程配置了多站点

域名分别绑定到不同的目录,想要实现VPS上 单IP 多域名 多站点

域名一 www.a.com 绑定目录 /home/wwwroot/a
域名二 www.b.com 绑定目录 /home/wwwroot/b


错误现象:时常会出现打开俩域名后,发现内容串了,比如域名一打开后显示了域名二的内容之类的,要么就是域名一正常,域名二却显示 LNMP安装成功的页面,而我已经将 /home/wwwroot/ 目录下的 Index.html 文件删除了(此文件为LNMP安装成功页面)

俩域名正常的情况也有,但时常会出现串内容或访问结果为LNMP成功页面!!

自己处理过程:
1、 /usr/local/nginx/sbin/nginx -t 结果显示正常
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful

2、/root/lnmp restart 或 reboot 结果也正常
nginx、php、mysql等都正常启动!






域名一:/usr/local/nginx/conf/vhost/a.conf
server
    {
        listen       80;
        server_name www.a.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/a;

        include none.conf;
        location ~ .*\.(php|php5)?$
            {
                fastcgi_pass  unix:/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;
    }


域名二:/usr/local/nginx/conf/vhost/b.conf
server
    {
        listen       80;
        server_name www.b.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/b;

        include none.conf;
        location ~ .*\.(php|php5)?$
            {
                fastcgi_pass  unix:/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;
    }


/usr/local/nginx/conf/nginx.conf的内容如下:

user  www www;

worker_processes 1;

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

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;

        #limit_zone  crawler  $binary_remote_addr  10m;

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

        location ~ .*\.(php|php5)?$
            {
                fastcgi_pass  unix:/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_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
        access_log  /home/wwwlogs/access.log  access;
    }
include vhost/*.conf;
}


注:vps 为单IP

[ 本帖最后由 haibor 于 2012-1-3 22:07 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-1-3 17:20:09 | 显示全部楼层


有了解的木,给点解决意见呗
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-1-3 20:36:04 | 显示全部楼层

多域名多站点都不行,还玩个屁啊。楼主贴个球代码,自己用vhost.sh添加网站,不行就见鬼了
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-1-3 22:05:57 | 显示全部楼层



已解决!原因不在VPS配置!真扯蛋!

结帖!!!
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-1-31 04:46:24 | 显示全部楼层

原帖由 haibor 于 2012-1-3 22:05 发表
已解决!原因不在VPS配置!真扯蛋!

结帖!!!
是什么问题 我也出现这样的问题

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

发表于 2012-1-31 18:54:10 | 显示全部楼层

这个正确,但是我刚换了lnmpa,多域名就有些问题
发表于 2012-2-1 08:13:45 | 显示全部楼层

在安装的时候,主目录,也就是/home/wwwroot 也需要放在一个vhost的配置文件中,这样就没问题了。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-2-24 14:08:09 | 显示全部楼层

这样啊,晕得很啊。。我也是这个情况。。我去试试。。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-22 10:06 , Processed in 0.027248 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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