ubuntu下xampp 虚拟目录配置
sudo gedit /opt/lampp/etc/httpd.conf
找到
#Include etc/extra/httpd-vhosts.conf
去除前面的#注释符号
Include etc/extra/httpd-vhosts.conf
并在文件最后追加如下访问权限配置,websites下可以有wb1、wb2 ... 等多个网站
<Directory "/home/user/websites"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all Require all granted #由于物理目录出于用户目录之下,需要granted </Directory>
然后编辑httpd-vhosts.conf文件
sudo gedit /opt/lampp/etc/extra /httpd-vhosts.conf
在此文件中配置虚拟目录
DocumentRoot -- 虚拟主机物理路径
ServerName -- 虚拟主机访问地址
按如下格式添加:
<VirtualHost *:80> DocumentRoot "/home/user/websites/ws1" ServerName example.com </VirtualHost>
配置完成,重启xampp服务
sudo /opt/lampp/xampp restart
浏览器输入 example.com 即可访问/home/user/websites/ws1 下的网站