1,Apache下载

选择一个版本,点击Download

点击File For Microsoft Windows

由于Apache HTTP Server官方不提供二进制(可执行)的发行版,所以我们选择一些贡献者编译完成的版本,我们选择第一个ApacheHaus

点击ApacheHaus,进入下载页

选择其中一个版本,如果你的Windows还没安装对应的VC环境的话,选择对应的VCRedistribute版本下载安装。我选择Apache 2.4VC9版,因为我的电脑中已经安装了VC9的环境。

点击JumpLinks下第一行的某一个版本,下载对应压缩包。

2,配置Apache之一--httpd.conf

解压后进入里面Apache22(最后两位数字可能不同)文件夹,使用文本编辑器(推荐ultraedit)打开conf文件夹中的httpd.conf配置文件

找到ServerRoot选项,设置Apache目录,大约在35行左右,将其改成你的Apache程序的文件夹,例:

ServerRoot "C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22"

找到Listen选项,设置端口,大约46行,一般不修改,使用默认80,在开启服务器前请保证80端口未被占用

找到DocumentRoot选项,修改服务器根目录,例:

DocumentRoot "F:/"

请保证此目录存在,否则服务器无法正常启动

修改Directory,保证其与服务器根目录相同,只修改下面的第一行中引号部分

<Directory "F:/">
#
# 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.2/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.
#
Order allow,deny
Allow from all </Directory>

找到ScriptAlias选项,设置服务器脚本目录,大约326行,一般将其设置为Apache目录下的cgi-bin文件夹

ScriptAlias /cgi-bin/ "C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/cgi-bin"

找到随后的Directory选项,设置脚本目录,大约342行,需要将其设置为和前面的ScriptAlias目录相同

<Directory "C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

3,配置Apache之二--ssl配置

如果你这使启动服务,一般会出现下面的消息对话框:

提示

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

确定此问题的原因:

右键  计算机,点击管理->Windows日志->应用程序,显示如下

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

打开Apache程序目录下的conf/extra/httpd-ahssl.conf文件,配置VirtualHost选项,有三处名为VirtualHost的选项,均需修改。

第一个在107行左右。

在110行左右,将其中的SSLCertificateFile改为:Apache所在目录/conf/ssl/server.crt

在111行左右,将SSLCertificateKeyFile改为:Apache所在目录/conf/ssl/server.key

在112行左右,将DocumentRoot改为你的服务器根目录

在126行左右,将CustomLog改为:Apache所在目录/logs/ssl_request.log,这个不改的话也会错。一般会出现如下错误:

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

改成的效果:

<VirtualHost _default_:443>
SSLEngine on
ServerName localhost:443
SSLCertificateFile C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/conf/ssl/server.crt
SSLCertificateKeyFile C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/conf/ssl/server.key
DocumentRoot F:/ # openssl req -new > server.csr
# openssl rsa -in privkey.pem -out server.key
# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 2048
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/Apache22/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</virtualhost>

主要改上文四处地方

在130行和152行还有另外两个VirtualHost,均需修改上述的四个选项

例:

130行

<VirtualHost *:443>
SSLEngine on
ServerName serverone.tld:443
SSLCertificateFile C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/conf/ssl/serverone.crt
SSLCertificateKeyFile C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/conf/ssl/serverone.key
DocumentRoot F:/
# openssl req -new > serverone.csr
# openssl rsa -in privkey.pem -out serverone.key
# openssl x509 -in serverone.csr -out serverone.crt -req -signkey serverone.key -days 2048
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/Apache22/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" env=HTTPS
</virtualhost>

第152行

<VirtualHost *:443>
SSLEngine on
ServerName servertwo.tld:443
SSLCertificateFile C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/conf/ssl/servertwo.crt
SSLCertificateKeyFile C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/conf/ssl/servertwo.key
DocumentRoot F:/
# openssl req -new > servertwo.csr
# openssl rsa -in privkey.pem -out servertwo.key
# openssl x509 -in servertwo.csr -out servertwo.crt -req -signkey servertwo.key -days 2048
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/Apache22/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "C:/Users/myPC/Downloads/httpd-2.2.31-x86-r3/Apache22/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</virtualhost>

上述的两个VirtualHost均需修改四处

这样,Apache就算配置完了,如果还有问题,可能还需配置./conf/extra/httpd-ssl.conf,配置方法和配置VirtualHost的相似

4,启动Apache HTTP Server

使用Windows命令行以管理员身份进入Apache程序的文件夹下的bin文件夹,输入httpd -k install,完成Apache服务的安装。

然后双击bin目录下的ApacheMonitor.exe,点击右边的start启动服务器,如果正常,如下图:

测试一下:

5,其它

卸载Apache HTTP Server:

管理员身份进入bin目录,使用httpd -k uninstall 移除服务

使用httpd -w -n "Apache2" -k start命令启动服务器 可以显示启动过程中的日志,便于分析错误。

Windows Apache(ApacheHaus)安装配置教程的更多相关文章

  1. Apache(ApacheHaus)安装配置教程

    1,Apache下载 选择一个版本,点击Download 点击File For Microsoft Windows 由于Apache HTTP Server官方不提供二进制(可执行)的发行版,所以我们 ...

  2. Windows上PostgreSQL安装配置教程

    Windows上PostgreSQL安装配置教程 这篇文章主要为大家详细介绍了Windows上PostgreSQL安装配置教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 PostgreSQL的 ...

  3. hadoop集群监控工具Apache Ambari安装配置教程

    ambari 1.2.4 下载地址:http://www.apache.org/dist/incubator/ambari/ambari-1.2.4/ambari-1.2.4-incubating.t ...

  4. Windows 中JDK安装配置教程

    1.准备工作 a.因为Java JDK区分32位和64位系统,所以在安装之前必须先要判断以下我们的系统为多少位系统.右键计算机-属性查看,我安装的是64位 b.下载JDK,地址:http://www. ...

  5. [转载]Apache在windows下的安装配置

    Apache在windows下的安装配置 转载自:http://blog.sina.com.cn/s/blog_536f16b00100cfat.html     1 Apache的下载 Apache ...

  6. Windows基础环境_安装配置教程(Windows7 64、JDK1.8、Android SDK23.0、TortoiseSVN 1.9.5)

    Windows基础环境_安装配置教程(Windows7 64.JDK1.8.Android SDK23.0.TortoiseSVN 1.9.5) 安装包版本 1)     JDK版本包 地址: htt ...

  7. PHP调试工具Xdebug安装配置教程

    说道PHP代码调试,对于有经验的PHPer,通过echo.print_r.var_dump函数,或PHP开发工具zend studio.editplus可解决大部分问题,但是对于PHP入门学习的童鞋来 ...

  8. 【Jmeter】Jmeter安装配置教程

    jmeter安装配置教程 1.安装jdk,配置环境变量 进入官网,https://www.oracle.com/downloads/index.html#java,选择 Java (JDK) for ...

  9. windows Apache 环境下配置支持HTTPS的SSL证书

    windows Apache 环境下配置支持HTTPS的SSL证书 1.准备工作 1)在设置Apache + SSL之前, 需要做: 安装Apache, 下载安装Apache时请下载带有SSL版本的A ...

随机推荐

  1. GoLand Dep Integration Project

    Dep integration 标签(空格分隔): Go 1. 通过 GoLand 使用 dep integration 创建项目 参见 Dep integration 使用 dep integrat ...

  2. Asp调用存储过程,command.CreateParameter 参数值的类型说明

    Asp调用存储过程,command.CreateParameter 参数值的类型说明 Asp调用各种存储过程,包括带参数,无参数,输入输出参数,带返回值等. 1,调用没有参数的存储过程 <% s ...

  3. Oracle OEM启动方法

    首先要启动 listener: lsnrctl start 对于dbconsole:emctl start dbconsole

  4. 【转】numpy教程

    [转载说明] 本来没有必要转载的,只是网上的版本排版不是太好,看的不舒服.所以转过来,重新排版,便于自己查看. 基础篇 NumPy的主要对象是同种元素的多维数组. 这是一个所有的元素都是一种类型.通过 ...

  5. HTML3/CSS基础

    1. HTML 1.1 什么是HTML HTML是用来制作网页的标记语言 HTML是Hypertext Markup Language的英文缩写,即超文本标记语言 HTML语言是一种标记语言,不需要编 ...

  6. 菜鸟vimer成长记——第2.2章、visual模式

    vi是没有可视模式的.然而大多数编辑软件都都是有可视模式.所以我猜测vim是几乎迫于无奈才有了visual模式. 个人建议,能不用就不用.这样能直接在头脑里处理好文本,锻炼文本处理能力,同时能转变过来 ...

  7. CentOS7.4 部署 Django + Python3 + Apache + Mod_wsgi

    安装环境 Remote: CentOS 7.4 x64 (django.example.com) Python: Python3.6.5 Apache: Apache 2.4.6 Mod_wsgi: ...

  8. Linux shell 编写(1)

    shell脚本的编写步骤 1.创建以.sh为扩展名的文件           touch 2.编辑脚本文件                              vim 3.增加脚本文件执行权限 ...

  9. linux centos7 nginx 安装部署和配置

    1/什么是NginxNginx("enginex")是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器,在高连接并发的情况下Nginx是Apac ...

  10. Go语言2

    Go语言特点: 类型检查:编译时 运行环境:编译成机器代码直接运行 编程范式:面向接口,函数式编程,并发编程 Go并发编程 采用CSP(Communication Sequenication Proc ...