阿帕奇
一:配置环境
1.配置主机名
2.安装软件包 yum install httpd.x86_64 -y
3.给火墙加服务
firewall-cmd --permanent --add-service
firewall-cmd --reload
firewall-cmd --list-all 显示火墙的所有服务
4.systemctl start httpd 开启此服务
systemctl enable httpd 开机自启动
二:阿帕奇访问的默认地址是: /var/www/html/index.html index.html 不存在时,可访问其他新建立的文件,需要在主配置文件中做改动。访问的默认端口是80端口。
三:
1.改变默认端口
访问主配置文件 vim /etc/httpd.conf
修改 Listen:80 为 8080 即改变默认端口
重启服务 systemctl restart httpd
firewall-cmd --permanent --add-por=8080/tcp
更新
则在访问默认文件时后面不用加/8080 也可以访问到
2.修改默认地址
在主配置文件中添加
DirectoryIndex index.html westos(需要在html下自己新建)
重启服务
即访问时加上/westos可以看到westos中的文件,当删除index.html时就可以不用加,westos 变为默认地址
3.修改默认目录
在主配置文件中添加
Document Root "/www/html"
<Directory "/www">
Require all granted
</Directory> (可从底部复制)
重启服务
修改selinux
semanage fcontext -a -t httpd_sys_content_t '/www(/.*)?'
restorecon -RvvF /www/
默认目录已改变