当前位置:网站首页>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
边栏推荐
- Reading is the cheapest and noblest
- Vest bag access process record
- QT基础第四天(4)qt事件机制:事件基础概念,常见事件机制,事件处理以及事件的重写
- How to check the WeChat applet server domain name and modify it
- Getting Started with MySQL Syntax
- 中科驭数等单位牵头发布行业首部DPU评测方法技术白皮书
- TMS320C6678开发板( DSP+Zynq )RTOS综合功能案例,嵌入式必看!
- Mechanical keyboard failure
- MySQL的简单运用-where、update、delete、like、union
- 系统存储的基本管理--挂载,分区,用户配额
猜你喜欢
随机推荐
【Untitled】
Typora永久使用,彻底解决This beta version of Typora is expired.
c语言实现三子棋
vite.config.ts introduces the `path` module Note!
Go-6-常用命令-go包管理问题-两个路径-GO111MODULE
Servlet基础详解
VPP snort插件
PAT Class A 1019 Common Palindrome Numbers
Qt | 信号和槽的一些总结
统计二进制中1的个数,两个int(32位)整数m和n的二进制表达中,有多少个位(bit)不同?
CNN flower classification
2022年低压电工考试试题及在线模拟考试
Brute-force cracking of the latest JVM interview questions of Meituan: unlimited execution
MySQL 高级(进阶) SQL 语句 (一)
并发模型和I/O模型介绍
入门关于 switch case 的理解
华为研究院19级研究员几年心得,终成趣谈网络协议文档,附大牛讲解
622. 设计循环队列 : 数组模拟循环队列
MySQL 视图(详解)
树状DP(记忆化搜索)PAT甲级 1079 1090 1106








