Httpd服务入门知识-Httpd服务常见配置案例之显示服务器版本信息
Httpd服务入门知识-Httpd服务常见配置案例之显示服务器版本信息
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.httpd配置文件的组成
1>.主要组成
Global Environment
Main server configuration
virtual host
2>.配置格式:directive value(指令 属性值)
directive 不区分字符大小写
value 为路径时,是否区分大小写,取决于文件系统
3>.官方帮助
博主推荐阅读: http://httpd.apache.org/docs/2.4/
二.显示服务器版本信息
1>.如下图所示,默认情况下服务器版本是显示的
2>.点击指令快速参考(如下图所示,点击"Run-time Configuration Directives")
3>.快速过滤我们要查找的指令(如下图所示,咱们要设置的是显示服务器版本信息,该指令是以"S"开头的)
4>.如下图所示,点击"ServerTokens"指令
5>.查看显示服务器版本信息案例
6>.自定义httpd的配置文件,设置参数"ServerTokens Prod"
[root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf ServerRoot "/etc/httpd" Listen 80 Include conf.modules.d/*.conf User apache Group apache ServerAdmin root@localhost <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/var/www/html" <Directory "/var/www"> AllowOverride None Require all granted </Directory> <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "logs/error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "logs/access_log" combined </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" </IfModule> <Directory "/var/www/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> TypesConfig /etc/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .shtml AddOutputFilter INCLUDES .shtml </IfModule> AddDefaultCharset UTF-8 <IfModule mime_magic_module> MIMEMagicFile conf/magic </IfModule> EnableSendfile on IncludeOptional conf.d/*.conf [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# curl -I http://node101.yinzhengjie.org.cn/ HTTP/1.1 200 OK Date: Sat, 07 Dec 2019 01:59:20 GMT Server: Apache/2.4.6 (CentOS) Last-Modified: Sat, 07 Dec 2019 01:31:15 GMT ETag: "25-599131e54e9d8" Accept-Ranges: bytes Content-Length: 37 Content-Type: text/html; charset=UTF-8 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# echo "ServerTokens Prod" > /etc/httpd/conf.d/server_tokens.conf [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# cat /etc/httpd/conf.d/server_tokens.conf ServerTokens Prod [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# httpd -t Syntax OK [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# systemctl reload httpd [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# curl -I http://node101.yinzhengjie.org.cn/ HTTP/1.1 200 OK Date: Sat, 07 Dec 2019 02:00:26 GMT Server: Apache Last-Modified: Sat, 07 Dec 2019 01:31:15 GMT ETag: "25-599131e54e9d8" Accept-Ranges: bytes Content-Length: 37 Content-Type: text/html; charset=UTF-8 [root@node101.yinzhengjie.org.cn ~]#
7>.查看httpd进程
[root@node101.yinzhengjie.org.cn ~]# ps auxf | grep apache root 5085 0.0 0.0 112708 980 pts/0 S+ 10:08 0:00 | \_ grep --color=auto apache apache 5057 0.0 0.0 224184 3700 ? S 10:00 0:00 \_ /usr/sbin/httpd -DFOREGROUND apache 5058 0.0 0.0 224184 3672 ? S 10:00 0:00 \_ /usr/sbin/httpd -DFOREGROUND apache 5059 0.0 0.0 224052 3184 ? S 10:00 0:00 \_ /usr/sbin/httpd -DFOREGROUND apache 5060 0.0 0.0 224052 2948 ? S 10:00 0:00 \_ /usr/sbin/httpd -DFOREGROUND apache 5061 0.0 0.0 224052 2952 ? S 10:00 0:00 \_ /usr/sbin/httpd -DFOREGROUND apache 5065 0.0 0.0 224052 2952 ? S 10:00 0:00 \_ /usr/sbin/httpd -DFOREGROUND [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# pstree | grep httpd |-httpd---6*[httpd] [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# pstree -p | grep httpd |-httpd(5026)-+-httpd(5057) | |-httpd(5058) | |-httpd(5059) | |-httpd(5060) | |-httpd(5061) | `-httpd(5065) [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# pstree -p systemd(1)─┬─NetworkManager(3051)─┬─dhclient(3119) │ ├─{NetworkManager}(3081) │ └─{NetworkManager}(3084) ├─agetty(3421) ├─atd(3055) ├─auditd(3015)───{auditd}(3016) ├─crond(3068) ├─dbus-daemon(3042) ├─httpd(5026)─┬─httpd(5057) │ ├─httpd(5058) │ ├─httpd(5059) │ ├─httpd(5060) │ ├─httpd(5061) │ └─httpd(5065) ├─irqbalance(3040) ├─lvmetad(1656) ├─polkitd(3037)─┬─{polkitd}(3050) │ ├─{polkitd}(3052) │ ├─{polkitd}(3053) │ ├─{polkitd}(3072) │ ├─{polkitd}(3077) │ └─{polkitd}(3079) ├─rsyslogd(3400)─┬─{rsyslogd}(3411) │ └─{rsyslogd}(3415) ├─sshd(3396)─┬─sshd(3954)───bash(3956)───pstree(5101) │ └─sshd(4851)───bash(4853) ├─systemd-journal(1636) ├─systemd-logind(3041) ├─systemd-udevd(1660) └─tuned(3395)─┬─{tuned}(3676) ├─{tuned}(3677) ├─{tuned}(3678) └─{tuned}(3691) [root@node101.yinzhengjie.org.cn ~]#
本文来自博客园,作者:尹正杰,转载请注明原文链接:https://www.cnblogs.com/yinzhengjie/p/12000173.html,个人微信: "JasonYin2020"(添加时请备注来源及意图备注,有偿付费)
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。