Windows运维_Windows下配置Apache-Haus(Apache2.4)

news/2024/4/29 9:01:44/文章来源:https://blog.csdn.net/goufeng93/article/details/137022565

Windows运维_Windows下配置Apache-Haus(Apache2.4)

Apache Haus 是一个由网站管理员, 开发人员和爱好者组成的社区, 他们更喜欢使用 Apache Web 服务器而不是 IIS。

无论是出于商业还是娱乐目的, Apache 在 Windows 上的使用正在稳步增加, 我们希望通过为人们提供一个可以获得帮助并分享他们在 Windows 上使用 Apache 的经验的地方, 看到这一趋势继续下去。

我们的论坛为人们提供了一个会面, 提问或分享有关 Apache 安装和操作知识的场所, 并帮助他们了解最新技术。

请注意, Apache Haus 不隶属于 Apache 软件基金会, 不受其认可。Apache HTTP Server, Apache 和 Apache 羽毛徽标是 Apache 软件基金会的商标。

The Apache Haus is a community of webmasters, developers and hobbyists who prefer using the Apache Web Server over IIS.

Whether for business or pleasure, the use of Apache on Windows is steadily gaining and we hope to see the trend continue by offering people a place to come where they can get help and share their experiences using Apache on Windows.

Our forums provide the place for people to meet and ask questions or share their knowledge concerning the installation and operation of Apache, as well as helping them keep up to date with the latest technologies.

Please note that the Apache Haus is not affiliated with, or endorsed by, the Apache Software Foundation. The Apache HTTP Server, Apache, and the Apache feather logo are trademarks of The Apache Software Foundation.

Server powered by: Finetworks Ay

  • 由以上 Apache Haus 的申明可知, Apache HTTP Server 官方不提供二进制 (可执行) 的发行版, 所以我们只能选择一些贡献者编译完成的版本, 这里我们当然选择了 Apache Haus。

  • 在 Apache Haus 下载页面 (https://www.apachehaus.com/) 下载 Apache 2.4 Server Binaries (Windows 需要安装对应的 VC 环境)。

Apache Haus 配置 1 - httpd.conf

  • 设置 Apache 目录, 即 ServerRoot 选项, 将其改成你的 Apache 程序的文件夹。

    如果存在 Define SRVROOT “[ApachePath]”, 则修改此处的 [ApachePath]。

    如果只有 ServerRoot “[ApachePath]”, 则修改此处的 [ApachePath]。

    如果既存在 Define SRVROOT, 也存在 ServerRoot “${SRVROOT}”, 则只需要修改 Define SRVROOT “[ApachePath]” 中的 [ApachePath]。

    当然也可以直接修改 ServerRoot “[ApachePath]” 中的 [ApachePath], 只不过灵活性要差一些。

    修改示例:

    Define SRVROOT "D:\Program\Apache24"
    ServerRoot "${SRVROOT}"
    
  • 设置 Apache 服务监听的端口, 即 Listen 选项, 一般不修改, 使用默认 80, 在开启服务器前请保证 80 端口未被占用。

    修改示例:

    Listen 80
    
  • 设置 Apache 服务根目录, 即 DocumentRoot 选项, 是存放 .html 文件的目录, 用户输入 IP地址 + 端口号 (如: 12.34.56.78:80) 能够访问到的目录。

    请保证 DocumentRoot 所设置的目录存在, 否则服务器无法正常启动。

    同时也需要修改随后的 … XML标签中的路径属性, 保证其与服务器根目录相同。

    修改示例:

    DocumentRoot "D:\Program\Apache24\htdocs"
    <Directory "D:\Program\Apache24\htdocs">## Possible values for the Options directive are "None", "All",# or any combination of:#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews## Note that "MultiViews" must be named *explicitly* --- "Options All"# doesn't give it to you.## The Options directive is both complicated and important.  Please see# http://httpd.apache.org/docs/2.4/mod/core.html#options# for more information.#Options Indexes FollowSymLinks## AllowOverride controls what directives may be placed in .htaccess files.# It can be "All", "None", or any combination of the keywords:#   Options FileInfo AuthConfig Limit#AllowOverride None## Controls who can get stuff from this server.#Require all granted
    </Directory>
    
  • 设置 Apache 的 cgi-bin 路径, 即 ScriptAlias /cgi-bin/ 选项, 通常将其设置为 Apache 目录下的 cgi-bin 文件夹。

    需同时要找到随后的 … XML标签, 设置脚本目录, 需要将其设置为和前面的 ScriptAlias /cgi-bin/ 所指定的目录相同。

    修改示例:

    <IfModule alias_module>## Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location.# Example:# Redirect permanent /foo http://www.example.com/bar## Alias: Maps web paths into filesystem paths and is used to# access content that does not live under the DocumentRoot.# Example:# Alias /webpath /full/filesystem/path## If you include a trailing / on /webpath then the server will# require it to be present in the URL.  You will also likely# need to provide a <Directory> section to allow access to# the filesystem path.## ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that# documents in the target directory are treated as applications and# run by the server when requested rather than as documents sent to the# client.  The same rules about trailing "/" apply to ScriptAlias# directives as to Alias.#ScriptAlias /cgi-bin/ "D:\Program\Apache24\cgi-bin\"</IfModule><IfModule cgid_module>## ScriptSock: On threaded servers, designate the path to the UNIX# socket used to communicate with the CGI daemon of mod_cgid.##Scriptsock logs/cgisock
    </IfModule>#
    # "${SRVROOT}/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    #
    <Directory "D:\Program\Apache24\cgi-bin">AllowOverride NoneOptions NoneRequire all granted
    </Directory>
    

Apache Haus 配置 2 - 尝试启动 Apache 服务

  • 配置环境变量: 右键点击 “计算机” -> 属性 -> 高级系统设置 -> 环境变量 -> 编辑 Path -> 新建 -> 添加 “D:\Program\Apache24\bin” 路径

  • 测试环境变量: Win 键 + r 打开 “运行” -> 输入 cmd 打开 Windows 终端 -> 输入 httpd -v 显示 Apache 版本号

  • (如果之前安装并使用过 Nginx, 需要先清除浏览器缓存)

  • 安装 Apache 服务: 以管理员的身份再次打开 Windows 终端, 输入 httpd -k install 安装 Apache 服务 (未安装 Apache 服务可能无法启动 Apache 服务)。

  • 启动 Apache 服务 (方式 1): 打开 Windows 终端, 输入 httpd -k start 启动 Apache 服务。

  • 启动 Apache 服务 (方式 2): 打开 D:\Program\Apache24\bin 目录下的 ApacheMonitor.exe, 点击右边的 start 启动 Apache 服务。

    Windows 系统下 Apache 24.x 常见命令:

    httpd -k install      安装 Apache 服务
    httpd -k uninstall    移除 Apache 服务httpd -k start        启动 Apache 服务
    httpd -k restart      重启 Apache 服务
    httpd -k stop         关闭已安装的 Apache 服务httpd -v              查看 Apache 版本
    httpd -t              查看 Apache 配置文件状态
    
  • 错误处理: (OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 : AH00072: make_sock: could not bind to address [::]:443

    意思就是 443 端口号被占用了

    修改 1: 将 D:\Program\Apache24\conf\extra 中 httpd-ahssl.conf 的 Listen 443 https 修改为 Listen 442 https 或 Listen 444 https

    修改 2: 将 D:\Program\Apache24\conf\extra 中 httpd-ssl.conf 的 Listen 443 修改为 Listen 442 或 Listen 444

  • 错误处理: Windows不能在本地计算机启动Apache2.2。有关更多信息,查阅系统日志文件。如果这是非Microsoft服务,请与厂商联系,并参考特定服务器错误代码1。

    右键点击 “计算机” -> 事件查看器 -> Windows 日志 -> 应用程序 -> 查看对应时间出错的应用其 “常规” 或 “详细信息” 中的信息

    错误日志 1:The Apache service nnamed reported the following error:
    >>> Syntax error on line 133 of C:/Users/xyb-C308/Downloads/httpd-2.2.31-x86-r3/Apache22/conf/extra/httpd-ahssl.conf:.错误日志 2:The Apache service nnamed reported the following error:
    >>> SSLCertificateFile 'C:/Apache22/conf/ssl/server.crt' dose not exist or is empty.
    

    这是由于 SSL 配置不正确所产生的, 以下是解决办法。

    打开 D:\Program\Apache22\conf\extra\httpd-ahssl.conf 文件, 配置 VirtualHost 选项。

    注意: 可能不止一处名为 VirtualHost 的选项, 均需修改。

    将其中的 SSLCertificateFile 改为 D:/Program/Apache22/conf/ssl/server.crt

    将其中的 SSLCertificateKeyFile 改为 D:/Program/Apache22/conf/ssl/server.key

    将其中的 DocumentRoot 改为你的服务器根目录。

    ##
    ## SSL Virtual Host Context
    ##<VirtualHost _default_:443>SSLEngine onServerName localhost:443SSLCertificateFile "D:/Program/Apache22/conf/ssl/server.crt"SSLCertificateKeyFile "D:/Program/Apache22/conf/ssl/server.key"DocumentRoot "D:/Program/Apache22/htdocs"
    # DocumentRoot access handled globally in httpd.confCustomLog "${SRVROOT}/logs/ssl_request.log" \"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"<Directory "${SRVROOT}/htdocs">Options Indexes Includes FollowSymLinksAllowOverride AuthConfig Limit FileInfoRequire all granted</Directory>
    </virtualhost>
    

    将其中的 CustomLog 改为 D:/Program/Apache22/logs/ssl_request.log, 这个不改的话也会错, 通常会出现如下错误:

    错误日志:
    Apache2.2 服务由于下列服务特定错误而终止:
    函数不正确。
    

    这样, 错误就算处理完了, 如果还有问题, 可能还需配置 D:\Program\Apache22\conf\extra\httpd-ssl.conf, 配置方法和配置 httpd-ahssl.conf 的 VirtualHost 的相似。

Apache Haus 配置 3 - 启动 Apache 服务

  • 配置 Apache 服务 -> 安装 Apache 服务 -> 启动 Apache 服务

  • 整个流程下来没有错误, 或处理完所有错误后, 以后都按以下方式启动 Apache 服务即可。

    启动 Apache 服务 (方式 1): 打开 Windows 终端, 输入 httpd -k start 启动 Apache 服务。

    启动 Apache 服务 (方式 2): 打开 D:\Program\Apache24\bin 目录下的 ApacheMonitor.exe, 点击右边的 start 启动 Apache 服务。

  • 也可以显示启动过程中的日志, 便于分析错误。

    使用 httpd -w -n “Apache2” -k start 命令启动服务器

Apache Haus 配置 4 - 开机启动 Apache 服务

  • 右键点击 “计算机” -> 管理 -> 服务和应用程序 -> 服务 -> 找到 Apache2.4 -> 右键点击 “Apache2.4” -> 属性 -> 修改启动类型

    启动类型说明:

    自动: 开机自动启动

    手动: 每次手动启动

Apache Haus 可选配置 - 配置 PHP-7.x.x 支持

  • 下载 PHP-7.x.x。注意: 需要下载 “线程安全(THREAD SAFE)版”, 如果是 “非线程安全(NOT THREAD SAFE)版”, 则不包含 “php7apache2_4.dll” 库文件。

  • 修改 Apache Haus 的 httpd.conf 文件, 加载 PHP-7.x.x 的支持, 在 httpd.conf 文件末尾添加如下内容:

    # Load PHP7 Module for PHP7 Support.
    LoadModule php7_module D:\Program\PHP-7.4.28-TS-Win32-VC15-X64\php7apache2_4.dll# 将 PHP 配置文件加载到 Apache 配置文件中, 使其共同生效。
    PHPIniDir "D:\Program\PHP-7.4.28-TS-Win32-VC15-X64"
    
  • 修改 Apache Haus 的 httpd.conf 文件, 让 Apache 分配模块工作, 将含有 PHP 代码的 .php 文件分配给 PHP 模块处理, 在 httpd.conf 文件末尾添加如下内容:

    # 让 Apache 分配模块工作, 将含有 PHP 代码的 .php 文件分配给 PHP 模块处理。
    AddType application/x-httpd-php .php
    

    或者:

    # 让 Apache 分配模块工作, 将含有 PHP 代码的 .php 文件分配给 PHP 模块处理。
    <IfModule mod_php7.c>AddType application/x-httpd-php .php
    </IfModule>
    
  • 修改 Apache Haus 的 httpd.conf 文件, 让 Apache 解析 index.php 主页索引文件。

    找到以下内容:

    <IfModule dir_module>DirectoryIndex index.html
    </IfModule>
    

    将找到的 DirectoryIndex 参数末尾添加上 index.php 项目:

    <IfModule dir_module>DirectoryIndex index.html index.php
    </IfModule>
    
  • 重启 Apache 服务, 使 httpd.conf 配置生效。

    httpd -k restart
    

总结

以上就是关于 Windows运维 Windows下配置Apache-Haus(Apache2.4) 的全部内容。

更多内容可以访问我的代码仓库:

https://gitee.com/goufeng928/public

https://github.com/goufeng928/public

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_1027844.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux的学习之路:3、基础指令(2)

一、echo指令 这个指令在上篇文章我也用了但是忘了说了&#xff0c;这个指令的大概用法就是把后面跟的文本等输出在显示器上&#xff0c;如下代码所示打印的“Hello Linux” [rootVM-24-9-centos ~]# echo "Hello Linux" Hello Linux二、输出重定向与输入重定向 着…

vue前端工程化

前言 本文介绍的是有关于vue方面的前端工程化实践&#xff0c;主要通过实践操作让开发人员更好的理解整个前端工程化的流程。 本文通过开发准备阶段、开发阶段和开发完成三个阶段开介绍vue前端工程化的整体过程。 准备阶段 准备阶段我将其分为&#xff1a;框架选择、规范制…

基于单片机HX711电子秤称重控制设计

**单片机设计介绍&#xff0c;基于单片机HX711电子秤称重控制设计 文章目录 一 概要二、功能设计设计思路 三、 软件设计原理图 五、 程序六、 文章目录 一 概要 基于单片机HX711的电子秤称重控制设计是一个融合了单片机技术、称重传感器技术和显示技术的综合性项目。其设计目…

C 语言贪吃蛇源码解析

贪吃蛇是一款经典的电子游戏&#xff0c;玩家控制一条不断成长的蛇&#xff0c;需要避免撞到自己的身体或者游戏边界&#xff0c;同时吃掉出现在屏幕上的食物以增长身体长度。 下面是一个简单的贪吃蛇游戏的C语言实现&#xff0c;使用了标准输入输出库conio.h和时间库windows.h…

GTC 2024 火线评论:DPU 重构文件存储访问

编者按&#xff1a;英伟达2024 GTC 大会上周在美国加州召开&#xff0c;星辰天合 CTO 王豪迈在大会现场参与了 GPU 与存储相关的最新技术讨论&#xff0c;继上一篇《GTC 2024 火线评论&#xff1a;GPU 的高效存储利用》之后&#xff0c;这是他发回的第二篇评论文章。 上一篇文章…

农村分散式生活污水分质处理及循环利用技术指南

标准已完成意见征集&#xff1a; 本文件给出了农村分散式生活污水分质处理及循环利用的总则、污水收集、污水分质处理、资源化利用、利用模式、运维管理等的指导。 本文件适用于农村分散式生活污水分质处理及循环利用的设施新建、扩建和改建工程的设计、施工与运维。 注:本文件…

微服务demo(二)nacos服务注册与集中配置

环境&#xff1a;nacos1.3.0 一、服务注册 1、pom&#xff1a; 移步spring官网https://spring.io&#xff0c;查看集成Nacos所需依赖 找到对应版本点击进入查看集成说明 然后再里面找到集成配置样例&#xff0c;这里只截一张&#xff0c;其他集成内容继续向下找 我的&#x…

蓝桥杯刷题计划-洛谷-持续更新

P8598 [蓝桥杯 2013 省 AB] 错误票据 题目 #include <bits/stdc.h> #define endl \n #define int long long #define INF 0x3f3f3f3f3f const int N 1000010; using namespace std; int arr[N]; signed main() {int N;cin>>N;int idx;while(cin>>arr[idx…

数据库审计和安全

互联网、云计算、物联网等新技术的应用&#xff0c;数据安全面临前所未有的挑战!我国信息安全已从终端安全、网络安全&#xff0c;发展到数据安全建设阶段。数据安全的核心是对“数据”全方位的安全防护&#xff0c;其产品及解决方案直接涉及国家和企业的核心机密 核心数据库存…

win10微软拼音输入法 - bug - 在PATH变量为空的情况下,无法输入中文

文章目录 win10微软拼音输入法 - bug - 在PATH变量为空的情况下&#xff0c;无法输入中文概述笔记实验前提条件100%可以重现 - 无法使用win10拼音输入法输入中文替代的输入法软件备注END win10微软拼音输入法 - bug - 在PATH变量为空的情况下&#xff0c;无法输入中文 概述 在…

ES6学习之路:迭代器Iterator和生成器Generator

迭代器 一、知识背景 什么是迭代器 迭代器就是在一个数据集合中不断取出数据的过程迭代和遍历的区别 遍历是把所有数据都取出迭代器注重的是依次取出数据&#xff0c;它不会在意有多少数据&#xff0c;也不会保证能够取出多少或者能够把数据都取完。比如斐波那契额数列&#…

linux nginx配置ssl, 实现https+ip访问

mkdir sslZhengShu openssl req -newkey rsa:2048 -nodes -keyout ca.key -out ca.csr openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt openssl genrsa -out server.key 2048 openssl req -new -key server.key -out server.csr 和之前输入一样即可 …

Python基本运算

1.逻辑运算符 第四行会有黄色的下划线是因为这个不是系统推荐的写法&#xff0c;系统推荐的是第五行的链式比较&#xff1b; 2.短路求值 对于and而言&#xff0c;左边的语句是false&#xff0c;那么整体一定是false,右边的表达式就不会进行计算&#xff1b; 对于or而言&…

FTP 文件传输服务

FTP连接 控制连接&#xff1a;TCP 21&#xff0c;用于发送FTP命令信息 数据连接&#xff1a;TCP 20&#xff0c;用于上传、下载数据 数据连接的建立类型&#xff1a; 主动模式&#xff1a;服务端从 20 端口主动向客户端发起连接 被动模式&#xff1a;服务端在指定范围…

平台介绍-搭建赛事运营平台(3)

上文介绍了品牌隔离的基本原理&#xff0c;就是通过不同的前端和微服务来实现。但是确实很多功能是类似的&#xff0c;所以从编程角度还是有些管理手段的。 前端部分&#xff1a;前端部分没有什么特别手段&#xff0c;就是两个独立的项目工程&#xff0c;分别维护。相同的部分复…

神策数据参与制定首份 SDK 网络安全国家标准

国家市场监督管理总局、国家标准化管理委员会发布中华人民共和国国家标准公告&#xff08;2023 年第 13 号&#xff09;&#xff0c;全国信息安全标准化技术委员会归口的 3 项国家标准正式发布。其中&#xff0c;首份 SDK 国家标准《信息安全技术 移动互联网应用程序&#xff0…

2核4G服务器租用价格表,阿里云/腾讯云/华为云/京东云

当前最新2核4G云服务器多少钱&#xff1f;165元一年&#xff0c;30元3个月。阿里云2核4G服务器165元一年&#xff0c;30元3个月、腾讯云2核4G5M服务器165元一年、京东云2核4G云主机126元1年&#xff0c;华为云也提供2核4G配置云服务器。阿腾云atengyun.com整理2024年最新云服务…

【NLP笔记】预训练+Prompt Tuning新范式之LLM时代(GPT3...)

文章目录 概述GPT3 【参考链接】 一张图总结大语言模型的技术分类、现状和开源情况 大语言模型LLM微调技术&#xff1a;Prompt Tuning A Survey of Large Language ModelsThe Practical Guides for Large Language ModelsGPT3&#xff1a;Language Models are Few-Shot Learner…

行存储与列存储:大数据存储方案的选择与优缺点分析

随着大数据时代的来临&#xff0c;数据的规模和复杂性呈指数级增长&#xff0c;传统的关系数据库已经不再适应这一巨大的存储量和计算要求。在大数据存储领域&#xff0c;行存储和列存储成为两种备受关注的存储方案。本文将探讨行存储和列存储的定义、优缺点&#xff0c;并结合…

python pytz是什么

pytz模块常用于时区的转换&#xff0c;常常配合datetime一起使用。我们知道datetime除了data方法生成的时间是没有时区概念&#xff0c;其他如time、datetime等都是有时区概念&#xff0c;即指定了tzinfo信息。 >>> import datetime >>> datetime.datetime.n…