当前位置 主页 > 服务器问题 > Linux/apache问题 >

    Windows Server 2016 上配置 APACHE+SSL+PHP+perl的教程详解

    栏目:Linux/apache问题 时间:2019-10-15 15:10

    <strong><span >安装环境</span></strong> 
     谷歌云实例 Windows Server 2016 
    Apache   Apache/2.4.25 (win64-VC14) 
    PHP    php-5.6.30 (VC11 x64 Thread Safe) 
    PERL    ActivePerl-5.24 (Win64) 
    OpenSSL  openssl-1.0.2j-win64 
    VC14    Microsoft Visual C++ 2015(vcredist_x64) 
    VC11    Microsoft Visual C++ 2015(vcredist_x64) 
    <strong><span >1.安装 Apache</span></strong> 
    Apache/2.2 不支持php-5.3以后的版本,用最新的 Apache/2.4,由于是Win64-VC14版本,需安装 x64位版本的 VC2015运行库,即VC14 
    http://httpd.apache.org/download.cgi 
    http://www.apachelounge.com/download/VC14/binaries/httpd-2.4.25-win64-VC14.zip 
    解压到 D:\httpd 
    修改 D:\httpd\conf 和 D:\httpd\conf\extra 目录下的文件,替换 C:/apache24 到 D:/httpd 

    <span ><strong>2.安装 SSL</strong></span> 
    http://openssl.org 
    https://wiki.openssl.org/index.php/Binaries 
    https://slproweb.com/products/Win32OpenSSL.html 
    这里使用了 Apache/2.4.25 自带的 openssl ,在 D:\httpd\bin 目录 ,默认配置文件位于 C:/openssl-1.0.2j-win64/ssl/openssl.cnf 
    用命令建立 server.key 和 server.crt 
      set path=D:/httpd/bin 
      D: 
      cd D:/httpd/conf/ 
      copy openssl.cnf openssl.conf 
      mkdir demoCA\newcerts 
      echo.>demoCA/index.txt 
      echo.>demoCA/serial 
      openssl genrsa -out server.key 1024 
      openssl req -new -x509 -key server.key -out server.crt -days 3650 -config openssl.conf   
    修改 D:/httpd/conf/httpd.conf 文件,去掉下面两行前面的 # 
    #LoadModule ssl_module modules/mod_ssl.so 
    #Include conf/extra/httpd-ssl.conf 
    修改 D:/httpd/conf/extra/httpd-ssl.conf 文件,注释下面的行 
    #SSLSessionCache    "shmcb:d:/httpd/logs/ssl_scache(512000)" 
    <span ><strong>3.安装 perl</strong></span> 
    下载后安装时选第三项会自动安装到 c:/perl64 ,无需做其它修改,以后加载.pl文件时,第一行指向 #!c:/perl64/bin/perl.exe 
    http://perl.org 
    http://www.activestate.com/activeperl/downloads 
    修改 D:/httpd/conf/httpd.conf 文件,去掉下行前面的 # 
    #LoadModule cgi_module modules/mod_cgi.so 
    <span ><strong>4.安装 php</strong></span> 

    php 有两种版本,Thread Safe(TS) 和 Non Thread Safe(NTS) , TS 用于APACHE ,NTS 用于IIS 

    由于 VC11 x64 Thread Safe 需安装 x64位版本的 VC2012运行库,即VC11,在微软官方网站搜索安装。   

    http://windows.php.net/download/ 
    http://windows.php.net/downloads/releases/php-5.6.30-Win32-VC11-x64.zip 
    解压到 D:/httpd/php-5.6.30 ,把 php.ini-production 改名为 php.ini 
    修改 D:/httpd/conf/httpd.conf 文件,增加下面的行 
    LoadModule php5_module "D:/httpd/php-5.6.30/php5apache2_4.dll" 
    PHPIniDir "d:/httpd/php-5.6.30" 
    AddType application/x-httpd-php .php .html .htm 
    如果出现找不到 D:/httpd/php-5.6.30/php5apache2_4.dll 文件的提示,可能是需要的VC运行库没有安装,或者是apache和php的版本不配。 
    5.到此配置结束,<span ><strong>使用下面的命令启动服务</strong></span>  
    httpd -k install 
    httpd -k start  
    单是 httpd -k start 不能启动服务