为了日后便于查询,本文所涉及到的所有命令集合如下:
chkconfig iptables off ?#关闭防火墙命令 ?在Centos7中使用的是chkconfig firewalld offvi /etc/sysconfig/selinux ?#打开selinux配置文件yum install httpd -y ?#安装httpd软件vi /etc/httpd/conf/httpd.conf #配置httpd文件service httpd restart ???#重启httpd服务
什么是apache服务?
apache服务就是用来部署网站的服务。其对应的软件名就httpd。
开启apache服务
1.准备环境
- 永久关闭防火墙
chkconfig iptables off ?#关闭防火墙命令 ?在Centos7中使用的是chkconfig firewalld off
- 关闭selinux
vi /etc/sysconfig/selinux ?#打开selinux配置文件
打开selinux配置文件,其中的SELINUX选项改为disabled
- 配置IP地址
2.进行httpd软件的安装
使用命令
yum install httpd -y ?#安装httpd软件
进行httpd软件的安装
3.修改配置文件
使用命令
vi /etc/httpd/conf/httpd.conf
其中比较关键的配置项有以下几个
- Listen 80 说明监听端口为80
DocumentRoot "/var/www/html" 文档根目录
4.重启服务
使用命令
service httpd restart
进行apache服务的重启生效操作
5.测试
在DocumentRoot目录也就是 /var/www/html新建一个文件
使用以下命令随便创建一个文件
cd /var/www/html/ ?#进入文档根目录touch hello.txt ????#创建文件echo "hello world" > hello.txt ???#在文件中写入内容 ???
回到windows中打开浏览器输入ip/文件正常访问,如果无法访问请再次检查防火墙
关于apache的知识就讲到这里,感谢各位看官
如何搭建apache服务?
原文地址:https://www.cnblogs.com/codescrew/p/8605691.html