phpstudy 安裝Apache SSL證書實現https鏈接

Windows phpstudy安裝ssl證書教程。php

工具/原料

 
  • phpstudy 集成環境
  • 申請的SSL證書

方法/步驟

 
  1.  

    首先申請免費的ssl證書,不少地方均可以申請。我是在騰訊雲!如圖html

    phpstudy 安裝Apache SSL證書實現https鏈接
  2.  

    下載證書備份好。以避免丟失。解壓下載的證書,裏面有4個文件夾相對應不一樣的安裝環境,咱們用的是Apache,因此選擇這個。如圖安全

    phpstudy 安裝Apache SSL證書實現https鏈接
  3.  

    打開PHPstudy php擴展設置,在php_openssl上點擊打鉤。說明就打開了!如圖ide

    phpstudy 安裝Apache SSL證書實現https鏈接
  4.  

    打開修改httpd.conf配置文件,打開找到#LoadModule ssl_module modules/mod_ssl.so,去掉前面的註釋符#(保證前面沒有#號),使得ssl模塊生效。工具

    增長一條引用語句   Include conf/vhostssl.conf網站

    phpstudy 安裝Apache SSL證書實現https鏈接
    phpstudy 安裝Apache SSL證書實現https鏈接
    phpstudy 安裝Apache SSL證書實現https鏈接
  5.  

    如圖在Apache/conf環境下新建vhostssl.conf文件;寫入以下:ui

    Listen 443spa

    <VirtualHost *:443>3d

        DocumentRoot "C:\myphp_www\PHPTutorial\WWW"htm

        ServerName www.test.com

        ServerAlias test.com

        SSLEngine on

        SSLProtocol TLSv1 TLSv1.1 TLSv1.2

        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5

        SSLCertificateFile "C:\myphp_www\PHPTutorial\Apache\cert\2_www.test.com.crt"

        SSLCertificateKeyFile "C:\myphp_www\PHPTutorial\Apache\cert\3_www.test.com.key"

        SSLCertificateChainFile "C:\myphp_www\PHPTutorial\Apache\cert\1_root_bundle.crt"

    <Directory "C:\myphp_www\PHPTutorial\WWW">

          Options +Indexes +FollowSymLinks +ExecCGI

          AllowOverride All

          Order allow,deny

          Allow from all

          Require all granted

      </Directory>

    </VirtualHost>

    其中

    SSLCertificateFile 是指證書公鑰

    SSLCertificateKeyFile   是指證書私鑰

    SSLCertificateChainFile  

    上面3個就是分別對應ssl證書放置的位置,請看下一步說明。

    DocumentRoot  "C:\myphp_www\PHPTutorial\WWW"這是網站路徑根據本身的,這是隻是完成一半若是啓動成功,那你就能夠使用了 若是不成功請繼續往下看

    phpstudy 安裝Apache SSL證書實現https鏈接
  6.  

    在Apache目錄下新建cert目錄放入下載下來的Apache環境的ssl證書;如圖;

    phpstudy 安裝Apache SSL證書實現https鏈接
    phpstudy 安裝Apache SSL證書實現https鏈接
  7.  

    而後重啓Apache,用https訪問網站,出現安全就說明成功了。

    phpstudy 安裝Apache SSL證書實現https鏈接
  8.  

    細節配置;防火牆不要攔截443端口;

    最後在.htaccess里加入 實現http轉跳到https上

    下列代碼修改本身域名

    <IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{SERVER_PORT} 80RewriteRule ^(.*)$ https://www.chu.mn/$1 [R=301,L]</IfModule>

相關文章
相關標籤/搜索