NO.12 httpd服务

    xiaoxiao2021-03-25  85

    安装apache软件包:

               yum install -y httpd httpd-manual

    启动apache服务:

               systemctl start httpd ; systemctl enable httpd

    查看监听端口: ss -antlp |grep httpd LISTEN 0 128 :::80 :::* users:(("httpd",4347,4),("httpd",4346,4),("httpd",4345,4),("httpd",4344,4),("httpd" ,4343,4),("httpd",4342,4))

    主配置文件    /etc/httpd/conf/httpd.conf

    ServerRoot "/etc/httpd"                                   用于指定Apache的运行目录 Listen 80                                                         监听端口 User apache                                                   运行apache程序的用户和组 Group apache ServerAdmin root@localhost                           管理员邮箱 DocumentRoot "/var/www/html"                       网页文件的存放目录 <Directory "/var/www/html"> <Directory>        语句块自定义目录权限 Require all granted </Directory> ErrorLog "logs/error_log"                                 错误日志存放位置 AddDefaultCharset UTF-8                               默认支持的语言 IncludeOptional conf.d/*.conf                           加载其它配置文件 DirectoryIndex index.html                                 默认主页名称

    httpd  服务允许一个服务器为多个网站同时提供服务  即不同的域名指向同一个IP

    的不同内容

    Example: <virtualhost *:80>

    servername www.example.com                                  指定服务器名称 serveralias www documentroot /var/www/example.com/                       指定单独域名的根目录 customlog "logs/www.example.com.log" combined     指定日志文件目录

    </virtualhost>

    <directory /var/www/example.com> require all granted </directory>

    此外  需在/etc/httpd/conf.d/  下编写虚拟主机的配置文件

    用账户创建Apache密码文件

    htpasswd -cm /etc/httpd/.htpasswd user

    在VirtualHost块中将诸如以下内容添加至VirtualHost块

    <Directory /var/www/html> AuthName “Secret Stuff” AuthType basic AuthUserFile /etc/httpd/.htpasswd Require valid-user </Directory>

    配置完成后需重起apache服务

    转载请注明原文地址: https://ju.6miu.com/read-21854.html

    最新回复(0)