# 网络服务器 Apache httpd:安装 安装Apache httpd以配置Web服务器。
\[1\]安装Apache httpd。
``` [root@www ~]# dnf -y install httpd # rename or remove welcome page [root@www ~]# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.org ```
\[2\]配置httpd。将服务器名称替换为您自己的环境。
``` [root@www ~]# vi /etc/httpd/conf/httpd.conf # line 91 : change to admin's email address ServerAdmin root@srv.world # line 100 : change to your server's name ServerName www.srv.world:80 # line 149 : change (remove [Indexes]) Options FollowSymLinks # line 156 : change AllowOverride All # line 169 : add file name that it can access only with directory's name DirectoryIndex index.html index.php index.cgi # add follows to the end # server's response header ServerTokens Prod [root@www ~]# systemctl enable --now httpd ```
\[3\]如果防火墙正在运行,请允许HTTP服务。HTTP使用80/TCP。
``` [root@www ~]# firewall-cmd --add-service=http success [root@www ~]# firewall-cmd --runtime-to-permanent success ```
\[4\]创建HTML测试页面,并使用网页浏览器从任何客户端计算机访问它。如果显示以下页面,没关系。
``` [root@www ~]# vi /var/www/html/index.html
Test Page
```