Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Q8Xbox's avatar
Level 1

Run octane cmd in production

I have laravel 10 site which i want to run it over octane Swoole cmd using pm2 in Ubuntu server. Is there instructions that guide me through do that since the use of mp2 it to make the cmd run always as long as the server working and it will not end when terminal closed.

0 likes
8 replies
martinbean's avatar

@q8xbox You’re meant to use something like Supervisord to keep the Octane process running on the server without needing to be connected via SSH or whatever.

Q8Xbox's avatar
Level 1

@martinbean yes, i used pm2 to run python and next.js application before but not sure how it will work with laravel sites

martinbean's avatar

@Q8Xbox I have no idea what “pm2” is, but a quick Google suggests it’s for Node.js applications:

Advanced process manager for production Node.js applications.

So I’m not sure why you keep mentioning it when talking about a Laravel and Octane application? 🤷‍♂️

The Laravel Octane docs tell you the commands you need to run to start an Octane-powered application. As per my last comment, you need to use something like Supervisord to run this command as a daemon on your server without you having to have an active SSH session or whatever.

Q8Xbox's avatar
Level 1

@martinbean It is my first time so that is why i don't know the difference between the two so still learning 😅

Iagoss's avatar
Iagoss
Best Answer
Level 1

As @martinbean commented, pm2 serves as a process manager and load balancer for Node.js applications and, as far as I know, it cannot be used to keep a Laravel process running. To have Octane working, you need to have the php artisan octane:start command running on the server.

To ensure it runs, you can use Supervisor, which is a process monitoring tool for Linux, meaning it will keep your process always running.

1- Install Supervisor

sudo apt-get install supervisor

2- Configure Supervisor Go to the /etc/supervisor/conf.d directory and create a new configuration file (e.g., laravel-octane.conf) and put the code below in it.

[program:laravel-octane]
process_name=%(program_name)
command=php /PROJECT_PATH/artisan octane:start
autostart=true
autorestart=true
user=root
redirect_stderr=true
stdout_logfile=/PROJECT_PATH/octane.log
stopwaitsecs=3600

Don't forget to replace PROJECT_PATH with your Laravel project's path.

3- Update Supervisor configurations and start the Octane process

sudo supervisorctl reread
 
sudo supervisorctl update
 
sudo supervisorctl start "laravel-octane"

This should be enough to keep the Octane process always running on your server. By default, Octane will run as localhost:8000, but you can change this by passing additional parameters to the process that Supervisor is monitoring. See the Laravel Octane documentation: https://laravel.com/docs/10.x/octane

Q8Xbox's avatar
Level 1

@Iagoss I have some questions to ask: 1- If site file changes or updated will that change what octane serve ? 2- currently the site run under domain name for example domain.com is there extra configuration need to be added to config file ?

martinbean's avatar

I have some questions to ask: 1- If site file changes or updated will that change what octane serve ?

@Q8Xbox Why don’t you read the docs? You should be if this is your “first time” and you’re “still learning”.

https://laravel.com/docs/11.x/octane#watching-for-file-changes

You should also probably learn to build PHP and Laravel applications “normally” instead of complicating matters with Octane.

Q8Xbox's avatar
Level 1

@martinbean sorry for that my main issue is that i don't like ready at all but i do my best as much as possible since prefer watching videos more clearer for me since it is practical. @lagoss explain very well but still not catch everything properly but after i saw below video now i understand exactly his steps. https://youtu.be/eX7D40y9qv8?si=D7x1u__OOKew3H0L

I have questio to ask when you said "learn to build PHP and Laravel applications “normally” instead of complicating matters with Octane." Could you explain this little more ? I know how to build applications with laravel and soon will move to use Inertia React to do some personal project but The use of Octane will boost our laravel applications performance when it comes to responses also increase the number of requests to the server with the advantage of it caching system ?

Please or to participate in this conversation.