Created
October 28, 2019 13:47
-
-
Save WebSofter/4b35957c9bd32327c11b176572fb0577 to your computer and use it in GitHub Desktop.
Run laravel artisian serve script via pm2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"apps": [{ | |
"name": "laravel-app", | |
"script": "artisan", | |
"args": ["serve", "--host=0.0.0.0", "--port=3333"], | |
"instances": "1", | |
"wait_ready": true, | |
"autorestart": false, | |
"max_restarts": 1, | |
"interpreter" : "php", | |
"watch": true, | |
"error_file": "log/err.log", | |
"out_file": "log/out.log", | |
"log_file": "log/combined.log", | |
"time": true | |
}] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. install Node and PM2 module | |
2. Add file ecosystem.config.json to root folder of laravel project | |
2. Run command: | |
$ pm2 start ecosystem.config.json | |
cool~
thank you!
Based on this, it was needed to run php artisan serve as sudo, so then i did like this bellow and also worked pretty well.
{ "name": "laravel_serve", "script": "php artisan serve --host=0.0.0.0 --port=80", "instances": "1", "wait_ready": true, "autorestart": false, "max_restarts": 1, "interpreter" : "sudo", "watch": true, "error_file": "log/err.log", "out_file": "log/out.log", "log_file": "log/combined.log", "time": true }
Actually, using the watch feature isn't the best idea: projects are live updated anyways. You should check for the directories you want to exclude: https://pm2.keymetrics.io/docs/usage/watch-and-restart/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thankyou, you save my time