1. yum -y install httpd
2. 編輯配置文件:
vi /etc/httpd/conf/httpd.conf
修改80主機的根目錄為: /home/repo/yum/centos-release
同時開啟目錄瀏覽:
DocumentRoot "/home/repo/yum/centos-release" <Directory "/home/repo/yum/centos-release"> Options Indexes FollowSymLinks Order allow,deny Allow from all AllowOverride None Require all granted IndexOptions Charset=UTF-8 IndexOptions NameWidth=* </Directory>
3. 設置目錄權限:
vi /etc/selinux/config # 關閉selinux, 把 SELINUX=enforcing 修改 SELINUX=disable setenforce 0 # 使得selinux立即關閉 chown apache:apache /home/repo/yum/centos-release/ # 設置目錄權限,避免無法瀏覽索引
4. 啟動服務:
service httpd start
service firewalld stop # 停止防火牆
systemctl disable firewalld # 禁用防火牆
systemctl enable httpd # 設置開啟自啟動
嘗試通過 http://ip地址/ 訪問, 我這里訪問 http://192.168.88.118/7/
5. 關於錯誤調試,記得打開錯誤日志查看即可: tailf /etc/httpd/logs/error_log
所有相關錯誤,都可以通過百度找到答案。