Skip to content

Instantly share code, notes, and snippets.

@hongyangqin
Last active November 27, 2017 15:41
Show Gist options
  • Select an option

  • Save hongyangqin/0558556660c5c817b6c480dafe22b3b5 to your computer and use it in GitHub Desktop.

Select an option

Save hongyangqin/0558556660c5c817b6c480dafe22b3b5 to your computer and use it in GitHub Desktop.

前言

Apache官网从2.2之后,不再提供windows的msi或exe安装版本,现在Apache http Server有两个分支2.2及2.4

注意事项

如果之前有安装2.2的版本,请先卸载

image

Apache2.4下载

1、进入apache官网:https://httpd.apache.org/download.cgi

2、选择2.4的版本,点击 Files for Microsoft Windows  (windows安装版本)

image

3、选择前三个网站中的任意一下进入下载,(推荐Apache Lounge镜像站点快)

image

4、以Apache Lounge 为例,选择需要的x86或x64进行下载

注意事项

不同的VC对应不同的vc++(简单理解为Visual Studio)版本,我的电脑上安装了VS2015所以选择VC14,如果是vs2012请选择VC11

image

image

 

我的环境

我的电脑安装了VS2015,WIN10 X64位操作系统

文件分析

解压文件

1、下载完成后,解压出目录如下:

image

image

2、详细的安装配置步骤可以参考图一中的ReadMe.txt

主要的文件和目录

创建服务 :bin\httpd.exe

管理面板 :bin\ApacheMonitor.exe

主要的配置文件:conf\httpd.conf

网站根目录:\htdocs

配置方法

下面说一下我的简单配置步骤

1、默认的安装目录是在C:/Apache24,找到自己的实际目录比如我的D:/Apache24

2、打开conf\httpd.conf

  • 把文件中的所有  ”c:/Apache24″ 替换为自己的安装目录,如” d:/Apache24″
  • 找到 218行(版本不同,可能有区别)的 ServerName ,把前面的 # 去掉
  • image
  • 找到 DocumentRoot ,修改网站的根目录,比如是 “d:/Apache24/htdocs”
  • DocumentRoot 下方一行的 Directory也做相应修改
  • 修改端口号——“Listen:80”改为8080
  • image

3、以管理员身份运行CMD,进入Apache24\bin 目录(httpd.exe所在目录

4、输入 httpd.exe -k install -n "Apache24"  安装服务(注:Apache24为安装服务名称)

image

 

安装完成

image

5、至此,安装基本完成。到安装目录下的bin目录中找到 ApacheMonitor.exe ,双击运行,启动apache服务

image

6、开启Apache服务,输入ip和端口访问(默认访问的是\htdocs\index.html)

image

 

卸载Apache服务

如果要卸载这个服务 先要停止这个服务,然后输入httpd.exe -k uninstall –n “Apache24”卸载这个服务。

自动安装

通过编写bat脚本自动安装Apache,减少劳动量。

方法步骤

1.在apache的文件目录下创建一个bat文件:win_install.cmd

2.输入示例代码,保存,以管理员身份运行,即可安装成功

3.安装成功之后,在服务管理器可以开启和停止服务

win_install脚本

复制代码
1 echo "正在安装Apache24";
2 ::作用:以管理员身份安装Apache 说明:在 windows10 x64下工作正常
3 d:
4 cd %~dp0bin\
5 httpd.exe -k install -n "Apache24"
6 pause
复制代码

自动安装结果

C:\Windows\system32>echo "正在安装Apache24";
"正在安装Apache24";
C:\Windows\system32>d:
D:\>cd D:\Server\Apache24\bin\
D:\Server\Apache24\bin>httpd.exe -k install -n "Apache24"

 

遇到的问题

安装服务报错

image

请安装对应版本的VC++运行库

 

VC14/VC12/VC10 知识

Visual C++ Redistributable Package(VC)

VC14对应Visual C++2015运行库

image

VC11对应Visual C++2012运行库

image

VC10对应Visual C++2010运行库

作者:赵青青        出处:http://www.cnblogs.com/zhaoqingqing/
关于我:乐于学习未知技术和知识,擅长Unity3D,游戏开发,.NET等领域。
本文版权归作者和博客园共有欢迎转载,转载之后请务必在文章明显位置标出原文链接和作者,谢谢。
如果本文对您有帮助,请点击【推荐】您的赞赏将鼓励我继续创作!想跟我一起进步么?那就【关注】我吧。
posted @ 2015-11-16 21:13 赵青青 阅读(13132) 评论(0) 编辑 收藏
@hongyangqin

Copy link
Copy Markdown
Author

httpd-2.4.29-Win64-VC15 解压之后readme.txt的内容

有关于环境和安装的简单说明

Be sure you have installed the Visual C++ Redistributable for Visual Studio 2017.
Download and install, if you not have it already, see:

http://www.apachelounge.com/download/vc15/

Install

  • Unzip the Apache24 folder to c:/Apache24 (that is the ServerRoot in the config).
    Default folder for your your webpages is DocumentRoot "c:/Apache24/htdocs"

When you unzip to an other location, change ServerRoot in the httpd.conf,
and change in httpd.conf the Documenroot, Directories, ScriptAlias,
also when you use the extra folder config file(s) change to your location there.

Start apache in a DOS box:

httpd.exe

Install as a service:

httpd.exe -k install

ApacheMonitor:

Double click ApacheMonitor.exe, or put it in your Startup folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment