Home>Article>Backend Development> How to add https secure access to php website
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.
#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)
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:
Taking the Linux server as an example, you only need to use the for Apache compressed package, after decompression, three files are generated:
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
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
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!