Front end rear mounting configuration] [SSL certificate phpStudy the environment, access to encryption (Https)

Disclaimer: This article is a blogger original article. Reproduced please contact bloggers authorization. Bloggers public micro-channel number] [Department of Knowing and Doing the campus. https://blog.csdn.net/cxh_1231/article/details/90318387
  • Description: From the article: ① SSL certificate request, the SSL certificate ②phpStudy configuration environment, ③http access protocol is automatically switched to the https protocol, three mounting configuration about the SSL certificate.
  • Focus on micro-channel public number [ knowing and campus sinks ] to learn more WUTer knowledge.
  • >> Click here for a summary WUTer experimental computer science
  • Remember: Paper come Zhongjue know this practice is essential.

First, what is an SSL certificate?

SSL certificates are what?

Baidu Encyclopedia is so explained:

SSL certificate is a digital certificate one, similar to the electronic copy of a driver's license, passport and business license. Because the configuration on the server, also known as SSL server certificate.

SSL certificates that comply with the SSL protocol, digital certificate authority CA trusted certificate, issued after verifying the identity of the server with server authentication and data encryption.

Simple to understand it is to realize the transmission of data encryption.

When your site uses SSL certificates link the browser address bar will show https, so your customers know your site is safe and reliable, users can increase the reliability of the site.

Second, what is PHPStudy?

phpStudy is a PHP program integrated debugging environment package.

The package integrates the latest of the Apache + PHP + MySQL + phpMyAdmin + ZendOptimizer , one-time installation, without any configuration, it is very convenient and easy to use PHP debugging environment · The program includes not only the PHP debugging environment, also includes development tools, · the development of manuals and other learning PHP just a short package.

Can be simply understood as, if you write in PHP a Web server, you need to deploy to the server, you need to use this integrated environment to run phpStudy you write PHP program.

Which, phpStudy own MySQL database, PHP build enough to meet the site.

In fact, much like the siting and PHPStudy there xampp integration software and so on. If you are interested you can go to look at xampp, both have great similarities.

Third, the application cloud Ali Free SSL Certificates

Before applying for an SSL certificate, first you need to have a domain name. The domain name belongs to the account and the account is not required to apply the same SSL certificate. That domain name can be in any account, as long as you have the right to control DNS.

The following describes how to apply for Ali cloud free SSL certificate.

1. Log Ali cloud into the console, the search SSL Certificate Services

As shown below, you can search for [SSL] in [products and services] column, [SSL] certificate under [Security (cloud shield)] module.

Click to enter.

2, buy SLL certificate

As shown below, click [buy] in [Certificate SSL Certificate in Management Console

3, purchasing certificates

As shown below, select [free] type DV SSL certificates, you can purchase.

The certificate is a certificate for free, so a certificate can only bind a domain name (such as: baidu.com and www.baidu.com for the same domain name, and baike.baidu.com was another domain).

4, requesting the issuance of a certificate

After the purchase SSL certificates, SSL certificate in [console] to see just purchased a certificate status is not issued.

Click [apply] to apply for the certificate binding domain.

You can fill out the form above.

  • If the certificate is in the same domain and Ali cloud account, select [Auto] to verify DNS.
  • If the SSL certificate and domain name are not under the same Ali cloud account, select [manual] DNS verification. Also choose File Validation (requires a server)

Click Next.

Author different accounts, for example, you need to manually configure the domain name in TXT records, as shown below:

DNS [domain name] under the cloud resolve this record is added to the map. As shown below:

Then in the certificate request page, click on [validation] to show [the validation is successful], click [] to submit audit.

It normally takes a few minutes will apply through.

Free certificate will not call you to verify, but does not rule there are exceptions. 

Then, the certificate status: Under review. As shown below.

5, download the certificate

After approval, documents relating to the certificate to download. As shown below:

点击需要配置到服务器的证书后面的【下载】按钮,即可下载对应的证书文件。

如上图,有Tomcat、Apache等环境。

使用phpStudy服务器环境,推荐使用Apache。

下载服务器类型为Apache的SSL证书文件后,文件中包含三个文件,如下图所示:

 下载的压缩包文件名中包含该证书所属的域名,以及该证书适配的服务器环境。

然后将这些文件上传到服务器里,接下来需要在服务器里将这个SSL证书配置到phpStudy。

 

四、SSL证书配置至phpStudy环境下

1、上传证书,解压

前面我们已经下载好Apache服务器的证书,将证书上传至服务器,解压至任意目录即可,建议统一存放。

下图为笔者SSL证书存放在服务器中的路径,这个路径记住!后边要用!!!

2、开启SSL服务

在phpStudy主面板中,点击【其他选项菜单】→【PHP扩展及设置】→【PHP扩展】,将【php_openssl】参数勾选,如下图所示:

这时,打开【httpd.conf】文件,可以看到“LoadModule ssl_module modules/mod_ssl.so”这行代码前没有“#”。

如果依旧有“#”,可手动删除。

然后将【httpd.conf】这个文件滑到最底下,将下图中红框内的那行代码前的井号#删除:

 然后保存这个文件,关闭即可。

到这里,就开启了SSL服务。

3、配置SSL文件

在phpStudy安装目录下,找到【httpd-ssl.conf】文件,一般目录如下图所示;

将这个文件使用记事本打开。

默认的文件中自带很多注释代码,如下图所示,都是如何配置这个SSL文件的说明。如果你是技术大牛,可以根据这些英文提示,自行配置SSL证书文件。

其实这些文件,只需要配置几个地方就可以。但是看着这么多的文字,有点乱糟糟的……

所以笔者将该文件内原有代码删除,将下面代码复制进去,然后修改几个地方就可以:

Listen 443

<VirtualHost *:443>
    #双引号内为index文件的路径,替换成自己的
    DocumentRoot "C:\WWW\web"

    #后边跟该SSL证书文件的域名
    ServerName wx.domain.com

    #同上
    ServerAlias wx.domain.com

    SSLEngine on
    SSLProtocol TLSv1 TLSv1.1 TLSv1.2
    SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5

    #这后边跟自己证书文件的路径,如下例子所示:
    SSLCertificateFile C:\WWW\cert\wx\wx.domain.com_public.crt        #Public证书文件,替换成自己的
    SSLCertificateKeyFile C:\WWW\cert\wx\wx.domain.com.key            #KEY证书文件,替换成自己的
    SSLCertificateChainFile C:\WWW\cert\wx\wx.domain.com_chain.crt    #chain证书文件,替换成自己的

  #下面双引号内同上
  <Directory "C:\WWW\web">
      Options Indexes FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
     Require all granted
  </Directory>
</VirtualHost>

如果该服务器有多个域名访问,可以配置多个SSL证书,只需要将:

<VirtualHost *:443>
    ……
    ……
</VirtualHost>

内的代码重复复制在后边即可。

如下图,笔者就在一个服务器上配置了两个域名,并且均配置SSL证书:

After the above configuration file, restart phpStudy can.

If Apache does not start, if there are spelling errors check code.

Then you can test the domain name in the browser https access.

 

Fifth, the mandatory access https

 If you need to force https access, ie access using the http, https automatically switches to visit, it is very simple.

Just create a [.htacess] file in the root directory of the Web project, as follows:

Then copy the code below into it, and save it:

RewriteEngine on

RewriteBase /

RewriteCond %{SERVER_PORT} !^443$

RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

If you do not know how to create the only file extensions, you can copy one from elsewhere.

In this case, use the http protocol to access the Web project, then automatically switch to the https protocol.

VI References:

  1. phpStudy environment Install SSL Certificate Course - phpStudy technical articles: http: //phpstudy.php.cn/jishu-php-2958.html

Guess you like

Origin blog.csdn.net/cxh_1231/article/details/90318387