当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Servlet运行原理_API详解_请求响应构造进阶之路(Servlet_2)
Qt | 信号和槽的一些总结
软件成分分析:华为云重磅发布开源软件治理服务
多线程------实际篇
《数字经济全景白皮书》银行业智能风控科技应用专题分析 发布
PAT Grade A 1143 Lowest Common Ancestor
Qt | 通过创建一个简单项目了解 Qt Creator
Basic management of system storage -- mounts, partitions, user quotas
PAT tree DP (memory search) class a, 1079, 1090, 1106
华为研究院19级研究员几年心得,终成趣谈网络协议文档,附大牛讲解
PostGresql listen与notify命令
redis学习四redis消息订阅、pipeline、事务、modules、布隆过滤器、缓存LRU
mysql 自动添加创建时间、更新时间
Eight big software attack overview of supply chain
H5中的拖放(Drag 和 Drop)
如何用JDBC操作Mysql
Apache APISIX 2.15 版本发布,为插件增加更多灵活性
SOA(面向服务架构)是什么?
UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 178: illegal multibyte s
Traverse Heap PAT Class A 1155 Heap Path