RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Apache和Nginx虚拟主机的创建

一、Apache

成都创新互联是一家专业从事成都网站设计、成都网站建设的网络公司。作为专业的建站公司,成都创新互联依托的技术实力、以及多年的网站运营经验,为您提供专业的成都网站建设、成都全网营销推广及网站设计开发服务!

  (1)基于访问主机头(FQDN)

cat /etc/httpd/conf.d/vhostfqdn.conf 

	documentroot /data/web01
	servername www.web01.com
	
		require all granted
	
	CustomLog "logs/a_access_log" combined



	documentroot /data/web02
	servername www.web02.com
	
		require all granted
	
	CustomLog "logs/a_access_log" combined



	documentroot /data/web03
	servername www.web03.com
	
		require all granted
	
	CustomLog "logs/a_access_log" combined

(2)基于ip地址

cat /etc/httpd/conf.d/vhostip.conf 

	documentroot /data/web01
	
		require all granted
	



	documentroot /data/web02
	
		require all granted
	



	documentroot /data/web03
	
		require all granted
	

(3)基于端口号

cat  /etc/httpd/conf.d/vhostport.conf 
listen 8001
listen 8002
listen 8003


	documentroot /data/web01
	
		require all granted
	




	documentroot /data/web02
	
     		require all granted
	



	documentroot /data/web03
	
		require all granted
	

二、Nginx

(1)基于域名且不同站点

 server {
         listen       80;
         server_name  mobile.magedu.com;
         location / {
             root   html;
             index  index.html index.htm;
         }
         location /python {
             root   /mobile;        !!!必须在/mobile目录下创建/python目录,且把文件写入python目录中,否则会报错!!!
             index  index.html index.htm;
         }
         location /java {
             root   /mobile;
             index  index.html index.htm;
         }
     }
 server {
         listen       80;
         server_name  www.magedu.com;
         location / {
             root   html;
             index  index.html index.htm;
         }
         location /python {
             root   /www;
             index  index.html index.htm;
         }
         location /java {
             root   /www;
             index  index.html index.htm;
         }
     }

分享标题:Apache和Nginx虚拟主机的创建
分享网址:http://sczitong.cn/article/joccco.html