apache 出现错误 /usr/local/apache2/bin/apachectl start httpd: Could not reliably determine the server

[root@wenxiang apache2]# /usr/local/apache2/bin/apachectl start

httpd: Could not reliably determine the server's fully qualified domain n                 

ame, using 120.209.138.64 for ServerName


解决办法:# vi conf/httpd.conf

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.


#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk.  If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "/usr/local/apache2"
</IfModule>
</IfModule>


# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#


#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin you@example.com


#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName www.example.com:80 //注释:把#去掉


#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/local/apache2/htdocs"


#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).



[root@wenxiang apache2]# ./bin/apachectl -t

[root@localhost ~]# ls -l /usr/sbin/httpd -rwxr-xr-x. 1 root root 527736 5月 30 2023 /usr/sbin/httpd [root@localhost ~]# ls -l /usr/local/apache2/bin/httpd /usr/local/httpd/bin/httpd ls: 无法访问/usr/local/apache2/bin/httpd: 没有那个文件或目录 ls: 无法访问/usr/local/httpd/bin/httpd: 没有那个文件或目录 [root@localhost ~]# [root@localhost ~]# sudo vi /etc/systemd/system/httpd.service [root@localhost ~]# sudo systemctl daemon-reload [root@localhost ~]# sudo rm -f /etc/systemd/system/httpd.service [root@localhost ~]# sudo cp /usr/lib/systemd/system/httpd.service /etc/systemd/system/ [root@localhost ~]# sudo systemctl daemon-reload [root@localhost ~]# sudo systemctl start httpd [root@localhost ~]# sudo systemctl status httpdhttpd.service - The Apache HTTP Server Loaded: loaded (/etc/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since 一 2025-11-03 09:43:21 CST; 134ms ago Docs: man:httpd(8) man:apachectl(8) Main PID: 65758 (httpd) Status: "Processing requests..." Tasks: 6 CGroup: /system.slice/httpd.service ├─65758 /usr/sbin/httpd -DFOREGROUND ├─65759 /usr/sbin/httpd -DFOREGROUND ├─65760 /usr/sbin/httpd -DFOREGROUND ├─65761 /usr/sbin/httpd -DFOREGROUND ├─65762 /usr/sbin/httpd -DFOREGROUND └─65763 /usr/sbin/httpd -DFOREGROUND 11月 03 09:43:21 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... 11月 03 09:43:21 localhost.localdomain httpd[65758]: AH00558: httpd: Could not reliably determine the server's fully qualified domain ...essage 11月 03 09:43:21 localhost.localdomain systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]# curl -I http://localhost # 测试服务响应 HTTP/1.1 403 Forbidden Date: Mon, 03 Nov 2025 01:43:21 GMT Server: Apache/2.4.6 (CentOS) Last-Modified: Thu, 16 Oct 2014 13:20:58 GMT ETag: "1321-5058a1e728280" Accept-Ranges: bytes Content-Length: 4897 Content-Type: text/html; charset=UTF-8 [root@localhost ~]# sudo firewall-cmd --permanent --add-service=http FirewallD is not running [root@localhost ~]# sudo firewall-cmd --reload FirewallD is not running
11-04
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值