window中安装Apache http server(httpd-2.4.58-win64-VS17)

windows中安装Apache http server(httpd-2.4.58-win64-VS17)

1、下载windows版本的的httpd,

https://httpd.apache.org/docs/current/platform/windows.html#down

这里选择的是Apache Lounge编译的版本

https://www.apachelounge.com/download/
2、解压到指定目录,这里解压到D盘根目录,得到D:\Apache24
3、修改配置文件http.conf

bash 复制代码
# 服务的根目录(根据实际情况修改)
Define SRVROOT "D:/Apache24"
# 需要监听的端口(根据需要修改)
Listen 80

4、修改之后,检测配置文件是否有语法错误

bash 复制代码
# 检测配置文件语法是否有错误
httpd.exe -t

语法OK,至于ServerName的问题可以暂时不处理。
6、注册服务,根据命令提示注册windows服务

bash 复制代码
# 注册服务,默认服务名为Apache2.4
httpd.exe -k install
# 卸载服务,默认卸载服务名为Apache2.4
httpd.exe -k uninstall

# 注册服务,指定服务名
httpd.exe -k install -n Httpd2.4
# 卸载服务,指定服务名
httpd.exe -k uninstall -n Httpd2.4

7、启动服务

使用命令启动服务,或者打开服务管理窗口启动服务

bash 复制代码
# 使用net命令启动服务
net start Apache2.4

8、使用浏览器,查看

It works!

表示服务安装、运行正常。
9、部署前端项目、设置vhosts,编辑conf\extra\httpd-vhosts.conf。根据项目需要设置自己的VirtualHost。

bash 复制代码
<VirtualHost *:80>
    DocumentRoot D:/Apache24/dist
    ServerName 192.168.0.44
    <Directory D:/Apache24/dist>
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . index.html [L]
        SetOutputFilter DEFLATE
        Options FollowSymLinks
        AllowOverride All
        Require all granted
        DirectoryIndex index.php index.html index.htm default.php default.html default.htm
    </Directory>
    ProxyRequests off
    ProxyPass /prod-api http://192.168.0.44:8097
    ProxyPassReverse /prod-api http://192.168.0.44:8097
</VirtualHost>
bash 复制代码
# 在主配置文件httpd.conf中把引入httpd-vhosts.conf文件的注释去掉
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

10、处理异常问题

此时重启服务,发现服务是无法启动的,我们再使用httpd.exe -t,检测一下配置文件,根据提示解决问题
①RewriteEngine on,开启了重写引擎,需要引入相关模块

在主配置文件httpd.conf中搜索关键词,把重写模块引入进来

bash 复制代码
# 把注释去掉
LoadModule rewrite_module modules/mod_rewrite.so

②vhost中使用了反向代理,需要把代理模块引入进来

在主配置文件httpd.conf中引入代理请求模块

bash 复制代码
# 把注释去掉
LoadModule proxy_module modules/mod_proxy.so
# 引入上述两个模块后,服务可以正常启动了,但是仍不能完成代理请求工作,项目是http请求,所以还需要把http这个子模块引入进来
LoadModule proxy_http_module modules/mod_proxy_http.so

11、访问项目,查看运行情况。
12、隐藏Httpd版本信息和操作系统信息

可以在\conf\extra中新建一个httpd-servertokens.conf配置文件,从httpd-default.conf中把ServerTokens的信息复制过来。

并修改为ServerTokens Prod。之后在主配置文件中引入该文件,并重启服务。

bash 复制代码
#
# ServerTokens
# This directive configures what you return as the Server HTTP response
# Header. The default is 'Full' which sends information about the OS-Type
# and compiled in modules.
# Set to one of:  Full | OS | Minor | Minimal | Major | Prod
# where Full conveys the most information, and Prod the least.
#
ServerTokens Prod
bash 复制代码
# ServerTokens 
Include conf/extra/httpd-servertokens.conf

小尾巴~~

只要有积累,就会有进步

相关推荐
哆啦code梦4 分钟前
Kong vs Nginx:微服务网关选型指南
nginx·kong·微服务网关
Aloudata2 小时前
数据治理选型对比:Apache Atlas vs 商业平台在存储过程解析与自动化治理的实测分析
数据挖掘·自动化·apache·元数据·数据血缘
Fᴏʀ ʏ꯭ᴏ꯭ᴜ꯭.2 小时前
Nginx性能调优与压测实战指南
运维·nginx
世界尽头与你3 小时前
CVE-2017-5645_ Apache Log4j Server 反序列化命令执行漏洞
网络安全·渗透测试·log4j·apache
岁岁种桃花儿3 小时前
流量入口Nginx动态发现K8s Ingress Controller实操指南
nginx·架构·kubernetes
迎仔3 小时前
03-Apache Tez 通俗指南:MapReduce 的“高速公路”升级包
大数据·apache·mapreduce
世界尽头与你3 小时前
CVE-2025-55752_ Apache Tomcat 安全漏洞
java·安全·网络安全·渗透测试·tomcat·apache
HMX4043 小时前
【春秋云境】CVE-2025-44137 TileServer PHP v2.0任意文件读取漏洞
apache·安全漏洞·漏洞复测
mqiqe3 小时前
springboot tomcat 嵌入式 解决Slow HTTP DOS问题解决
spring boot·http·tomcat
迎仔3 小时前
08-Apache Iceberg 通俗指南:给“胡乱堆放”的文件加个“智能账本”
apache·iceberg