• Httpd服务入门知识-Httpd服务常见配置案例之修改监听的IP和Port


            Httpd服务入门知识-Httpd服务常见配置案例之修改监听的IP和Port

                                          作者:尹正杰

    版权声明:原创作品,谢绝转载!否则将追究法律责任。

    一.查看默认配置

    [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 ~]# 

    二.修改监听的IP和Port语法

    Listen [IP:]PORT
      (1)省略IP表示为本机所有IP
      (2)Listen指令至少一个,可重复出现多次

    三.修改监听的IP地址和Port实战案例

    [root@node101.yinzhengjie.org.cn ~]# ss -ntl         #默认监听本机的所有IP地址的80端口
    State       Recv-Q Send-Q        Local Address:Port                       Peer Address:Port              
    LISTEN      0      128                       *:80                                    *:*                  
    LISTEN      0      128                       *:22                                    *:*                  
    LISTEN      0      128                      :::22                                   :::*                  
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# vim /etc/httpd/conf.d/listen.conf
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# cat /etc/httpd/conf.d/listen.conf      #我们可以配置多条listen指令,它们并不会相互影响哟~
    listen 8080
    listen 172.30.1.101:8090
    [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 ~]# ss -ntl 
    State       Recv-Q Send-Q        Local Address:Port                       Peer Address:Port              
    LISTEN      0      128                       *:8080                                  *:*                  
    LISTEN      0      128                       *:80                                    *:*                  
    LISTEN      0      128                       *:22                                    *:*                  
    LISTEN      0      128            172.30.1.101:8090                                  *:*                  
    LISTEN      0      128                      :::22                                   :::*                  
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# 
  • 相关阅读:
    iconv 文件编码相互转换
    MySQL 字符编码
    MySQL there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause同时创建多个更新当前时间戳字段 解决方法
    PHP 输出日志到文件 DEMO
    Nginx http -> https 跳转后 POST 丢失
    SSH SCP 远程密钥登录配置和服务器间的文件传输
    Mac 安装 7zip
    git pull There is no tracking information for the current branch.
    MacOS 安装配置 Laravel
    Mac OS 安装 MySQL5.7
  • 原文地址:https://www.cnblogs.com/yinzhengjie/p/12000469.html
Copyright © 2020-2023  润新知