当前位置 博文首页 > m0_53521757的博客:Linux(CentOS7)之Apache服务器配置
1.镜像文件挂载,参考链接https://blog.csdn.net/m0_53521757/article/details/112536969
[root@localhost ~]# mkdir /c1
[root@localhost ~]# mount -r /dev/sr0 /c1
[root@localhost ~]# df
2.安装 Apache服务程序
[root@localhost ~]# yum -y install httpd
3.启动Apache服务程序并设置为开机启动
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
4.建立网站数据目录
[root@localhost ~]# mkdir /home/wwwroot
5.创建首页文件
默认的网站数据是存放在/var/www/html目录中的,首页名称是index html
[root@localhost ~]# echo Hello CSDN >> /home/wwwroot/index.html
6.编辑Apache服务程序的主配置文件
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
7.重新启动Apache服务
[root@localhost ~]# systemctl restart httpd.service
8.关闭Selinux ,不然会显示默认主页
[root@localhost ~]# setenforce 0
9.打开浏览器
[root@localhost ~]# firefox 127.0.0.1 &
完整代码:
[root@localhost ~]# mkdir /c1
[root@localhost ~]# mount -r /dev/sr0 /c1
[root@localhost ~]# df
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
[root@localhost ~]# mkdir /home/wwwroot
[root@localhost ~]# echo Hello CSDN >> /home/wwwroot/index.html
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
[root@localhost ~]# systemctl restart httpd.service
[root@localhost ~]# setenforce 0
[root@localhost ~]# firefox 127.0.0.1 &
今天的分享就到这里,大家有什么问题可以直接私信或者评论,博主肯定会回复的。希望大家指出我的不足之处,我们一起努力。创作不易,希望大家给个赞。
cs