一、进入/etc/apache2/sites-available,执行命令:cp 000-default.conf demo.conf
然后打开demo.conf 执行命令: vi demo.conf 里面的内容为:
<VirtualHost whh.com:80>
DocumentRoot /var/www/html/whh/trunk/src/public/
ServerName whh.com:80
<Directory "/var/www/html/whh/trunk/src/public/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
然后保存。:x为保存退出,输入i为插入,添加
二、执行命令:vi /etc/hosts
打开之后添加如下代码:
127.0.0.1 localhost
127.0.0.1 whh.com
就是把需要的域名给添加上去。
三、执行命令:sudo a2ensite demo.conf
这样在/etc/apache2/sites-enabled目录下面就会生成一个demo.conf一样的文件用于连接。
四、重启apache执行命令:sudo /etc/init.d/apache2 restart