Home Backend Development PHP Tutorial How does phpstudy's Apache configuration convert HTTP to HTTPS access?

How does phpstudy's Apache configuration convert HTTP to HTTPS access?

Oct 22, 2018 pm 05:28 PM
http https phpstudy

本篇文章给大家带来的内容是介绍phpstudy的Apache配置SSL成功将HTTP转换为HTTPS访问。有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所帮助。

1、去阿里云购买证书 有免费一年的证书 最多20个 一个证书需要填写一个二级域名 www.xxx.com
开启apache相应配置

#修改httpd.conf文件
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
LoadModule rewrite_module
#去掉上面三行前的"#"
Copy after login

保存退出

在apache目录下的conf目录下新建一个cert目录,将你的证书文件放在这里面

开启php的openssl模块,在phpstudy的“php扩展及设置”里面开启即可

修改httpd-ssl.conf文件,保存退出
在…\Apache\conf\extra目录下,打开httpd-ssl.conf文件(注:先备份一遍,以免出错,因为这个文件的错误我重装phpstuy不下10回)
在文件里定位到 Listen 443 这句话这里,把 从这句话到这个文件结尾的文本 全部注释掉或者删除掉,替换成以下代码

Listen 443   //这里强调一下,如果Listen 443这句代码在这个文件里重复出现了,即重复监听,apache会报错,然后不能启动
SSLStrictSNIVHostCheck off
SSLCipherSuite AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL
SSLProtocol all -SSLv2 -SSLv3
Copy after login
#这里的路径设置你的网站根目录
DocumentRoot "C:\phpStudy\PHPTutorial\WWW"  
#这里xxxxx.com替换成你的域名
ServerName www.xxxxx.com    
#这里xxxxx.com替换成你的域名
ServerAlias xxxxx.com          
#这里的路径设置你的网站根目录    
      
    Options FollowSymLinks ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted

SSLEngine on
#你的公钥文件
SSLCertificateFile "C:/phpStudy/PHPTutorial/Apache/conf/cert/server.crt"
Copy after login

#你的私钥文件(有的机构命名为private或者以你的域名为文件名命名)
SSLCertificateKeyFile “C:/phpStudy/PHPTutorial/Apache/conf/cert/server.key”
#证书链文件(有的机构命名为CA) 我尝试过注释掉这个选项,结果apache不能运行
SSLCertificateChainFile “C:/phpStudy/PHPTutorial/Apache/conf/cert/chain.crt”
重启apache,看看能不能正常启动,如果有异常,尝试把第4步中httpd-ssl.conf代码恢复注释(把#重新加上去,保存退出),再次重启apache,如果此时能够正常启动,则说明httpd-ssl.conf文件中有错误(是不是重复监听了?证书路径对不对?证书是否有效?),请认真检查,直到能够正常启动apache

项目http访问自动跳转https配置根目录 .htaccess

  	Options -MultiViews
 
    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Copy after login

The above is the detailed content of How does phpstudy's Apache configuration convert HTTP to HTTPS access?. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1653
14
PHP Tutorial
1251
29
C# Tutorial
1224
24
How to install phpstudy pro How to install phpstudy pro Apr 02, 2024 pm 03:15 PM

PHPstudy Pro is a web development environment software package that enables rapid deployment and testing of web applications. The installation steps are as follows: Download the installation package from the official website. Run the installer and select the installation path and language. After the installation is complete, launch PHPstudy and configure PHP, MySQL, Apache settings. To verify the installation, enter "localhost" in your browser or run the command "php -v" to check the PHP version.

Why can't phpstudy be installed? Why can't phpstudy be installed? Apr 02, 2024 pm 03:42 PM

PHP Study installation failure may be due to the following reasons: 1. System compatibility issues; 2. Insufficient permissions; 3. File conflicts; 4. Abnormal network connection; 5. Anti-virus software interference; 6. Path problems; 7. System errors. If you encounter a problem that cannot be solved, you can seek support through the PHP Study forum, GitHub or the official website.

Understand common application scenarios of web page redirection and understand the HTTP 301 status code Understand common application scenarios of web page redirection and understand the HTTP 301 status code Feb 18, 2024 pm 08:41 PM

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

How to change the port in phpstudy How to change the port in phpstudy Apr 02, 2024 pm 04:24 PM

In order to change the PHPSTUDY port, follow these steps: Open the Control Panel and navigate to the built-in Web server settings; modify the number in the port number field; save the changes and restart the server; enter the website URL and new port number to verify the changes.

How to read the database in phpstudy How to read the database in phpstudy Apr 02, 2024 pm 04:06 PM

Methods to view the database through PHPstudy include: Direct connection to MySQL Command line Use MySQL Workbench to configure the connection Select the database to view Select the database to view in the left menu through PHPMyAdmin

How to implement HTTP streaming using C++? How to implement HTTP streaming using C++? May 31, 2024 am 11:06 AM

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

Where is the phpstudy configuration file? Where is the phpstudy configuration file? Apr 02, 2024 pm 04:00 PM

The phpStudy configuration file is located in the conf folder of the installation directory. Mainly includes web server, database, PHP and other settings. To access the configuration files, open the following files: ps.conf (main configuration file), config.ini (Web server settings), nginx.conf (Nginx settings), php.ini (PHP settings), and mysql.conf (MySQL settings) ). Modify configuration files with caution and make backup copies before editing.

What should I do if phpstudy cannot be installed? What should I do if phpstudy cannot be installed? Apr 02, 2024 pm 04:03 PM

Solution for unable to install phpStudy: Check whether the system requirements are met. Disable anti-virus software. Turn off the firewall. Run the installer as administrator. Repair corrupted files: sfc /scannow. Try using an alternative installer. Contact phpStudy technical support.

See all articles