源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Windows Apache2.4 VC9(ApacheHaus)详细安装配置教程

  • 时间:2022-11-02 08:53 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Windows Apache2.4 VC9(ApacheHaus)详细安装配置教程
1,Apache下载 [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100123_0_56866.png[/img] 选择一个版本,点击Download [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100123_1_89262.png[/img] 点击File For Microsoft Windows [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100123_2_40616.png[/img] 由于Apache HTTP Server官方不提供二进制(可执行)的发行版,所以我们选择一些贡献者编译完成的版本,我们选择第一个ApacheHaus 点击ApacheHaus,进入下载页 [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100124_3_47813.png[/img] 选择其中一个版本,如果你的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>
[b]3,配置Apache之二--ssl配置[/b] 如果你这使启动服务,一般会出现下面的消息对话框: [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100124_4_65542.png[/img] 提示 Windows不能在本地计算机启动Apache2.2。有关更多信息,查阅系统日志文件。如果这是非Microsoft服务,请与厂商联系,并参考特定服务器错误代码1。 确定此问题的原因: 右键 计算机,点击管理->Windows日志->应用程序,显示如下 [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100125_5_37548.png[/img] [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100125_6_28021.png[/img] 这是由于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,这个不改的话也会错。一般会出现如下错误: [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100126_7_27789.png[/img] 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命令行[b]以管理员身份[/b]进入Apache程序的文件夹下的bin文件夹,输入httpd -k install,完成Apache服务的安装。 然后双击bin目录下的ApacheMonitor.exe,点击右边的start启动服务器,如果正常,如下图: [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100126_8_29793.png[/img] 测试一下: [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100127_9_58612.png[/img] 5,其它 卸载Apache HTTP Server: 管理员身份进入bin目录,使用httpd -k uninstall 移除服务 使用httpd -w -n "Apache2" -k start命令启动服务器 可以显示启动过程中的日志,便于分析错误。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部