阿帕奇服务1

阿帕奇服务
##启动安帕奇服务##
yum install httpd -y ##安装服务##
yum install htppd-manual ##安装服务手册##
systemctl start httpd ##开启服务##
systemctl enable httpd ##开机自启##
firewall-cmd --permanent --add-service=http ##防火墙设置http服务##
firewall-cmd --reload ##防火墙重新载入##
在浏览器中输入地址测试阿帕奇服务

在这里插入图片描述

/var/www/html 为阿帕奇服务的默认发布目录
cd /var/www/html
vim index.html ##编写默认发布目录##

在这里插入图片描述

打开浏览器输入ip测试

在这里插入图片描述

阿帕奇的基础信息

在这里插入图片描述

vim test.html (写入test’s page)
vim /etc/httpd/conf/httpd.conf ##通过编辑主配置文件来改变主页面##

在这里插入图片描述

systemctl restart httpd

测试

在这里插入图片描述
rm -fr test.html ##删除此发布页面##
mkdir -p /westos/html
vim /etc/httpd/conf/httpd.conf ##修改默认发布目录##

在这里插入图片描述

cd /westos/html/
vim index.html ##编写发布页面##
vim/etc/httpd/conf/httpd.conf

在这里插入图片描述

systemctl restart httpd

在这里插入图片描述

注意:此时selinux状态为disabled,如果状态不是disabled,则需要修改安全上下文
semanage fcontext -a -t httpd_sys_content_t ‘/westos(/.*)?’
restorecon -FvvR /westos/ ##修改安全上下文##

##修改默认服务端口##
在浏览器访问时,http服务的默认端口为80
vim /httpd/conf/httpd.conf

在这里插入图片描述

修改默认端口为8080
netstat -antlupe | grep httpd ##查看服务端口的变化##
firewall-cmd --permanent --add-port=8080/tcp ##添加8080端口到防火墙策略##
firewall-cmd --reload
systemctl restart httpd
此时在浏览器内输入ip显示无法访问,但是在ip后面加上8080就可以访问了

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43478840/article/details/84100363