/ 中存储网

配置Apache2建立多个虚拟主机网站

2013-09-22 10:39:01 来源:ITJS.CN
系统:Ubuntu 10.10

Apache:2.2.16

###################################################################

修改 /etc/apache2/httpd.conf 为:

ServerName 127.0.0.1

<VirtualHost *:80>

ServerAdmin [email protected]

DocumentRoot /var/www

ServerName localhost

ErrorLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/error-80-%Y-%m-%d.log 86400"

CustomLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/access-80-%Y-%m-%d.log 86400" combined

</VirtualHost>

<VirtualHost *:6666>

ServerAdmin [email protected]

DocumentRoot /var/www/zuitu

ServerName 127.0.0.1

ErrorLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/error-6666-%Y-%m-%d.log 86400"

CustomLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/access-6666-%Y-%m-%d.log 86400" combined

</VirtualHost>

<VirtualHost *:7777>

ServerAdmin [email protected]

DocumentRoot /var/www/tiantian

ServerName 127.0.0.1

ErrorLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/error-7777-%Y-%m-%d.log 86400"

CustomLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/access-7777-%Y-%m-%d.log 86400" combined

</VirtualHost>

********************************************************************************

###################################################################

修改/etc/apache2/ports.conf 为:

NameVirtualHost *:80

Listen 80

NameVirtualHost *:6666

Listen 6666

NameVirtualHost *:7777

Listen 7777

********************************************************************************

###################################################################

把 /etc/apache2/sites-available/default 复制为default2 和 default3 并修改对应的端口及网站文件路径:

default3内容,粗体部分是需要改动的。log日志文件我改为每天一个,避免过大:

<VirtualHost *:7777>

ServerAdmin [email protected]

DocumentRoot /var/www/tiantian

<Directory />

Options FollowSymLinks

AllowOverride None

</Directory>

<Directory /var/www/tiantian/>

Options Indexes FollowSymLinks MultiViews

AllowOverride None

Order allow,deny

allow from all

</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">

AllowOverride None

Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

Order allow,deny

Allow from all

</Directory>

ErrorLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/error-7777-%Y-%m-%d.log 86400"

# Possible values include: debug, info, notice, warn, error, crit,

# alert, emerg.

LogLevel warn

CustomLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/access-7777-%Y-%m-%d.log 86400" combined

Alias /doc/ "/usr/share/doc/"

<Directory "/usr/share/doc/">

Options Indexes MultiViews FollowSymLinks

AllowOverride None

Order deny,allow

Deny from all

Allow from 127.0.0.0/255.0.0.0 ::1/128

</Directory>

</VirtualHost>

###################################################################

保存后重启apache服务:

sudo /etc/init.d/apache2 restart