我尝试使用XAMPP在Ubuntu12.04中创建一个虚拟主机magento.developers.com
。
首先,我编辑了/opt/lampp/etc/extra/httpd-vhosts.conf
并添加了以下行:
<VirtualHost *:80>
ServerAdmin webmaster@magento.developers.com
DocumentRoot "/opt/lampp/htdocs/magento"
ServerName magento.developers.com
ErrorLog "logs/magento.developers.com-error_log"
CustomLog "logs/magento.developers.com-access_log" common
</VirtualHost>
我使用命令sudo /opt/lampp/lampp restart
重新启动了XAMPP,然后编辑了
hosts文件,并添加了:
127.0.0.1 magento.developers.com
然后我尝试使用浏览器访问magento.developers.com
,但它不能访问
/opt/lampp/htdocs/magento
我必须做什么才能使它工作,并访问magento
文件夹而不是htdocs
(根目录)?
发布于 2019-06-03 19:08:09
第1步:编辑apache配置
sudo nano /opt/lampp/etc/httpd.conf
并在行下面找到并取消注释(remove #),然后保存
Include etc/extra/httpd-vhosts.conf
第2步:编辑vhost配置以添加虚拟主机
sudo nano /opt/lampp/etc/extra/httpd-vhosts.conf
并使用您的示例(/opt/lampp/htdocs/ DocumentRoot )和ServerName (URL)(example.local)添加以下代码
<VirtualHost *:80> ServerAdmin your@email.com DocumentRoot "/opt/lampp/htdocs/example" ServerName "example.local" ErrorLog "logs/example.local-error_log" CustomLog "logs/example.local-access_log" common </VirtualHost>
步骤3:编辑主机文件以添加您的URL (example.local)
sudo nano /etc/hosts
将这一行添加到底部,其中包含您的URL (example.local)并保存
127.0.1.1 example.local
步骤4:重启服务器
sudo /opt/lampp/lampp restart
https://stackoverflow.com/questions/10878284
复制相似问题