我正在尝试创建一个 Web 服务器,但添加虚拟主机配置后,apache 不会重新启动。它有几个错误,但我已经设法修复了其中的大部分。现在我不知道发生了什么,因为journalctl -xn
没有给我任何提示。
这是日志:
[root@localhost victorscarone]# systemctl restart httpd.service
Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' for details.
[root@localhost victorscarone]# systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: failed (Result: exit-code) since vie 2015-09-11 22:54:27 PYT; 2s ago
Process: 2681 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 2679 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 2679 (code=exited, status=1/FAILURE)
sep 11 22:54:27 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
sep 11 22:54:27 localhost.localdomain kill[2681]: kill: cannot find process ""
sep 11 22:54:27 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
sep 11 22:54:27 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
sep 11 22:54:27 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
[root@localhost victorscarone]# journalctl -xn
-- Logs begin at vie 2015-09-11 22:20:49 PYT, end at vie 2015-09-11 22:54:27 PYT. --
sep 11 22:48:29 localhost.localdomain kill[2658]: kill: cannot find process ""
sep 11 22:48:29 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
sep 11 22:48:29 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
--
-- Unit httpd.service has failed.
--
-- The result is failed.
sep 11 22:48:29 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
sep 11 22:54:27 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun with start-up
-- Defined-By: systemd
--
-- Unit httpd.service has begun starting up.
sep 11 22:54:27 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
sep 11 22:54:27 localhost.localdomain kill[2681]: kill: cannot find process ""
sep 11 22:54:27 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
sep 11 22:54:27 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
--
-- Unit httpd.service has failed.
--
-- The result is failed.
sep 11 22:54:27 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
请帮忙,这是为了一个好的理由(我的大学作业:D)
编辑 #1 (09/12/2015 19:30 GMT -4)
我不知道我刚刚做了什么,但是测试“httpd -t”命令@garethTheRed告诉我,我想看看它有什么帮助,所以我尝试了“httpd -H”并执行。然后运行“apachectl restart”给了我同样的错误。但这一次看到“journalctl -xn”时发生了变化。 apache 中仍然存在错误,但它已经在测试页 123 上运行。但是 vhost 尚未工作。
这是之后的输出。
[root@localhost victorscarone]# httpd -t
Syntax OK
[root@localhost victorscarone]# httpd --help
[root@localhost victorscarone]# httpd --h
httpd (pid 2977) already running
[root@localhost victorscarone]# systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: failed (Result: exit-code) since sáb 2015-09-12 19:12:42 PYT; 4min 53s ago
Process: 2965 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 2963 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 2963 (code=exited, status=1/FAILURE)
sep 12 19:12:42 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
sep 12 19:12:42 localhost.localdomain kill[2965]: kill: cannot find process ""
sep 12 19:12:42 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
sep 12 19:12:42 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
sep 12 19:12:42 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost victorscarone]# apachectl restart
Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' for details.
[root@localhost victorscarone]# journalctl -xn
-- Logs begin at sáb 2015-09-12 19:07:51 PYT, end at sáb 2015-09-12 19:18:32 PYT. --
sep 12 19:18:18 localhost.localdomain kill[2993]: kill: cannot find process ""
sep 12 19:18:18 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
sep 12 19:18:18 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
--
-- Unit httpd.service has failed.
--
-- The result is failed.
sep 12 19:18:18 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
sep 12 19:18:32 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun with start-up
-- Defined-By: systemd
--
-- Unit httpd.service has begun starting up.
sep 12 19:18:32 localhost.localdomain httpd[3001]: httpd (pid 2977) already running
sep 12 19:18:32 localhost.localdomain kill[3003]: kill: cannot find process ""
sep 12 19:18:32 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
sep 12 19:18:32 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
--
-- Unit httpd.service has failed.
--
-- The result is failed.
sep 12 19:18:32 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
[root@localhost victorscarone]# httpd -t
Syntax OK
有任何想法吗?
编辑#2 09/24/2015 19:29 (GMT -4) 我很抱歉延迟了,没有时间继续这个,但现在我又开始了。我已经尝试过 @garethTheRed 所说的,但它在某一时刻卡住了
[root@localhost victorscarone]# httpd -DFOREGROUND -e debug
[Thu Sep 24 19:26:01.249663 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module access_compat_module from /etc/httpd/modules/mod_access_compat.so
[Thu Sep 24 19:26:01.249913 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module actions_module from /etc/httpd/modules/mod_actions.so
[Thu Sep 24 19:26:01.249975 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module alias_module from /etc/httpd/modules/mod_alias.so
[Thu Sep 24 19:26:01.250021 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module allowmethods_module from /etc/httpd/modules/mod_allowmethods.so
[Thu Sep 24 19:26:01.250065 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module auth_basic_module from /etc/httpd/modules/mod_auth_basic.so
[Thu Sep 24 19:26:01.250130 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module auth_digest_module from /etc/httpd/modules/mod_auth_digest.so
[Thu Sep 24 19:26:01.250180 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authn_anon_module from /etc/httpd/modules/mod_authn_anon.so
[Thu Sep 24 19:26:01.250230 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authn_core_module from /etc/httpd/modules/mod_authn_core.so
[Thu Sep 24 19:26:01.250277 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authn_dbd_module from /etc/httpd/modules/mod_authn_dbd.so
[Thu Sep 24 19:26:01.250324 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authn_dbm_module from /etc/httpd/modules/mod_authn_dbm.so
[Thu Sep 24 19:26:01.250368 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authn_file_module from /etc/httpd/modules/mod_authn_file.so
[Thu Sep 24 19:26:01.250422 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authn_socache_module from /etc/httpd/modules/mod_authn_socache.so
[Thu Sep 24 19:26:01.250484 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authz_core_module from /etc/httpd/modules/mod_authz_core.so
[Thu Sep 24 19:26:01.250541 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authz_dbd_module from /etc/httpd/modules/mod_authz_dbd.so
[Thu Sep 24 19:26:01.250597 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authz_dbm_module from /etc/httpd/modules/mod_authz_dbm.so
[Thu Sep 24 19:26:01.250650 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authz_groupfile_module from /etc/httpd/modules/mod_authz_groupfile.so
[Thu Sep 24 19:26:01.250701 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authz_host_module from /etc/httpd/modules/mod_authz_host.so
[Thu Sep 24 19:26:01.250857 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authz_owner_module from /etc/httpd/modules/mod_authz_owner.so
[Thu Sep 24 19:26:01.250914 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module authz_user_module from /etc/httpd/modules/mod_authz_user.so
[Thu Sep 24 19:26:01.250986 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module autoindex_module from /etc/httpd/modules/mod_autoindex.so
[Thu Sep 24 19:26:01.251082 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module cache_module from /etc/httpd/modules/mod_cache.so
[Thu Sep 24 19:26:01.251370 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module cache_disk_module from /etc/httpd/modules/mod_cache_disk.so
[Thu Sep 24 19:26:01.251431 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module data_module from /etc/httpd/modules/mod_data.so
[Thu Sep 24 19:26:01.251498 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module dbd_module from /etc/httpd/modules/mod_dbd.so
[Thu Sep 24 19:26:01.251662 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module deflate_module from /etc/httpd/modules/mod_deflate.so
[Thu Sep 24 19:26:01.251805 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module dir_module from /etc/httpd/modules/mod_dir.so
[Thu Sep 24 19:26:01.251873 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module dumpio_module from /etc/httpd/modules/mod_dumpio.so
[Thu Sep 24 19:26:01.251929 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module echo_module from /etc/httpd/modules/mod_echo.so
[Thu Sep 24 19:26:01.251985 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module env_module from /etc/httpd/modules/mod_env.so
[Thu Sep 24 19:26:01.252044 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module expires_module from /etc/httpd/modules/mod_expires.so
[Thu Sep 24 19:26:01.252113 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module ext_filter_module from /etc/httpd/modules/mod_ext_filter.so
[Thu Sep 24 19:26:01.252184 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module filter_module from /etc/httpd/modules/mod_filter.so
[Thu Sep 24 19:26:01.252309 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module headers_module from /etc/httpd/modules/mod_headers.so
[Thu Sep 24 19:26:01.252392 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module include_module from /etc/httpd/modules/mod_include.so
[Thu Sep 24 19:26:01.252475 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module info_module from /etc/httpd/modules/mod_info.so
[Thu Sep 24 19:26:01.252547 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module log_config_module from /etc/httpd/modules/mod_log_config.so
[Thu Sep 24 19:26:01.252611 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module logio_module from /etc/httpd/modules/mod_logio.so
[Thu Sep 24 19:26:01.252684 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module mime_magic_module from /etc/httpd/modules/mod_mime_magic.so
[Thu Sep 24 19:26:01.252822 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module mime_module from /etc/httpd/modules/mod_mime.so
[Thu Sep 24 19:26:01.252916 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module negotiation_module from /etc/httpd/modules/mod_negotiation.so
[Thu Sep 24 19:26:01.252985 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module remoteip_module from /etc/httpd/modules/mod_remoteip.so
[Thu Sep 24 19:26:01.253050 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module reqtimeout_module from /etc/httpd/modules/mod_reqtimeout.so
[Thu Sep 24 19:26:01.253150 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module rewrite_module from /etc/httpd/modules/mod_rewrite.so
[Thu Sep 24 19:26:01.253219 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module setenvif_module from /etc/httpd/modules/mod_setenvif.so
[Thu Sep 24 19:26:01.253303 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module slotmem_plain_module from /etc/httpd/modules/mod_slotmem_plain.so
[Thu Sep 24 19:26:01.253373 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module slotmem_shm_module from /etc/httpd/modules/mod_slotmem_shm.so
[Thu Sep 24 19:26:01.253440 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module socache_dbm_module from /etc/httpd/modules/mod_socache_dbm.so
[Thu Sep 24 19:26:01.253503 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module socache_memcache_module from /etc/httpd/modules/mod_socache_memcache.so
[Thu Sep 24 19:26:01.253567 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module socache_shmcb_module from /etc/httpd/modules/mod_socache_shmcb.so
[Thu Sep 24 19:26:01.253638 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module status_module from /etc/httpd/modules/mod_status.so
[Thu Sep 24 19:26:01.253747 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module substitute_module from /etc/httpd/modules/mod_substitute.so
[Thu Sep 24 19:26:01.253823 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module suexec_module from /etc/httpd/modules/mod_suexec.so
[Thu Sep 24 19:26:01.253884 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module unique_id_module from /etc/httpd/modules/mod_unique_id.so
[Thu Sep 24 19:26:01.253960 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module unixd_module from /etc/httpd/modules/mod_unixd.so
[Thu Sep 24 19:26:01.254028 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module userdir_module from /etc/httpd/modules/mod_userdir.so
[Thu Sep 24 19:26:01.254094 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module version_module from /etc/httpd/modules/mod_version.so
[Thu Sep 24 19:26:01.254157 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module vhost_alias_module from /etc/httpd/modules/mod_vhost_alias.so
[Thu Sep 24 19:26:01.254350 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module dav_module from /etc/httpd/modules/mod_dav.so
[Thu Sep 24 19:26:01.254491 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module dav_fs_module from /etc/httpd/modules/mod_dav_fs.so
[Thu Sep 24 19:26:01.255042 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module dav_lock_module from /etc/httpd/modules/mod_dav_lock.so
[Thu Sep 24 19:26:01.255892 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module lua_module from /etc/httpd/modules/mod_lua.so
[Thu Sep 24 19:26:01.256053 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module mpm_prefork_module from /etc/httpd/modules/mod_mpm_prefork.so
[Thu Sep 24 19:26:01.256261 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_module from /etc/httpd/modules/mod_proxy.so
[Thu Sep 24 19:26:01.256362 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module lbmethod_bybusyness_module from /etc/httpd/modules/mod_lbmethod_bybusyness.so
[Thu Sep 24 19:26:01.256434 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module lbmethod_byrequests_module from /etc/httpd/modules/mod_lbmethod_byrequests.so
[Thu Sep 24 19:26:01.256505 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module lbmethod_bytraffic_module from /etc/httpd/modules/mod_lbmethod_bytraffic.so
[Thu Sep 24 19:26:01.256709 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module lbmethod_heartbeat_module from /etc/httpd/modules/mod_lbmethod_heartbeat.so
[Thu Sep 24 19:26:01.256904 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_ajp_module from /etc/httpd/modules/mod_proxy_ajp.so
[Thu Sep 24 19:26:01.257042 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_balancer_module from /etc/httpd/modules/mod_proxy_balancer.so
[Thu Sep 24 19:26:01.257142 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_connect_module from /etc/httpd/modules/mod_proxy_connect.so
[Thu Sep 24 19:26:01.257227 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_express_module from /etc/httpd/modules/mod_proxy_express.so
[Thu Sep 24 19:26:01.257334 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_fcgi_module from /etc/httpd/modules/mod_proxy_fcgi.so
[Thu Sep 24 19:26:01.257421 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_fdpass_module from /etc/httpd/modules/mod_proxy_fdpass.so
[Thu Sep 24 19:26:01.257543 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_ftp_module from /etc/httpd/modules/mod_proxy_ftp.so
[Thu Sep 24 19:26:01.257736 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_http_module from /etc/httpd/modules/mod_proxy_http.so
[Thu Sep 24 19:26:01.257861 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module proxy_scgi_module from /etc/httpd/modules/mod_proxy_scgi.so
[Thu Sep 24 19:26:01.258128 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module systemd_module from /etc/httpd/modules/mod_systemd.so
[Thu Sep 24 19:26:01.258301 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module cgi_module from /etc/httpd/modules/mod_cgi.so
[Thu Sep 24 19:26:01.272364 2015] [so:debug] [pid 2603] mod_so.c(266): AH01575: loaded module php5_module from /etc/httpd/modules/libphp5.so
答案1
我遇到了类似的问题,事实证明 Apache 不喜欢 VirtualHost 容器中的 ErrorLog 和 CustomLog 行。我将它们注释掉,服务开始没有问题。
我猜这与 httpd.conf 中的权限有关
答案2
对于将来遇到此问题的任何人,不要禁用 SElinux,学习如何使用它。禁用它几乎就像取消枪支上的所有安全装置一样,因为当您尝试射击时扳机将无法工作。
这是解决这个问题的正确方法:
semanage fcontext -a httpd_sys_rw_content_t "/var/www/html(/.*)?"
将允许 apache 权限读取和写入给定目录。
之后,你应该能够restorecon -Rv /var/www/html
这应该可以解决你的问题。
正如@MADforFUNandHappy 发布的
答案3
尝试完全重新启动系统,看起来它正在尝试终止不再存在的进程。
sudo reboot
当系统完全重新启动后,尝试再次运行该命令。
sudo systemctl restart httpd
这应该可以工作,如果不行,请发布“journalctl -xn”输出。
答案4
对我来说,它是通过在 CentOS7 中禁用 selinux 来实现的
要在重新启动后永久禁用,请执行以下操作:
须藤纳米 /etc/selinux/config
SELINUX=允许或禁用
保存文件
须藤 setenforce 0
并检查
状态