标签:
服务器IP地址:127.0.0.1:80
绑定两个 域名 my.cms.com my.test.com
将my.cms.com绑定到/home/gaofei/Desktop/www/my_cms
将my.cms.test绑定到/home/gaofei/Desktop/www/my_test
1.
cd /etc/hosts
添加域名
127.0.0.1 my.test.com 127.0.0.1 my.cms.com
2.进入/etc/apache2/sites-enabled/ ; 删除 000-default 文件。
3.在/etc/apache2/sites-available/ 下建立两个文件 名为 my.test.com my.cms.com
在my.cms.com插入以下内容
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName my.cms.com DocumentRoot /home/gaofei/Desktop/www/my_cms <Directory /> Options FollowSymLinks DirectoryIndex index.php index.html index.htm AllowOverride None </Directory> <Directory /home/gaofei/Desktop/www/my_cms> # Options Indexes FollowSymLinks MultiViews Options FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php AllowOverride All 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 ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log 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>
在my.test.com内插入以下内容
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName my.test.com DocumentRoot /home/gaofei/Desktop/www/my_test <Directory /> Options FollowSymLinks DirectoryIndex index.php index.html index.htm AllowOverride None </Directory> <Directory /home/gaofei/Desktop/www/my_test> # Options Indexes FollowSymLinks MultiViews Options FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php AllowOverride All 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 ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log 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>
4.在 /etc/apache2/sites_enabled/ 中创建ln链接:
ln -s /etc/apache2/sites-available/my.test.com /etc/apache2/sites-enabled/my.test.com
ln -s /etc/apache2/sites-available/my.cms.com /etc/apache2/sites-enabled/my.cms.com
5.重启apache2
service apache2 restart
标签:
原文地址:http://www.cnblogs.com/g825482785/p/apachevhost.html