apache - 添加新虚拟主机时 Apache 服务器无法启动
问题描述
我目前在运行 Apache2 的 Linode 上有一个 CentOS 7 服务器,其中有两个域指向它。我通过在 /etc/httpd/conf.d/vhost.conf 中配置基于名称的虚拟主机来实现这一点
这效果很好,但是...
出于某种原因,当我向该文件添加第三个虚拟主机时,apache 拒绝启动。我已经在 /var/www/html/... 中创建了所有适当的文件夹,并具有适当的权限(apache.apache)。但是 Apache 仍然拒绝启动。下面是我的 vhost.conf 文件的示例和来自 apache 的错误日志。我错过了什么步骤?
这是我的 vhost.conf ......
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@domain1.com
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/html/domain1.com/public_html/
ErrorLog /var/www/html/domain1.com/logs/error.log
CustomLog /var/www/html/domain1.com/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@domain2.com
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/html/domain2.com/public_html/
ErrorLog /var/www/html/domain2.com/logs/error.log
CustomLog /var/www/html/domain2.com/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@domain3.com
ServerName domain3.com
ServerAlias www.domain3.com
DocumentRoot /var/www/html/domain3.com/public_html/
ErrorLog /var/www/html/domain3.com/logs/error.log
CustomLog /var/www/html/domain3.com/logs/access.log combined
</VirtualHost>
这是我从 apache 得到的错误...
Jan 16 18:40:30 dribrats systemd[1]: Starting The Apache HTTP Server...
Jan 16 18:40:30 dribrats httpd[19023]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf.d/vhost.conf:1
Jan 16 18:40:30 dribrats httpd[19023]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using xxxx::xxxx:xxxx:xxxx:xxxx. Set the 'ServerName' directive globally to suppress this message
Jan 16 18:40:30 dribrats systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 16 18:40:30 dribrats kill[19024]: kill: cannot find process ""
Jan 16 18:40:30 dribrats systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 16 18:40:30 dribrats systemd[1]: Failed to start The Apache HTTP Server.
Jan 16 18:40:30 dribrats systemd[1]: Unit httpd.service entered failed state.
Jan 16 18:40:30 dribrats systemd[1]: httpd.service failed.
解决方案
好的,我已经想通了。问题源于我对第三个域的新文件夹的权限。我没有设置正确的权限。运行以下命令解决了我的问题。
sudo chown apache:apache -R /var/www/html/example.com/
cd /var/www/html/example.com/
find . -type f -exec sudo chmod 0644 {} \;
find . -type d -exec sudo chmod 0755 {} \;
sudo chcon -t httpd_sys_content_t /var/www/html/example.com -R
sudo chcon -t httpd_sys_rw_content_t /var/www/html/example.com -R
然后重启apache...
sudo systemctl restart httpd.service
推荐阅读
- aem - AEM /welcome 未重定向到 /libs/cq/core/content/welcome.html
- python - 将直线显示为斜坡的绘图 - Python
- asp.net-web-api - Coinigy v2 API - 如何使用 StartDate 和 EndDate 参数调用交易历史 API
- java - 数据库从 WSO2 bps 迁移到 Camunda
- shell - 只需要 grep IP 地址
- javascript - 观看 $route.params.slug 不会触发 vuejs
- kubernetes - 为什么 ThingsBoard 服务的 Kubernetes 配置文件将 TCP 用于 CoAP?
- c - 读取 C 中的访问冲突,试图找到源
- android - Android Studio 3.2 更新后同步失败
- mongodb - 无法在 Spring Data MongoDb 中使用 Nested VariableOperators.mapItemsOf