Đôi khi chúng ta cần phải truy cập vào địa chỉ trong localhost của chúng ta bằng địa chỉ:
https://localhost
Chúng ta gặp nhau tại đây là do các bạn đang vướng phải vấn đề không truy cập được, và đây là hướng dẫn để các bạn có thể làm được điều đó.
Sometimes some websites require https to work. This can be useful in those cases.
This has been tested with XAMPP (PHP 7.0.8) on Windows 7. Please see the Reference links at the end if in confusion about some step.
STEP 1: Editing Configs
Open:C:\xampp\php\php.ini
Remove semi colon (;) in front of the line, if there is any:
extension=php_openssl.dll
date.timezone=Europe/London
zend_extension="C:\xampp\php\ext\php_xdebug.dll" 
Now, open:
C:\xampp\apache\conf\httpd.confMake sure that this is uncommented (no semi colon - ;)
LoadModule rewrite_module modules/mod_rewrite.so
User user
User john
STEP 2: Create the Certificate
Open Command Prompt, then enter:cd /D C:\xampp\apache
Now enter:
makecert
C:\xampp\apache>makecert
Loading 'screen' into random state - done
Generating a 1024 bit RSA private key
............................++++++
.....................................++++++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
It will say:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
GB (for United Kingdom). You can find yours here: http://www.worldatlas.com/aatlas/ctycodes.htmFor some fields you can just press enter to skip fields. They are not necessary for the certificate to work.
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Then it will say:
Enter pass phrase for privkey.pem:
Now this should succeed with a message:
writing RSA key
Signature ok
subject=/C=GB/ST=Some-State/O=Internet Widgits Pty Ltd/CN=localhost
Getting Private key
        1 file(s) moved.
        1 file(s) moved.
-----
Das Zertifikat wurde erstellt.
The certificate was provided.
Press any key to continue . . .
STEP 3:
Now go to start menu, type the following and enter:certmgr.msc
Click Next. It will ask to choose the certificate file. Click Browse and choose
C:\xampp\apache\conf\ssl.crt\server.crt
Click Next. Next again, then Finish.This will bring you a message. Click Yes. Then it should say Import was successful. Click OK.
STEP 4: Restart XAMPP services
I just stopped the Apache and MySQL service from XAMPP Control Panel, and when they stopped, I just started them again.This should now enable https on localhost.
STEP 4: Now test!
Now access https://localhost in your browser.Đến bước này nếu không được nữa thì kiểm tra xem xampp của chúng ta đã port 443 có free hay không nếu không thì chúng ta phải làm cho xampp chạy được port 443 mới được, thường thì các chương trình máy ảo dễ bị đụng port này dùng để share.
Disable port này là được nha các bạn.
Chúc các bạn thành công.
 

Không có nhận xét nào:
Đăng nhận xét