由于不存在"/var/www/html"目录。 运行 mkdir "/var/www/html" ,希望它能解决。
我已經安裝了一個全新的 Centos 7 副本。然后我重新启动了Apache,但Apache无法启动。我有 3 天的时间卡在这个问题上。即使是支持也无法找出错误。
sudo service httpd start
Failed to start apache :
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2016-05-09 16:08:02 BST; 59s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 5710 (code=exited, status=1/FAILURE)
May 09 16:08:02 mike079.startdedicated.de systemd[1]: Starting The Apache HTTP Server...
May 09 16:08:02 mike079.startdedicated.de httpd[5710]: (98)Address already in use: AH00072: make_sock: could not bind to address 85.25.12.20:80
May 09 16:08:02 startdedicated.de httpd[5710]: no listening sockets available, shutting down
May 09 16:08:02 startdedicated.de httpd[5710]: AH00015: Unable to open logs
May 09 16:08:02 startdedicated.de systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 09 16:08:02.startdedicated.de kill[5712]: kill: cannot find process ""
May 09 16:08:02 .startdedicated.de systemd[1]: httpd.service: control process exited, code=exited status=1
May 09 16:08:02startdedicated.de systemd[1]: Failed to start The Apache HTTP Server.
May 09 16:08:02 startdedicated.de systemd[1]: Unit httpd.service entered failed state.
May 09 16:08:02 mike: httpd.service failed.
由于vhost.conf中的简单拼写错误,我得到了同样的错误。请记住确保配置文件中没有任何错误。
apachectl configtest
从你的输出:
没有可用的侦听插座,已关闭
基本上意味着,一个 Apache 将在其中侦听的任何端口已经被另一个应用程序使用。
netstat -punta | grep LISTEN
将为您提供正在使用的所有端口的列表以及识别哪个进程所需的信息,以便您可以kill
stop
或执行任何您想做的事情。
在对您的IP进行了nmap
后,我可以看到
80/tcp open http
所以我想你已经解决了。
就我而言,我收到错误仅仅是因为我已将文件中的 Listen 80 更改为侦听 443
/etc/httpd/conf/httpd.conf
由于我已经使用 yum 命令安装了mod_ssl
yum -y install mod_ssl
在安装过程中创建的文件中ssl.conf
有一个重复的 listen 443 指令mod_ssl
。
如果您有重复的 listen 80 或 443,您可以通过在 linux centos(我的 linux(中运行以下命令来验证这一点
grep '443' /etc/httpd/conf.d/*
下面是示例输出
/etc/httpd/conf.d/ssl.conf:Listen 443 https
/etc/httpd/conf.d/ssl.conf:<VirtualHost _default_:443>
/etc/httpd/conf.d/ssl.conf:#ServerName www.example.com:443
只需将 httd.conf 中的收听 443 还原为侦听 80 即可解决我的问题。
命令行上键入journalctl -xe
,结果将是
SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port 83 or 80
这意味着 SELinux 正在您的机器上运行,您需要禁用它。 然后通过键入以下内容编辑配置文件
nano /etc/selinux/config
然后找到SELINUX=enforce
行并更改为SELINUX=disabled
然后键入以下内容并运行命令以启动 httpd
setenforce 0
最后启动服务器
systemctl start httpd
允许 Apache 通过防火墙
允许默认的 HTTP 和 HTTPS 端口(端口 80 和 443(通过 firewalld:
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
并重新加载防火墙:
sudo firewall-cmd --reload
其他一些服务可能正在使用端口 80: 尝试停止其他服务:HTTPD,SSL,NGINX,PHP,使用命令sudo systemctl stop,然后使用命令sudo systemctl start httpd
,问题如下:
[Sat Sep 10 00:43:20.999998 2022] [auth_digest:error] [pid 123456] (2)No such file or directory: AH01762: Failed to create shared memory segment on file /run/httpd/authdigest_shm.128124
[Sat Sep 10 00:43:20.999999 2022] [auth_digest:error] [pid 123456] (2)No such file or directory: AH01760: failed to initialize shm - all nonce-count checking and one-time noncesdisabled
我刚刚尾随错误日志以获得上面的两行:
*ADMINSHELL* :/var/opt/custom_path/logs/httpd # tail error_log
所以问题是这个文件夹丢失了:/run/httpd/
溶液:
mkdir /run/httpd
chown root:httpd /run/httpd
chmod 0710 /run/httpd
完成此操作后。您将能够重新启动该服务:
systemctl restart httpd.service
仔细检查:
systemctl status httpd.service
错误可能出现在任何地方,配置、库或二进制文件。控制过程中的错误是系统在无法启动/重新启动服务时引发的一般错误。就我而言,链接到 .service 文件中 exe 的库之一有问题。修复该库解决了问题。
请尝试此cmd以了解文件配置中缺少的配置或错误$ apachectl configtest
我遇到了几乎相同的错误,我在位于/etc/httpd/conf.d/vhost.conf
上的vhost.conf
文件上发现了错误。
如果您正在配置虚拟主机,我建议您查看以下文件并查找是否有任何错误。
/etc/httpd/conf.d/vhost.conf
,添加虚拟SSL后也会发生同样的错误
/etc/httpd/conf.d/ssl.conf
文件中,它创建了一行,如下所示,
SLCertificateFile /etc/pki/tls/certs/localhost.crt
我将其从 SLCertificateFile 更改为 SSLCertificateFile
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
在 apache 重新启动后,它开始正常工作。
<VirtualHost *:80>
ServerName www.YOURDOMAIN.COM
ServerAlias YOURDOMAIN.COM
DocumentRoot /var/www/YOURDOMAIN.COM/public_html
ErrorLog /var/www/YOURDOMAIN.COM/error.log
CustomLog /var/www/YOURDOMAIN.COM/requests.log combined
DocumentRoot /var/www/YOURDOMAIN.COM/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/YOURDOMAIN.COM/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>