Apache的管理及优化

1.Apache的作用

在web被访问时通常使用http://的方式
http://                             ##超文本传输协议

http:// 超文本传输协议提供软件

Apache  nginx  stgw  jfe  Tengine

2.Apache的安装

dnf install httpd.x86_64 -y

3.Apache的启用

systemctl enable --now httpd      ##开启服务并设定服务位开机启动
firewall-cmd --list-all      ##查看火墙信息
firewall-cmd --permanent --add-service=http      ##在火墙中永久开启http访问
firewall-cmd --permanent --add-service=https   ##在火墙中永久开启https访问
firewall-cmd --reload      ##刷新火墙使设定生效

 4.Apache的基本信息
服务名称:httpd
配置文件:          /etc/httpd/conf/httpd.conf       ##主配置文件
                           /etc/httpd/conf.d/*.conf           ##子配置文件
默认发布目录:  /var/www/html
默认发布文件:  index.html
默认端口:80      #http
                           443        #https
用户:    apache
日志:    /etc/httpd/logs

5.Apache的基本配置

下载安装
[root@westoslinux174 ~]# dnf install httpd -y  安装Apache
[[root@westoslinux174 ~]# systemctl enable --now httpd   开启服务并设定服务开机启动
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@westoslinux174 ~]# firewall-cmd --permanent --add-service=http 在火墙中永久开启http访问
success
[root@westoslinux174 ~]# firewall-cmd --reload  刷新火墙使设定生效
success
[root@westoslinux174 ~]# vim /var/www/html/index.html
<h1>hello westos</h1>


浏览器查看172.25.254.174     【hello westos】

端口更改

[root@westoslinux174 ~]vim /etc/httpd/conf/httpd.conf
Listen 8080


[root@westoslinux174 ~]systemctl restart httpd
[root@westoslinux174 ~]# netstat -antlupe | grep http
tcp6       0      0 :::8080                 :::*                    LISTEN      0          87524      4864/httpd          
浏览器172.25.254.174:8080  失败


[root@westoslinux174 ~]firewall-cmd --permanent --add-port=8080/tcp
[root@westoslinux174 ~]firewall-cmd  --reload
浏览器172.25.254.174:8080  成功


[root@westoslinux174 ~]vim /etc/httpd/conf/httpd.conf  恢复80


[root@westoslinux174 ~]systemctl restart httpd
浏览器查看 172.25.254.174 成功

默认发布文件
[root@westoslinux174 ~]# cd /var/www/html/
[root@westoslinux174 html]# ls
index.html
[root@westoslinux174 html]# vim test.html


<h1>hello test</h1>
[root@westoslinux174 html]# cat test.html
hello test
浏览器查看 172.25.254.174/test.html  【hello test】


[root@westoslinux174 ~]vim /etc/httpd/conf/httpd.conf
<IfModule dir_module>
    DirectoryIndex test.html index.html  按顺序查看
</IfModule>


[root@westoslinux174 ~]systemctl restart httpd
浏览器查看 172.25.254.174 成功 【hello test】


[root@westoslinux174 ~]rm -fr test.html
浏览器查看 172.25.254.174  【hello westos】

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值