1. 程式人生 > >Linux - apache 服務

Linux - apache 服務

firewalld 配置 分享 修改 png 分享圖片 htm sta install

暫時關閉 iptables 防火墻

[root@sch01ar ~]# systemctl stop iptables.service

暫時關閉 firewall 防火墻

[root@sch01ar ~]# systemctl stop firewalld

暫時關閉 selinux

[root@sch01ar ~]# setenforce 0

安裝軟件包

[root@sch01ar ~]# yum install httpd -y

查看配置文件

[root@sch01ar ~]# vim /etc/httpd/conf/httpd.conf

技術分享圖片

ServerRoot 為配置文件根目錄

技術分享圖片

Listen 為 apache 服務監聽的端口

技術分享圖片

Include 為包含的配置文件

技術分享圖片

DocumentRoot 為網站根目錄

技術分享圖片

Errorlog 為錯誤日誌,LogLevel 為錯誤級別

重啟 apache 服務

[root@sch01ar ~]# systemctl restart httpd.service

查看 ip 地址

技術分享圖片

在網站根目錄 /var/www/html 下創建一個 index.html 內容為 test

訪問

技術分享圖片

修改主機信息

[root@sch01ar html]# vim /etc/hosts

添加一條記錄

技術分享圖片

添加上這一條

訪問該域名就會訪問該 ip 地址

因為沒有解析,所以只能本機訪問該域名

技術分享圖片

Linux - apache 服務