标签:apache
博主热衷各种互联网技术,常啰嗦,时常伴有强迫症,常更新,觉得文章对你有帮助的可以关注我。 转载请注明"深蓝的镰刀"
假设你的网站的ip是12.34.56.78,你想实现输入12.34.56.78:81后访问 "/yourpath/www81"目录下的网站,而输入12.34.56.78:82后访问 "/yourpath/www82"目录下的网站。
首先确保端口没有被其他进程占用,如果是的关掉该进程,并且设置开机启动不启用该进程。
首先找到你的Apache配置文件httpd.conf,找到“Listen 80”这句,如果没有,在ServerRoot "..." 这句后加上"Listen 80",随后添加上你需要监听的端口(80端口一般是默认端口,即你输入12.34.56.78和12.34.56.78:80是一样的效果)
ServerRoot "/yourpath/server/httpd" Listen 80 Listen 82 Listen 84
NameVirtualHost *:80 Include /yourpath/server/httpd/conf/vhosts/80.conf NameVirtualHost *:81 Include /yourpath/server/httpd/conf/vhosts/81.conf NameVirtualHost *:82 Include /yourpath/server/httpd/conf/vhosts/82.conf
ServerRoot "/yourpath/server/httpd" Listen 80 Listen 82 Listen 84 Include /yourpath/server/httpd/my-httpd-vhosts.conf
/yourpath/server/httpd/conf/vhosts/80.conf
/yourpath/server/httpd/conf/vhosts/81.conf
/yourpath/server/httpd/conf/vhosts/82.conf
并进行如下配置(根据端口不同将相应的数字改变)
<VirtualHost *:82> DocumentRoot /yourpath/www82 ServerName localhost ServerAlias localhost ErrorLog "/yourpath/server/httpd/log/default-error-82.log" CustomLog "/yourpath/server/httpd/log/default-82.log" common </VirtualHost>
如果apache启动不了,请查看是否有拼写错误,或者直接查看apache错误日志。
标签:apache
原文地址:http://blog.csdn.net/hornedreaper1988/article/details/43833607