How to add https secure access to php website

(*-*)浩
Release: 2023-02-24 09:06:01
Original
4150 people have browsed it

PHP websites generally default to http access. If you want to change it to https secure access, you need to apply for an SSL certificate and install it.

How to add https secure access to php website

#1. Apply for SSL certificate

Go to WoSign or other websites to apply for an SSL certificate. Here we take WoSign as an example. User You need to register a password and set the certificate installation password: (Recommended learning: PHP programming from entry to proficiency)

How to add https secure access to php website

After the certificate application is successful, download The certificate gets a compressed package, and the decompression password is the certificate installation password. After decompression, you get the following file package:

How to add https secure access to php website

Taking the Linux server as an example, you only need to use the for Apache compressed package, after decompression, three files are generated:

How to add https secure access to php website

2. Install openssl on the server, mod_ssl

linux command window through the cloud Convenient installation, command: yum install mod_ssl openssl

After installation, an ssl.conf will be generated in the directory /etc/httpd/conf.d. If it is not generated, upload one yourself

3 , Upload certificate

Create a directory such as ssl under the /etc/httpd/conf.d directory, and upload the three previously compressed files to the newly created ssl directory (/etc/httpd/conf .d/ssl/).

4. Modify the ssl.conf configuration file

Listen 443(https默认端口为443)
LoadModule ssl_module modules/mod_ssl.so
SSLCertificateFile /etc/httpd/conf.d/ssl/www.xxx.com.crt
SSLCertificateKeyFile /etc/httpd/conf.d/ssl/www.xxx.com.key
SSLCertificateChainFile /etc/httpd/conf.d/ssl/root_bundle.crt
Copy after login

where www.xxx.com is the website domain name, replaced by xxx here.

5. Add 301 redirection to the pseudo-static file to point to https access method

See the picture below for the settings

How to add https secure access to php website

6. Restart the service

service httpd restart

After restarting the service, test whether the https domain name method can be accessed normally.

The above is the detailed content of How to add https secure access to php website. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!