NameVirtualHost 192.168.1.231:80
<VirtualHost 192.168.1.231:80>
ServerName
www.a.com ServerName
www.b.com DocumentRoot "/usr/local/apache/www1"
Alias /cs "/usr/local/apache/htdocs/phpmyadmin/"
<directory "/usr/local/apache/www1">
allow from all
</directory>
DirectoryIndex index.php
</VirtualHost>
<VirtualHost 192.168.1.231:80>
ServerName
www.c.com DocumentRoot "/usr/local/apache/htdocs"
<directory "/usr/local/apache/htdocs">
allow from all
</directory>
DirectoryIndex index.html index.php
</VirtualHost>
#Alias /cs "/usr/local/apache/htdocs/phpmyadmin/"这个表示建立虚拟目录为cs,指向地点为phpmyadmin目录
完整配置实例一:
<VirtualHost *:81>
<Directory /www/www.a.com/www/htdocs>
Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
DocumentRoot /www/www.a.com/www/htdocs
ServerName www.a.com
ErrorLog /www/www.a.com/logs/error_log
CustomLog "|/usr/local/cronolog/sbin/cronolog /www/www.a.com/logs/access_log.%Y%m%d" combined
</VirtualHost>
#CustomLog "|/usr/local/cronolog/sbin/cronolog /www/www.a.com/logs/access_log.%Y%m%d" combined #这句是表示按日期写日志到目录文件里面
cronolog下载地址:
配置详细实例二:
<VirtualHost *:80>
<Directory /www/www.test.com/www/htdocs>
Options FollowSymLinks
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
ServerAdmin
swm9988@gmail.com DocumentRoot /www/www.test.com/www/htdocs
ServerName
www.test.com ErrorDocument 404 /index.php
ErrorLog /www/www.test.com/logs/error_log
CustomLog "|/usr/local/cronolog/sbin/cronolog /www/www.test.com/logs/access_log.%Y%m%d" combined
</VirtualHost>
多虚拟主机配置80端口在同一文件中的配置前要加
NameVirtualHost *:80
多虚拟主机配置80端口在多配置文件中在httpd.conf最后加
NameVirtualHost *:80
Include /usr/local/apache/conf/Includes/*.conf
再建立Includes文件夹
# mkdir /usr/local/apache/conf/Includes