Linix Apache VirtualHost 配置
摘要:Linix Apache VirtualHost 配置域名或配置IP和端口,及启用。
1. 配置域名:
在 /etc/apache2/sites-available/blog.conf 添加以下代码
VirtualHost *:80> ServerName wp.blog.com // 域名 ServerAdmin webmaster@localhost DocumentRoot /var/www/html/E_Linux/wamp/www/blog <Directory /var/www/html/E_Linux/wamp/www/blog/> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
在 /etc/hosts 添加域名
127.0.0.1 wp.blog.com
2. 配置IP和端口
在 /etc/apache2/sites-available/blog.conf 添加以下代码
VirtualHost *:8080> // 端口 ServerName 127.0.0.1 // IP ServerAdmin webmaster@localhost DocumentRoot /var/www/html/E_Linux/wamp/www/blog <Directory /var/www/html/E_Linux/wamp/www/blog/> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
在 /etc/apache2/ports.conf 添加端口
Listen 8080
3. 启用 Apache VirtualHost
sudo a2ensite blog.conf
sudo service apache2 restart
4. 使用
- 在浏览器输入 wp.blog.com 或者 127.0.0.1:8080,开始编程喽。
- 欢迎各大神点评 -