DEV Community

Morten Bak
Morten Bak

Posted on

Running Laravel Reverb on a Plesk Server

Here's a small guide on how I got Laravel Reverb running on a Plesk managed server.

Supervisor configuration

I wanted to have Supervisor be in control of the process reverb:start, so I made a .conf in the project root containing this:

[program:appname_reverb]
command=/var/www/vhosts/DOMAIN.TLD/.phpenv/shims/php /var/www/vhosts/DOMAIN.TLD/httpdocs/artisan reverb:start
# the user related to the server/domain
user=USERNAME  
numprocs=1
startsecs=0
autostart=true
autorestart=true
startretries=10
process_name=%(program_name)s_%(process_num)02d
# optional logging:
stdout_logfile=/var/www/vhosts/DOMAIN.TLD/logs/reverb-worker.log
Enter fullscreen mode Exit fullscreen mode

In the above you can change the program name and folder structure to match your setup. I like to prefix my supervisor program name with the apps name. So replace appname_reverb to something saying for your project.

Also user= must be set to the username of the user on the domain.

Activate the process in supervisor

Next we will create a symlink from the above file into /etc/supervisor/conf.d/ by running:

sudo ln -s /var/www/vhosts/DOMAIN.TLD/httpdocs/reverb-dev.conf /etc/supervisor/conf.d/

Ask supervisor to re-read the conf.d directory:
sudo supervisorctl reread

Ask supervisor to update the processes:
sudo supervisorctl update

Now, start your new "program" (Note the usage of the program name we gave it in our conf file:
sudo supervisorctl start appname_reverb:*

Setup additional nginx directives:

In plesk you can add additional nginx directives. We need to do this in order to forward the requests to reverb:

location /app/ {
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header Scheme $scheme;
    proxy_set_header SERVER_PORT $server_port;
    proxy_set_header REMOTE_ADDR $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";

    proxy_pass http://127.0.0.1:8080;
}

location /apps {
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header Scheme $scheme;
    proxy_set_header SERVER_PORT $server_port;
    proxy_set_header REMOTE_ADDR $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";

    proxy_pass http://127.0.0.1:8080;
}
Enter fullscreen mode Exit fullscreen mode

Updating the Laravel .env file

In the .env file we need to make some updates:

REVERB_APP_ID=YOUR_APP_ID_HERE
REVERB_APP_KEY=YOUR_KEY_HERE
REVERB_APP_SECRET=YOUR_SECRET_HERE
REVERB_HOST="DOMAIN.TLD" # your domain without protocol
REVERB_PORT=443 # via SSL
REVERB_SCHEME=https # via SSL

REVERB_SERVER_HOST=0.0.0.0 # = locally on the server
REVERB_SERVER_PORT=8080 # the server internal port
Enter fullscreen mode Exit fullscreen mode

Important thing here is that REVERB_PORT is set to 443 and REVERB_SCHEME is set to https as we want the frontend to connect through https

Checking if it runs

You can check if the reverb is running by either:

  • Looking as the reverb-worker.log, if you enabled this
  • Check via: sudo supervisorctl status to see if the program name is listed here.
  • Check via netstat on the port: netstat -tulnp | grep 8080

Top comments (0)