https配置(阿里云win+phpstudy2016)

一 下載證書

我這里的下載流程只供參考,詳細的步驟可以去百度搜索杭朱。最終的目的是得到4個證書文件

  1. 首先申請阿里云免費的ssl認證證書阅仔,認證證書申請過程比較簡單。請自行百度弧械。登陸阿里云之后八酒,在安全(云盾)板塊下-CA證書服務
購買
  1. 申請過程比較簡單,需要等待阿里云審核通過刃唐。通過之后會顯示證書羞迷。點擊“下載”(此教程主要是針對Apache);
下載
  1. 這里選取apache證書画饥。下載的文件包里面有四個文件:

【123.key證書私鑰文件,123.pem,證書公鑰文件chain.pem,證書鏈文件 public.pem 】

二 配置phpStudy的Apache

  1. 開啟apache的編譯ssl模塊衔瓮,如圖打開phpstudy—其它選項設置—PHP擴展及設置—php擴展—php-openssl前面打勾
配置
  1. 打開httpd.conf文件(C:\phpStudy\Apache\conf\httpd.conf根據(jù)這個規(guī)律去找你安裝的位置)
  2. 更改httpd.conf的相應文件
  • 找到LoadModule ssl_module modules/mod_ssl.so (如果前面有#號把#號去調(diào)打開此擴展)
  • 找到Include conf/vhosts.conf(如果前面有#號把#號去了)
  • 找到Include conf/extra/httpd-ssl.conf(如果前面有#號把#號去了,如果沒有此段文字抖甘,就搜索# Secure (SSL/TLS) connections热鞍,并在它的下一行寫上)
#Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf
  • 現(xiàn)在重啟Apache 肯定是紅燈,如果把Include conf/extra/httpd-ssl.conf前面加#注釋以后能正常啟動說明引入文件成功

  • 打開httpd-ssl.conf(C:\phpStudy\Apache\conf\extra根據(jù)這個規(guī)律去找你安裝的位置)

  • 把下面<VirtualHost><VirtualHost>的內(nèi)容全部刪除

    <VirtualHost >
        衔彻。碍现。。米奸。昼接。。
    </VirtualHost>    
    
    • 更改如下

      <VirtualHost *:443>
          SSLEngine on
          SSLProtocol TLSv1 TLSv1.1 TLSv1.2
          SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
          SSLCertificateFile "C:/phpStudy/Apache/cert/public.pem"
          SSLCertificateKeyFile  "C:/phpStudy/Apache/cert/11.key"
          SSLCertificateChainFile  "C:/phpStudy/Apache/cert/chain.pem"
          ServerName www.exam.com
          DocumentRoot "C:\phpStudy\WWW\exam"
      </VirtualHost>    
      
      • 以上參數(shù)說明

        SSLCipherSuite是阿里云提供的悴晰,下載證書的頁面有

        SSLCertificateFile SSLCertificateKeyFile SSLCertificateChainFile文件是證書的絕對路徑

        ServerName 是你網(wǎng)站的域名這個域名必須是和購買證書的iP是對應的映射關(guān)系

        DocumentRoot 是www. exam.com域名對應的項目地址:單訪問ServerName時就打開WWW下的exam文件(我用的tp框架且把入口index.php放在了項目的根目錄下慢睡,及直接運行exam/index.php文件了)

        • 再次重啟apache正常啟動 如果還是紅燈肯定是哪里寫錯了,一定保證httpd.cpmf的Include conf/extra/httpd-ssl.conf開啟

        http-ssl.conf源碼

        #
        # This is the Apache server configuration file providing SSL support.
        # It contains the configuration directives to instruct the server how to
        # serve pages over an https connection. For detailed information about these 
        # directives see <URL:http://httpd.apache.org/docs/trunk/mod/mod_ssl.html>
        # 
        # Do NOT simply read the instructions in here without understanding
        # what they do.  They're here only as hints or reminders.  If you are unsure
        # consult the online docs. You have been warned.  
        #
        
        #
        # Pseudo Random Number Generator (PRNG):
        # Configure one or more sources to seed the PRNG of the SSL library.
        # The seed data should be of good random quality.
        # WARNING! On some platforms /dev/random blocks if not enough entropy
        # is available. This means you then cannot use the /dev/random device
        # because it would lead to very long connection times (as long as
        # it requires to make more entropy available). But usually those
        # platforms additionally provide a /dev/urandom device which doesn't
        # block. So, if available, use this one instead. Read the mod_ssl User
        # Manual for more details.
        #
        #SSLRandomSeed startup file:/dev/random  512
        #SSLRandomSeed startup file:/dev/urandom 512
        #SSLRandomSeed connect file:/dev/random  512
        #SSLRandomSeed connect file:/dev/urandom 512
        
        #
        # When we also provide SSL we have to listen to the 
        # standard HTTP port (see above) and to the HTTPS port
        #
        # Note: Configurations that use IPv6 but not IPv4-mapped addresses need two
        #       Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443"
        #
        Listen 443
        
        ##
        ##  SSL Global Context
        ##
        ##  All SSL configuration in this context applies both to
        ##  the main server and all SSL-enabled virtual hosts.
        ##
        
        #   Pass Phrase Dialog:
        #   Configure the pass phrase gathering process.
        #   The filtering dialog program (`builtin' is a internal
        #   terminal dialog) has to provide the pass phrase on stdout.
        SSLPassPhraseDialog  builtin
        
        #   Inter-Process Session Cache:
        #   Configure the SSL Session Cache: First the mechanism 
        #   to use and second the expiring timeout (in seconds).
        #SSLSessionCache         "dbm:/Apache24/logs/ssl_scache"
        SSLSessionCache        "shmcb:/Apache24/logs/ssl_scache(512000)"
        SSLSessionCacheTimeout  300
        
        ##
        ## SSL Virtual Host Context
        ##
        
        <VirtualHost *:443>
            SSLEngine on
            SSLProtocol TLSv1 TLSv1.1 TLSv1.2
            SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
            SSLCertificateFile "C:/phpStudy/Apache/cert/public.pem"
            SSLCertificateKeyFile  "C:/phpStudy/Apache/cert/1.key"
            SSLCertificateChainFile  "C:/phpStudy/Apache/cert/chain.pem"
            ServerName www.exam.com
            DocumentRoot "C:\phpStudy\WWW\exam"
        </VirtualHost>        
        

        三 自動轉(zhuǎn)htpps

        在項目的根目錄下找到并打開.htaccess(C:\phpStudy\WWW\項目名稱.htaccess如果沒有自建)

        內(nèi)容如下隱藏了index.php和強行自動跳轉(zhuǎn)https的配置

        <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . index.php
        </IfModule>
        

?

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末铡溪,一起剝皮案震驚了整個濱河市漂辐,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌棕硫,老刑警劉巖髓涯,帶你破解...
    沈念sama閱讀 218,755評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異哈扮,居然都是意外死亡纬纪,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,305評論 3 395
  • 文/潘曉璐 我一進店門滑肉,熙熙樓的掌柜王于貴愁眉苦臉地迎上來包各,“玉大人,你說我怎么就攤上這事靶庙∥食” “怎么了?”我有些...
    開封第一講書人閱讀 165,138評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長护姆。 經(jīng)常有香客問我矾端,道長,這世上最難降的妖魔是什么卵皂? 我笑而不...
    開封第一講書人閱讀 58,791評論 1 295
  • 正文 為了忘掉前任须床,我火速辦了婚禮,結(jié)果婚禮上渐裂,老公的妹妹穿的比我還像新娘豺旬。我一直安慰自己,他們只是感情好柒凉,可當我...
    茶點故事閱讀 67,794評論 6 392
  • 文/花漫 我一把揭開白布族阅。 她就那樣靜靜地躺著,像睡著了一般膝捞。 火紅的嫁衣襯著肌膚如雪坦刀。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,631評論 1 305
  • 那天蔬咬,我揣著相機與錄音鲤遥,去河邊找鬼。 笑死林艘,一個胖子當著我的面吹牛盖奈,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播狐援,決...
    沈念sama閱讀 40,362評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼钢坦,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了啥酱?” 一聲冷哼從身側(cè)響起爹凹,我...
    開封第一講書人閱讀 39,264評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎镶殷,沒想到半個月后禾酱,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,724評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡绘趋,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年颤陶,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片埋心。...
    茶點故事閱讀 40,040評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡指郁,死狀恐怖忙上,靈堂內(nèi)的尸體忽然破棺而出拷呆,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 35,742評論 5 346
  • 正文 年R本政府宣布茬斧,位于F島的核電站腰懂,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏项秉。R本人自食惡果不足惜绣溜,卻給世界環(huán)境...
    茶點故事閱讀 41,364評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望娄蔼。 院中可真熱鬧怖喻,春花似錦、人聲如沸岁诉。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,944評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽涕癣。三九已至哗蜈,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間坠韩,已是汗流浹背距潘。 一陣腳步聲響...
    開封第一講書人閱讀 33,060評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留只搁,地道東北人音比。 一個月前我還...
    沈念sama閱讀 48,247評論 3 371
  • 正文 我出身青樓,卻偏偏與公主長得像氢惋,于是被迫代替她去往敵國和親硅确。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,979評論 2 355

推薦閱讀更多精彩內(nèi)容