1:先打开Apache目录下的配置文件httpd.conf(在conf目录下),找到#Include conf/extra/httpd-vhosts.conf这句,将之前的#号去掉,开启虚拟主机配置。
2:在conf/extra/httpd-vhosts.conf中进行虚拟主机的配置操作;也可以在httpd.conf直接写入配置,但是不建议这么做;尽量做到配置分离,解耦。在文件中添加以下示例配置:
<VirtualHost *:80>
DocumentRoot "D:/wamp/www/"
ServerName bbs.tuling.com
<Directory "D:/wamp/www/">
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
ServreName为域名名称DocumentRoot为网站目录
基于域名的虚拟主机配置
<VirtualHost *:80>
DocumentRoot /var/www/cms
ServerName
RewriteEngine On
RewriteCond %{REQUEST_METHOR} ^TRACE
RewriteRule .* - [F]
<Directory "/var/www/cms">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
ErrorLog "/var/www/log/httpd/example-com-error.log"
CustomLog "/var/www//log/httpd/example-com.log" common
</VirtualHost>
将 example.com 自动跳转到
<VirtualHost *:80>
ServerName example.com
RedirectMatch permanent ^/(.*) $1
</VirtualHost>
Ubuntu Server 14.04 安装Web服务器(Linux+Apache+MySQL+PHP)
Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置
CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12)
RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind