How to run a laravel/lumen application in the background


The nohup command tells the shell to run the command without hanging up when the terminal is closed. This means that you can run a command in the background and it will continue to run even after you close the terminal window.

To use the nohup command, simply prepend it to the command that you want to run in the background. For example, to run the php -S localhost:8002 -t public command in the background, you would use the following command:

nohup php -S localhost:8002 -t public & 

You can then close the terminal window without stopping the server. To check if the server is running, you can use the following command: 

netstat -an | grep 8002 

 If the server is running, you will see a line that looks like this: 

tcp4 0 0 localhost:8002 localhost:LISTEN 



To stop the server, you can use the following command: 


killall php 

This will stop all PHP processes, including the Lumen server. Here are some additional tips for running Lumen servers in CentOS 8: You can use the supervisord service to manage multiple Lumen servers. You can use the pm2 process manager to manage multiple Lumen servers and automatically restart them if they crash.

No comments:

Post a Comment