我在httpd-vhosts.conf中添加了一个虚拟主机,如下所示
<VirtualHost *:80>
ServerAdmin webmaster@localhost.com
DocumentRoot "C:/xampp/htdocs/basicwebsite/public"
ServerName basicwebsite.dev
</VirtualHost>
在类似的帖子中,我也取消了来自https.conf的Include conf/extra/httpd-vhosts.conf
的注释。我还在windows/system32/drivers/etc/hosts
中添加了127.0.0.1 basicwebsite.dev
。
现在,当我启动Apache时,它会显示以下错误
12:07:33 PM [Apache] Error: Apache shutdown unexpectedly.
12:07:33 PM [Apache] This may be due to a blocked port, missing dependencies,
12:07:33 PM [Apache] improper privileges, a crash, or a shutdown by another method.
12:07:33 PM [Apache] Press the Logs button to view error logs and check
12:07:33 PM [Apache] the Windows Event Viewer for more clues
12:07:33 PM [Apache] If you need more help, copy and post this
12:07:33 PM [Apache] entire log window on the forums
当我从httpd-vhosts.conf
中删除VirtualHost时,Apache又开始顺利工作了。
我做错了什么?如有任何建议或帮助,我们将不胜感激。
发布于 2019-08-22 07:21:09
步骤1:
打开C:\xampp\apache\conf\httpd.conf中存在的httpd.conf文件删除存在的#(散列)符号以在httpd.conf文件中包含“httpd-vhosts.conf”文件。
虚拟主机
#Include conf/extra/httpd-vhosts.conf
至
虚拟主机
包括conf/extra/httpd-vhosts.conf
第2步:
创建一个虚拟主机文件。打开“httpd-vhosts.conf”文件。并复制以下代码行。
<VirtualHost *:80>
ServerAdmin webmaster@localhost.com
DocumentRoot <PATH_TO_PROJECT_DIRECTORY_HERE>
ServerName <SERVER_NAME like local.pos.com>
</VirtualHost>
用适当的值替换PATH_TO_PROJECT_DIRECTORY_HERE和SERVER_NAME,保存文件。
Step3:
打开C:\Windows\System32\drivers\etc\hosts
在文件末尾添加以下行。
127.0.0.1 <SERVER_NAME like local.pos.com>
重新启动apache服务器并访问站点URL。
这就是设置虚拟主机所需的全部内容。
发布于 2020-04-10 07:13:27
尝试在VirtualHost中添加目录标签
<VirtualHost *:80>
ServerAdmin webmaster@localhost.com
DocumentRoot "C:/xampp/htdocs/basicwebsite/public"
ServerName basicwebsite.dev
<Directory "C:/xampp/htdocs/basicwebsite/public">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
https://stackoverflow.com/questions/57603893
复制相似问题