- 首先打开三个 terminal,并分别获得 root 权限
- 在三个 terminal 中,分别进入 /etc/apache2 目录
其中一个 terminal 进入 site-available 中并复制
000-default.conf 文件一份,重命名为需要的虚拟主机 target.conf- >$ cp site/available/000-default.conf target.conf
依次打开如下三个文件
apache2.conf
site-available/target.conf
ports.conf在 site-available/target.conf 文件中,修改第一行的端口号为 xxxx,
以及 DocumentRoot 的所对应的路径地址,然后保存退出进入 site-available 目录后,再执行
- >$ cd site-available
- >$ a2ensite target.conf
- >$ cd ../
- 在 ports.conf 文件中,第二行添加
Listen xxxx
,其中 xxxx 为第5步中的端口号 - 在 apache2.conf 文件中,添加第5步中 DocumentRoot 对应路径的权限信息,如
- <Directory /home/dev/xxxx>
- Options Indexes FollowSymLinks
- AllowOverride None
- Require all granted
- </Directory>
重启 apache 服务器
It works