当前位置:网站首页>Apache management and web optimization
Apache management and web optimization
2022-08-02 17:36:00 【linyxg】
Apache服务
- 安装Apache服务:dnf install httpd.x86_64
安装Apache加密插件:dnf install mod_ssl -y - 启用Apache服务
Start the service and set the service to start automatically at boot:systemctl enable --now httpd
在火墙中永久开启https访问:firewall-cmd --permanent --add-service=https
在火墙中永久开启http访问:firewall-cmd --permanent --add-service=http
刷新火墙,让设定生效:firewall-cmd --reload - 查看火墙信息:firewall-cmd --list-all
Apachedefault setting information
- 服务名称: httpd
- 默认端口:http ----> 80 ; https ----> 443
- 日志目录:/etc/httpd/logs
- 默认发布目录:/var/www/html/
- 默认发布文件:index.html (Must be in the default publish directory)
- Apache主配置文件 : /etc/httpd/conf/httpd.conf
- Apache子配置文件 : /etc/httpd/conf.d/*.conf
修改Apache的基本配置
Change the base port
编辑主配置文件 :vim /etc/httpd/conf/httpd.conf (改为8080)
重启服务:systemctl restart httpd
关闭selinux服务: vim /etc/sysconfig/selinux
Modify firewall settings,增加8080端口:firewall-cmd --add-port=8080/tcp (防火墙默认80)
查看火墙信息:firewall-cmd --list-all
查看端口信息:netstat -antlupe | grep httpd
访问网址:172.25.254.110:8080更改Apache默认发布文件
设置westos文件为Apache默认发布目录
修改主配置文件 vim /etc/httpd/conf/httpd.conf
修改内容如下:(There are two publish files by default)
重启服务:systemctl restart httpd
访问网址:172.25.254.110更改Apache默认发布目录
新建目录:mkdir /var/www/westos
编辑文件:vim /var/www/westos/index.html
编辑主配置文件 vim /etc/httpd/conf/httpd.conf
重启服务:systemctl restart httpd
修改内容:
访问:172.25.254.210
Apache的访问控制
基于ip
Create a new subdirectory of the default publish directory:mkdir /var/www/html/Apacheip/
Create and edit a release file:vim /var/www/html/Apacheip/index.html
编辑主配置文件 vim /etc/httpd/conf/httpd.conf
重启服务: systemctl restart httpd
Main config file additions:
allow 和deny的读取顺序 ---->Agree and then reject
allow 和deny的读取顺序 ---->Reject and then agree
访问:172.25.254.40/Apacheip/基于用户(Enter the password to log in once and you will not need it next time)
建立用户认证文件:htpasswd -cm /etc/httpd/.htpasswd admin(Can be created to any directory )
Establish user authentication again:htpasswd -m /etc/httpd/.htpasswd lyx
编辑主配置文件 vim /etc/httpd/conf/httpd.conf
重启服务: systemctl restart httpd
Main config file additions:
访问:172.25.254.40/Apacheip/
ApacheVirtual host construction
- 可以使一台ApachePublish multiple pages at the same time
Build a test page
新建westos.orgdirectory and three subdirectories:mkdir -p /var/www/westos.org/{linux,shell,python}
Generate and write content toliunx的发布文件 :echo linux.westos.org >/var/www/westos.org/linux/index.html
Generate and write content toshell的发布文件: echo shell.westos.org >/var/www/westos.org/shell/index.html
Generate and write content topython的发布文件:echo python.westos.org >/var/www/westos.org/python/index.htmlWrite local parsing (Write in the host of the page you want to browse )
Write a local parsing file:vim /etc/hosts
Local parsing adds content:编辑Apache的子配置文件
进入Apachesub-configuration directory:cd /etc/httpd/conf.d
Specify a sub-configuration file and write the contents:vim vhost.conf (文件名必须以.conf结尾)
Subconfiguration file additions:重启服务: systemctl restart httpd
- 重启Apache服务不成功,Check the error cause method:
清空日志文件:>/var/log/messages
重新运行命令:systemctl restart httpd
查看日志信息:cat /var/log/messages
或查看httpd日志:ls /etc/httpd/logs/
Apache的语言支持
- 安装Apache的帮助文档:dnf install httpd-manual -y
- 访问帮助文档:http://172.25.254.40/manual/
- php语言
安装php:dnf install php -y
编辑php页面内容:vim /var/www/html/index.php
重启服务: systemctl restart httpd
访问网址:http://172.25.254.40/index.php
- cgi (通用网关接口 —> c++ )
- ApacheOnly static pages can be published,所以通过cgi执行脚本,输出静态text,Apache 再执行
Publish the contents of the file:
ApacheContents of sub-configuration files under sub-configuration directories:
- wsgi
安装:dnf install python3-mod_wsgi.x86_64 -y
发布目录:mkdir /var/www/html/wsgi
发布文件:vim /var/www/html/wsgi/index.wsgi
赋予执行的权限:chmod +x index.wsgi
编写子配置文件:vim /etc/httpd/conf.d/vhost.conf
本地解析文件:vim /etc/hosts
重启服务: systemctl restart httpd
边栏推荐
- 太香了!阿里Redis速成笔记,从头到尾全是精华!
- PAT serie a 1137 final grades
- SSRF(服务器端请求伪造)
- BSC链智能合约模式系统开发功能逻辑分析
- A status code, and access baidu process
- 【学习笔记之菜Dog学C】自定义类型详解(结构体+枚举+联合)
- 树状DP(记忆化搜索)PAT甲级 1079 1090 1106
- 【 Leetcode string, the string transform/hexadecimal conversion 】 HJ1. The length of the string last word HJ2. Calculation of a certain number of characters appear HJ30. String merging processing
- PAT Class A 1130 Infix Expressions
- 【无标题】
猜你喜欢
随机推荐
How to check the WeChat applet server domain name and modify it
已经2022下半年了,居然还在说链动2+1!
5000mAh大电池!华为全新鸿蒙手机今晚亮相:更流畅更安全
PAT tree DP (memory search) class a, 1079, 1090, 1106
622. 设计循环队列 : 数组模拟循环队列
phpstudy实现命令行操作
继续来学习有关淘宝的API接口的使用——获得店铺的所有商品 API
【无标题】
看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!
go——协程调度
Qt | QWidget 的一些总结
PAT甲级 1019 普通回文数
Apache的管理及web优化
【Untitled】
HDU1561 树形背包dp+边界优化 0ms过题
Vest bag access process record
状态码以及访问百度过程
Servlet基础详解
Mechanical keyboard failure
软件成分分析:华为云重磅发布开源软件治理服务