17.1 Web服务Apache


1. 安装Apache服务程序,Apache服务的软件包名称为httpd

    dnf -y install httpd

2. 启动并加入到开机启动项中

   systemctl start httpd

   systemctl enable httpd

3. httpd服务程序主要配置文件和参数

作用 文件名称
服务目录 /etc/httpd
主配置文件 /etc/httpd/conf/httpd.conf
网站数据目录 /var/www/html
访问日志 /var/log/httpd/access_log
错误日志

/var/log/httpd/error_log

4. httpd服务程序主配置文件中常见参数

参数 作用
ServerRoot 服务目录
ServerAdmin 管理员邮箱
User 运行服务的用户
Group 运行服务的用户组
ServerName 网站服务器的域名
DocumentRoot 网站数据目录
Listen 监听的IP地址与端口号
DirectoryIndex 默认的索引页页面
ErrorLog 错误日志文件
CustomLog 访问日志文件
Timeout 网页超时时间,默认为300秒

5. 编辑首页文件

   vim /var/www/html/index.html

6. 重启服务打开网页

    systemctl restart httpd