您的位置:首页 > 编程语言 > PHP开发

PHP单机发布时的虚拟域名配置

2016-12-30 10:25 609 查看
配置虚拟域名,避免冗长的路径,顺便把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.效果如图所示

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息