Start Laravel with Webserver

Asked

Viewed 227 times

1

I have Laravel installed in a Webserver, but every time I need to test a page I have to type in the terminal: php Artisan serves --host=IP_DO_SERVIDOR.

How do I get Laravel to start with Webserver ?

  • Is this server Linux? Which distro?

  • Ubuntu 16.04, Laravel 5.4.15, PHP 7.0.15, Myssql 5.7.17.

  • Install a good web server, create a vhost and be happy!

1 answer

0

To run a script while starting Ubuntu, you can use a cronjob (there are other ways, this I find easier).

To do this, create a file with the command you want, and put the extension .sh. In case, you can create in your home (/home/[usuario]) a file called laravel_start.sh and include in it the php artisan serve --host=IP_DO_SERVIDOR. After saving, run the following command:

chmod +x /home/[usuario]/laravel_start.sh

This gives permission to run the file.

Then run:

crontab -e

This will open the task file of cron, probably in the nano. Go to the end of the file and put the following line:

@reboot /home/[usuario]/laravel_start.sh

Save the file and come out pressing ctrl+x and confirming the change.

Boot it and see if it starts right.

  • I really appreciate your detailing, but when typing crontab -e, then it is presented these files

  • I really appreciate your detail, but when entering @reboot /home/[user]/laravel_start.sh in crontab, no change confirmation was requested.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.