配置虚拟域名,避免冗长的路径,顺便把index.php也隐藏掉,这里我用的是ThinkPHP框架。
1. vim /etc/hosts , 把虚拟域名添加进去。例如我这里最简单的用tp5.com 代替。那就加上一行
127.0.0.1 tp5.com
2.在/etc/apache2/apache2.conf 中进行VirtualHost的设置
<VirtualHost *:80>
ServerName tp5.com
DocumentRoot /var/www/html/
<Directory /var/www/html/thinkdevice >
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
ServerName 是对应着hosts文件中配置的虚拟域名
DocumentRoot 是web服务器的根目录的绝对路径
<Directory /var/www/html/thinkdevice > 是项目的路径,同时也是index.php 放置的位置
3.效果如图所示