nginx + PHP 下 https的設定。

來源:互聯網
上載者:User

1.   建立key

openssl genrsa -des3 -out server.key 2048

輸入密碼即可。

2.  建立 csr 

openssl req -new -key engir.key -out server.csr

按流程填寫,如

Country Name (2 letter code) [GB]: JP
State or Province Name (full name) [Berkshire]:Tokyo
Locality Name (eg, city) [Newbury]:Bunkyo-ku
Organization Name (eg, company) [My Company Ltd]: HuaWei
Organizational Unit Name (eg, section) :ENGR
Common Name (eg, your name or your server's hostname) []:abc.com
Email Address []:info@it.co.jp    注意郵件地址要和註冊網域名稱時的郵件地址一樣

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:  斷行符號
An optional company name []:  斷行符號

3. 通過  server.key   server.csr  在相應的網站申請 認證

如: http://www.startssl.com/

http://ocsp.godaddy.com/

申請成功後會得到兩個檔案:

gd_bundle.crt   abc.com.crt

4.  設定nginx的配置

上傳 gd_bundle.crt   abc.com.crt 檔案至 nginx的配置目錄下   /usr/local/nginx/conf

執行

cat abc.com.crt gd_bundle.crt > abc.com.chained.crt

Nginx的配置如下:

    server {
        listen       443;
        server_name  ttt.e.com;

        ssl                  on;
        ssl_certificate      /usr/local/nginx/conf/abc.com.chained.crt;
        ssl_certificate_key  /usr/local/nginx/conf/abc.com.key;
        ssl_protocols        SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers          HIGH:!aNULL:!MD5;

        location / {
            root   html;
            index  index.php;
        }

        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
      fastcgi_param HTTPS on;
            include fastcgi.conf;
        }
    }

5.  驗證

執行 

openssl s_client -connect www.godaddy.com:443

最後訪問  https://abc.com  如果能看到認證的資訊,而且串連都正常就OK了。

注意:

安裝nginx 時要加上https模組,編譯時間:

./configure --with-http_sub_module --with-http_ssl_module 

可以用  /usr/local/nginx/sbin/nginx -V  來查看。


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.