Configure SSR on a Laravel Inertia Project using Supervisor on Plesk

Published 2 weeks ago 2 min read

This guide is for anyone looking to configure SSR using a Laravel Intertia project on Plesk Linux. First follow this to enable SSR within your code : https://inertiajs.com/docs/v2/advanced/server-side-rendering

You will need to first have node version at least 22 and PHP version 8.3 or 8.5 according to project configuration. You don’t need to manually install node, just install the Node.js toolkit extension and then install node version. For this example i will be using PHP8.5 with Node 22 ( /opt/plesk/node/22/bin/node ).

1. SSH into your server and install supervisor

sudo apt-get install supervisor # Ubuntu/Debian

2. Create a Supervisor config for the SSR process, create a new config file:

sudo nano /etc/supervisor/conf.d/inertia-ssr.conf

3. Paste in the following. Remember to replace the your node version and php version as well as the vhosts path and user needs to be user under your plesk :

[program:inertia-ssr]
command=/opt/plesk/php/8.5/bin/php /var/www/vhosts/codenathan.com/httpdocs/artisan inertia:start-ssr
directory=/var/www/vhosts/codenathan.com/httpdocs
environment=PATH="/opt/plesk/node/22/bin:/opt/plesk/php/8.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=codenathan.com_v0z1u2fl0m
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/vhosts/codenathan.com/httpdocs/storage/logs/ssr.log
stopwaitsecs=3600

4. Now run the following commands

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start inertia-ssr
sudo supervisorctl status

5. Now after every deployment you need to configure the following:
cd /var/www/vhosts/codenathan.com/httpdocs
npm run build:ssr
php artisan inertia:stop-ssr