部署環境如下:
系統:CentOS7.6
IP:192.168.121.105
Server version: 2.4.6
1.安裝 apache,並設置 apache 服務啟動和下次開機啟動
[root@centos7 ~]# yum -y install httpd
[root@centos7 ~]# systemctl enable httpd --now
2.安裝成功后切換目錄,編輯 index.html 文件
[root@centos7 ~]# cd /var/www/html/
[root@centos7 html]# vim index.html
3.重啟 apache 服務,關閉防火牆
[root@centos7 ~]# systemctl restart httpd
[root@centos7 ~]# systemctl stop firewalld
[root@centos7 ~]# systemctl disable firewalld
或者在不關閉防火牆的前提下放行 apache 服務和 80 端口( --per 為 --permanent )
[root@centos-server ~]# firewall-cmd --add-service=http
[root@centos-server ~]# firewall-cmd --add-service=http --per
[root@centos-server ~]# firewall-cmd --add-port=80/tcp
[root@centos-server ~]# firewall-cmd --add-port=80/tcp --per
4.查看 apache 狀態和 80 端口是否被占用
[root@centos7 ~]# ps -ef | grep httpd
[root@centos7 ~]# ss -tunlp | grep 80
5.使用 IP 瀏覽網頁