Laravel php artisan serve to mimic HTTPS

后端 未结 3 949
失恋的感觉
失恋的感觉 2021-01-04 00:38

I have been searching around to see if there is a way I can mock SSL for local development using Laravel\'s artisan to serve HTTPS with no luck.

Is this possible and

3条回答
  •  悲&欢浪女
    2021-01-04 00:56

    If you're using xampp, then you can setup HTTPS locally with xampp (this post is also useful for setting up HTTPS) and then you can:

    1. move your project to htdocs folder and visit it with https://localhost/projectFolder/public/

    2. or just create a special VirtualHost in httpd-vhosts.conf for this project (always point to that public folder, this is from where the project is running) and then visit it with https://localhost/ in this example (you can of course, run it on a subdomain if you want to)

      
          ServerName localhost
          DocumentRoot "c:\pathToYourProject\projectFolder\public"
          
              Options All
              AllowOverride All
          
      
      
      # this should ensure https (this is mentioned in the stackoverflow post, that I linked as useful
      
          ServerName localhost
          DocumentRoot "c:\pathToYourProject\projectFolder\public"
          SSLEngine on
          SSLCertificateFile "conf\ssl.crt\server.crt"
          SSLCertificateKeyFile "conf\ssl.key\server.key"
          
              Options All
              AllowOverride All
          
      
      

    Theoretically, when you're using this method, you don't even need php artisan serve (tbh I'm not entirely sure if it has any purpose in this case).

提交回复
热议问题