ubuntu server 10.04 apache2配置多个虚拟主机

1.在/etc/apache2/site-available/中增加配置文件文件,可以将default拷贝后修改,如blogs:

<VirtualHost *自定义端口>
# 在ServerName后加上你的网站名称
ServerName www.linyupark.com
# 如果你想多个网站名称都取得相同的网站,可以加在ServerAlias后加上其他网站别名。
# 别名间以空格隔开。
ServerAlias ftp.linyupark.com mail.linyupark.com
# 在ServerAdmin后加上网站管理员的电邮地址,方便别人有问题是可以联络网站管理员。
ServerAdmin webmaster@linyupark.com
# 在DocumentRoot后加上存放网站内容的目录路径(用户的个人目录)
DocumentRoot /home/rong/public_html
<Directory /home/rong/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
ErrorLog /home/rong/public_html/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/rong/public_html/access.log combined
</VirtualHost>

2.在/etc/apache2/sites-enabled/中增加一个链接,使用命令 :ln -s /etc/apache2/sites-available/blogs /etc/apache2/sites-enabled/blogs

3在/etc/apache2/ports.conf中增加侦听端口和NameVirtualHost:

NameVirtualHost *:81

Listen 81

4. 重启apache2:sudo /etc/init.d/apache2 restart


原文地址:https://www.cnblogs.com/ylan2009/p/2370324.html