首页 > 代码库 > 虚拟机lamp环境下,Apache配置虚拟主机

虚拟机lamp环境下,Apache配置虚拟主机

1、在Apache配置文件中开启虚拟主机功能:即:Include etc//extra/httpd-vhosts.conf把前面的#去掉;

2、在extra目录下找到文件httpd-vhosts.conf,添加如下配置:

<Directory "/Data/www/thinkphp">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Data/www/thinkphp"
    ServerName lamp.tp.com
    ServerAlias www.lamp.tp.com
    ErrorLog "/log/tp-error_log"
    CustomLog "/log/tp-access_log" common
</VirtualHost>

  

3、重启Apache;

4、在Windows中修改host文件,让虚拟主机的IP指向该域名,如:192.168.33.10 lamp.tp.com

 

虚拟机lamp环境下,Apache配置虚拟主机