Laravel how to start server in production

27,929

Short answer: DON'T

The web server artisan uses is the PHP built-in web server, which is not for use in any scenario other than development as showcased by this excerpt from the Built-in web server documentation:

Warning This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.

The web server runs a only one single-threaded process, so PHP applications will stall if a request is blocked.

In production you should be using a fully featured web server such as nginx, Apache, lighttpd, etc.

Share:
27,929
IvRRimUm
Author by

IvRRimUm

I am a programmer/hacker.

Updated on January 25, 2020

Comments

  • IvRRimUm
    IvRRimUm over 4 years

    When I run it outputs:

    php artisan serve --port=80
    Laravel development server started on http://localhost:80
    

    How can I make it run in the background, when I exit the console the server stops.

  • IvRRimUm
    IvRRimUm over 8 years
    One way to do it is to use php-fpm
  • Istiaque Ahmed
    Istiaque Ahmed over 4 years
    Laravel + Vue.js app cannot run without php artisan serve. See the post here : stackoverflow.com/questions/51909405/…. WHat should we do in that case ?
  • Bogdan
    Bogdan over 4 years
    @IstiaqueAhmed That is not true, you misinterpreted what the answer you linked to says. You should use a HTTP server like described in the answer above. That will be responsible to serve the Laravel app. As for the Vue part, that's JavaScript that will be executed in the browser and has nothing to do with the server.
  • Istiaque Ahmed
    Istiaque Ahmed over 4 years
    @Bogdan, so can Laravel + Vue.js app be run in XAMPP apache server without executing php artisan serve ?
  • Bogdan
    Bogdan over 4 years
    @IstiaqueAhmed Yes it can, because you only need the HTTP server (in the case of XAMPP it's Apache) to serve the Laravel backend which would return a Blade View that includes the Vue app script.
  • Istiaque Ahmed
    Istiaque Ahmed over 4 years
    @Bogdan, can you have a look at this comment to a related question here : stackoverflow.com/questions/59245577/… ? Unless I executed php artisan serve, the router-view did not work.
  • n8bar
    n8bar over 3 years
    What's the short answer for getting apache to serve it up in production?