使用Apache搭建Web网站服务器
Apache服务
Apache被研发于1995年,是纯开源软件。用于HTTP协议提供web浏览服务,可在Unix、Linux、Windows上运行。
1、配置静态IP
vim /etc/sysconfig/network-scripts/ifcfg-ens33
2、关闭防火墙或者安全模块
systemctl disable firewalld #永久关闭防火墙
systemctl stop firewalld #暂时关闭防火墙,重启虚拟机时防火墙会重新开启
systemctl status firewalld #查看防火墙状态
vim /etc/selinux/config #enforcing改为disabled,永久关闭安全模块
3、Apache安装:
方法一:
编译安装:RPM
方法二:
配置yum源进行yum安装:
yum -y install httpd #安装httpd
rpm -ql httpd | less #查看安装文件的所有
4、httpd软件的配置
vim /etc/httpd/conf/httpd.conf #无需修改
:q #浏览完退出编译模式
Apache配置文件:
ServerRoot "/etc/httpd" #httpd服务的安装目录
Listen 80 #默认监听TCP协议80端口
Include conf.modules.d/*.conf #定义模板文件
User apache #定义服务运行用户
Group apache #定义服务运行组
ServerAdmin root@localhost #定义服务管理员
<Directory /> #定义服务根目录的访问权限
AllowOverride none #网站重写功能
Require all denied #定义为拒绝访问
</Directory>
DocumentRoot "/var/www/html" #定义网站根目录【文档】根目录
<Directory "/var/www"> #定义网站根目录的权限
AllowOverride None
Require all granted #定义允许所有用户访问
</Directory>
<Directory "/var/www/html"