apache - 添加虚拟主机后 Apache 未启动
问题描述
我在 httpd-vhosts.conf 中添加了一个虚拟主机如下
<VirtualHost *:80>
ServerAdmin webmaster@localhost.com
DocumentRoot "C:/xampp/htdocs/basicwebsite/public"
ServerName basicwebsite.dev
</VirtualHost>
我也Include conf/extra/httpd-vhosts.conf
按照类似线程中的建议取消了对 https.conf 的评论。我还添加127.0.0.1 basicwebsite.dev
了windows/system32/drivers/etc/hosts
.
现在当我启动 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
当我从 中删除 VirtualHost 时httpd-vhosts.conf
,Apache 再次开始顺利工作..
我做错了什么?任何建议/帮助将不胜感激。
解决方案
步骤1:
打开 C:\xampp\apache\conf\httpd.conf 中存在的 httpd.conf 文件 删除存在的 #(hash) 符号以在 httpd.conf 文件中包含“httpd-vhosts.conf”文件。
虚拟主机
#包括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 替换为适当的值,保存文件。
第三步:
打开 C:\Windows\System32\drivers\etc\hosts
在文件末尾添加以下行。
127.0.0.1 <SERVER_NAME like local.pos.com>
重新启动 apache 服务器并访问站点 URL。
这就是设置虚拟主机所需要的一切。
推荐阅读
- testing - 我无法使用 tsung 工具解释来自控制台的消息
- wordpress - 帖子类型分类未显示在古腾堡
- javascript - 什么是 Webtorrent 中仅浏览器的方法错误?
- momentjs - moment.js 使用 dd-mm-yyyy 格式比较日期
- php - 将数据添加到广播队列 Laravel
- android - 记住我在 android studio 中的复选框
- amazon-web-services - 消息轮询实例 ID
- python - Python:计算每种类型的标题数量和平均评分
- c# - ASP.NET Core CSHTML 视图中的 DropDownListFor 未加载当前值
- css - 按百分比定义填充时,父级不考虑子级的全宽