1. Navigate to Apache directory in XAMPP.
In regular install it’s in C:\xampp\apache.2. Create a folder in that page.
This is where we will store our cert. In this example I will create “crt” folder. So we will have C:\xampp\apache\crt3. Add this files.
4. Edit cert.conf and Run make-cert.bat
Change {{DOMAIN}} text using the domain we want to use, in this case site.test and save. Double click the make-cert.bat and input the domain site.test when prompted. And just do enter in other question since we already set the default from cert.conf.
Note: I don’t know how to do text replace in .bat script, if you do, let me know in the comment how to do it and I will update make-cert.bat to automatically replace the {{DOMAIN}} with the domain input.
5. Install the cert in windows.
After that, you will see site.test folder created. In that folder we will have server.crt and server.key. This is our SSL certificate. Double click on the server.crt to install it on Windows so Windows can trust it.6. Add the site in Windows hosts
- Open notepad as administrator.
- Edit C:\Windows\System32\drivers\etc\hosts (the file have no ext)
- Add this in a new line:
- 127.0.0.1 site.test
7. Add the site in XAMPP conf.
We need to enable SSL for this domain and let XAMPP know where we store the SSL Cert. So we need to edit C:\xampp\apache\conf\extra\httpd-xampp.conf And add this code at the bottom:- ## site.test
- <VirtualHost *:80>
- DocumentRoot "C:/xampp/htdocs"
- ServerName site.test
- ServerAlias *.site.test
- </VirtualHost>
- <VirtualHost *:443>
- DocumentRoot "C:/xampp/htdocs"
- ServerName site.test
- ServerAlias *.site.test
- SSLEngine on
- SSLCertificateFile "crt/site.test/server.crt"
- SSLCertificateKeyFile "crt/site.test/server.key"
- </VirtualHost>
Tips: In XAMPP conf, as you can see you can change the domain root directory if needed. Eg. as sub-dir in htdocs.
8. Restart your browser and Done!
This is required to load the certificate. And visit the domain on your browser, and you will see green lock!Chương trình học
Các bài học
Bài học trước Bài học tiếp theo
Chương trình học
Bao gồm Module, Chương, Bài học, Bài tập, Kiểm tra...Chương trình học
Bài học trước Bài học tiếp theo