upupw里边配置阿里云的SSL域名证书–也可以说是APACHE配置阿里云的CA证书

阅读次数: 14,219

  • A+
所属分类:windows系列 建站 运维

环境

UPUPW的5.6版本UPUPW_AP5.6-1510-64bit

windows server 2008 R2 开放端口 80 443 21

因为要做小程序所有就需要配置拥有https 的域名了,其实我到现在还是没有太明白这个到底有什么特别的含义。

废话不多说了 直接进入主题

第一步 在登录阿里云 如图

upupw里边配置阿里云的SSL域名证书--也可以说是APACHE配置阿里云的CA证书

第二步按下图选择的来购买

upupw里边配置阿里云的SSL域名证书--也可以说是APACHE配置阿里云的CA证书

第三步下载APPACHE证书

upupw里边配置阿里云的SSL域名证书--也可以说是APACHE配置阿里云的CA证书

第四步上传压缩包到 服务器 apache 根目录的   conf/key 下边 如果没有此文件夹 则新建一个文件夹名字为 key的

第五步配置apache  包含 httpd.conf  vhosts.conf ssl.conf  这三个配置文件

httpd.conf   主要是 开启  httpd-vhosts.conf 和httpd-ssl.conf 同时还必须开启 mod_ssl.so     mod_socache_shmcb.so 扩展

注意在第三步购买和配置SSL证书时正常的都可以选择默认的但是也可以自己生成证书再上传(具体生成 私钥和证书流程附在文章下方)

httpd-vhosts.conf 配置虚拟主机

<VirtualHost *:80>
    DocumentRoot "D:/web/UPUPW_AP5.6_64/htdocs"
    ServerName 127.0.0.1:80
    ServerAlias localhost
    ServerAdmin webmaster@localhost
    DirectoryIndex index.html index.htm index.php default.php app.php u.php
    ErrorLog logs/localhost_error.log
    CustomLog logs/localhost_access_%Y%m%d.log comonvhost
	php_admin_value open_basedir "D:\web\UPUPW_AP5.6_64\htdocs\;D:\web\UPUPW_AP5.6_64\memcached\;D:\web\UPUPW_AP5.6_64\phpmyadmin\;D:\web\UPUPW_AP5.6_64\temp\;C:\Windows\Temp\"
<Directory "D:/web/UPUPW_AP5.6_64/htdocs">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
<LocationMatch "/(inc)/(.*)$">
    Require all denied
</LocationMatch>
<LocationMatch "/(attachment|attachments|uploadfiles|avatar)/(.*).(php|php5|phps|asp|aspx|jsp)$">
    Require all denied
</LocationMatch>
</VirtualHost>



<VirtualHost *:80>
    DocumentRoot "D:/web/UPUPW_AP5.6_64/vhosts/www.wh2013.net"
	ServerName www.wh2013.net:80
    ServerAlias wh2013.net
    ServerAdmin webmaster@www.wh2013.net
	DirectoryIndex index.html index.htm index.php default.php app.php u.php
	ErrorLog logs/www.wh2013.net-error.log
    CustomLog logs/www.wh2013.net-access_%Y%m%d.log comonvhost
	php_admin_value open_basedir "D:\web\UPUPW_AP5.6_64\vhosts\www.wh2013.net\;D:\web\UPUPW_AP5.6_64\memcached\;D:\web\UPUPW_AP5.6_64\phpmyadmin\;D:\web\UPUPW_AP5.6_64\temp\;C:\Windows\Temp\"
<Directory "D:/web/UPUPW_AP5.6_64/vhosts/www.wh2013.net">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
	Order allow,deny
    Allow from all
</Directory>
<LocationMatch "/(inc)/(.*)$">
    Require all denied
</LocationMatch>
<LocationMatch "/(attachment|attachments|uploadfiles|avatar)/(.*).(php|php5|phps|asp|asp.net|jsp)$">
    Require all denied
</LocationMatch>
</VirtualHost>

上边的是默认的用户通过IP访问就会进入到 htdocs目录里边,下班的www.wh2013.net才是我们配置的第一个虚拟主机

httpd-ssl.conf 这个配置主要是SSL的关键


Listen 443


SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
#SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM


SSLHonorCipherOrder on 

SSLPassPhraseDialog  builtin

#SSLSessionCache         "dbm:logs/ssl_scache"
SSLSessionCache        "shmcb:logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

<VirtualHost *:443>
    DocumentRoot "D:/web/UPUPW_AP5.6_64/vhosts/www.wh2013.net"
    ServerName www.wh2013.net:443
    ServerAlias wh2013.net
    ServerAdmin webmaster@www.wh2013.net
    DirectoryIndex index.html index.htm index.php default.php app.php u.php
    ErrorLog logs/www.wh2013.net-error-443.log
    CustomLog logs/www.wh2013.net-access_%Y%m%d.log \
    "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    SSLEngine on
	#SSLCipherSuite ALL:!ADH:!EXPORT56:RC4 RSA: HIGH: MEDIUM: LOW: SSLv2: EXP: eNULL
    SSLCertificateFile "D:/web/UPUPW_AP5.6_64/Apache2/conf/ssl/public.pem"
    SSLCertificateKeyFile "D:/web/UPUPW_AP5.6_64/Apache2/conf/ssl/214452897390627.key"
	SSLCertificateChainFile "D:/web/UPUPW_AP5.6_64/Apache2/conf/ssl/chain.pem"
<Directory "D:/web/UPUPW_AP5.6_64/vhosts/www.wh2013.net">
    SSLOptions +StdEnvVars
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
	
</Directory>
<FilesMatch "\.(shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>
    BrowserMatch "MSIE [2-5]" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0
</VirtualHost>

我这里没有按照阿里云的 SSLCipherSuite 这个配置因为我需要的安全系数不高,能够满足微信即可。

配置完这些就可以重启APACHE 了,然后访问 https://www.wh2013.net 发现我没有权限访问 这个站通过443

这时再配置下 httpd.conf  的 <directory>这个配置

<Directory />
     Options FollowSymLinks
     AllowOverride None
     Order deny,allow
     deny from all
     Satisfy all
</Directory>

再 重启试下就可以了(核心点 在配置的过程中出现了很多的错误,需要及时的去看错误日志,但发现错误日志里什么也没有,再找系统 的应用程序错误日志也是没有说明哪里有错误!最后发现 apache的配置文件是类似php的流程加载的,这时候我们可以边注释边发现问题 可以说是通过断点调式发现了问题并解决了

第六步 通过httpd.conf 或者 .htaccess 文件来重定向 http到https  方法查看我的其他文章 搜索关键词 htaccess 应该可以搜索到相关文章。

附:windows下生成域名证书

1.通过cmd 黑框框进入 apache bin目录

set OPENSSL_CONF = ..\conf\openssl.cnf

2.生成服务端私钥

openssl genrsa -out server.key 1024  此时bin目录下会生成server.key

3.生成签署申请

openssl req -new -out server.csr -key server.key -config ../conf\openssl.cnf

需要填写信息 国家 CN 省份 GuangDong 城市 HuiZhou 公司名 域名 等等

其中域名需要填写正确

4.生成CA私钥

openssl genrsa -out ca.key 1024  生成了 ca.key

5.生成自签署证书

openssl req -new -x509 -days 365 -key ca.key -out ca.crt -config ..\conf\openssl.cnf

6.生成CA的服务器签署证书

openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config ..\conf\openssl.cnf 如果出错则如下

再当前目录下建立一个demoCA目录,在里面创建一个index.txt空文件,一个名为serial,内容为01的文件,以及一个文件夹newcerts 再重新执行一次

配置的话就跟上面是一样的了

7.打开IE,输入127.0.0.1:8080出现It works。输入https://127.0.0.1:443的时候会弹出一个验证证书的地方,点击取消发现没能成功。上网查了一下,原来还要生成一个 .pfx 的证书并导入到IE中去。
打开刚才的命令行,执行命令openssl pkcs12 -export -in ca.crt -inkey ca.key -out ca.pfx,在bin下面生成一个ca.pfx的文件,中间有个输入密码的过程,要记住这个密码。打开IE浏览器-》工具-》Internet选项-》内容-》证书,按照提示导入,这里要输入刚才生成 .pfx 过程中输入的密码。导入之后,打开浏览器输入https://127.0.0.1:443

转载请标明原出处                                           神秘剑派---大师兄  xzc

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: