VPS里面nginx无法配置多域名怎么办?

Linux VPS 支持
回复
头像
hackerzc
帖子: 51
注册时间: 2007-11-11 14:16

VPS里面nginx无法配置多域名怎么办?

#1

帖子 hackerzc » 2015-07-04 9:17

我是按照 Vps-Ubuntu中文 这里的方法来搭建服务器的,
因为配置不高(5G硬盘、512M内存),所以打算使用Nginx来搭建服务器而非Apache。
按照教程一步步做下来都挺顺利的,但是我想配置多域名到另外一个文件夹的时候,
每次把写好的文件放入“/etc/nginx/sites-enabled/”文件夹后,用

代码: 全选

service nginx restart
来重启Nginx服务都提示失败(Fail)
重启失败
重启失败
QQ截图20150704103748.png (2.44 KiB) 查看 11312 次
并且多域名也没有配置成功。
去掉其他的配置文件之后才能重启Nginx成功。
QQ截图20150704103951.png
QQ截图20150704103951.png (8.71 KiB) 查看 11312 次
想问问这个问题大家是怎么处理的,还是说我的哪些设置上可能有问题?

跪求大神解答,先谢谢了~

=-=-=-=-=-=-=-=-=
这里是sites-enabled文件夹下default的设置

代码: 全选

server {
	listen 80 default_server;
	listen [::]:80 default_server ipv6only=on;

	root /var/www;
	index index.html index.htm index.php;

	server_name *.*.*.*(主机所在IP地址);

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
		# Uncomment to enable naxsi on this location
		# include /etc/nginx/naxsi.rules
        if (!-e $request_filename)
        {
                rewrite ^/(.+)$ /index.php last;
        }
	}
	
	location ~ \.php$ {
		include /etc/nginx/fastcgi_params;
		fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
		fastcgi_pass  127.0.0.1:9000;
		}
}
下面是另外一个域名的配置

代码: 全选

server	{
	listen       80;
	server_name *.xxx.com;
	index index.html index.htm index.php;
	root  /var/www/*/;
	location ~ \.php$ {
		include /etc/nginx/fastcgi_params;
		fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
		fastcgi_pass  127.0.0.1:9000;
		}
	}
大家帮忙看看是不是我这里配置有冲突还是有什么问题,先谢谢了~
Ubuntu开创开源新纪元
Ubuntu很好很强大,Wine很帅很牛X!
回复