surroundings
centOS7+httpd
Install httpd
installation
1 # check whether the installation and httpd
2 RPM -qa | grep httpd
3 # If you do not install
4 yum -y install httpd
Start httpd and verification
service httpd start
service httpd status
Then access linux host IP in the browser can see the following page explains the successful launch
Modify httpd.conf
yum installation path generally /etc/httpd/conf/httpd.conf, custom installation may look with find / -name httpd.conf. Edit the configuration file or use the default paths are possible:
- Default path: ServerRoot and do not modify the Directory, copy the contents directly to the folder to the default path / var / www / html;
cp /etc/httpd/conf/httpd.conf / was / www / html
Published default directory:
/ Var / www / html
If the / var directory not under / www / html two folders, you can create your own
Default publish files:
/var/www/html/test.html ## need to establish their own
Copy a static file to the directory / var / www / html
There are two files in the html folder: the httpd.conf, test.html
(rlcVenv) [root@67 logicCheck]# cp test.html /var/www/html
(rlcVenv) [root@67 logicCheck]# cd /var/www/html
(rlcVenv) [root@67 html]# ls
httpd.conf test.html
重启httpd
1 service httpd restart
访问 :
http://10.2.1.92/test.html
遇到的问题:
403:没有权限访问test.html
分析:这只少证明是可以访问到test.html资源的,只是没有权限打不开,所以这里修改html文件夹的权限为所有人可读
修改html文件夹权限
(rlcVenv) [root@67 www]# sudo chmod 777 html -R
修改后可以看到html文件夹变成绿色,表示所有人可读 可写了
刷新页面,OK 成功啦 ~!
检查
重新访问ip,如果返回403
,有几种可能:
- 文件夹权限
ServerRoot
下没有index.html
SELinux
为开启状态(禁用SELinux)
最后一种情况居多。
参照:多谢大佬
Linux环境使用Apache部署静态html页面(主要看这1篇就可以了)
https://blog.csdn.net/CL_YD/article/details/84568828