Laravel 8

CloudPanel v1 is obsolete

CloudPanel v1 is obsolete; check out the CloudPanel v2 Docs.

On this page, we explain step by step how to setup Laravel 8 with CloudPanel.

Installation

In the following example we will setup Laravel under the domain www.domain.com.

Preparation

Before we can start with the installation, we need to create an SSH User, a Database, and a Domain.

When you Add the Domain, make sure to select the Laravel 8 Vhost Template and the right PHP Version.



Document Root

Make sure to point the Document Root to the public directory.

Installation

To install Laravel do the following steps:

  1. Login via SSH to the server e.g. with john-ssh and go htdocs directory:
cd /home/cloudpanel/htdocs/
  1. Delete the project directory which has been created by CloudPanel:
rm -rf /home/cloudpanel/htdocs/www.domain.com
  1. Install via composer:
php7.4 /usr/local/bin/composer create-project --prefer-dist laravel/laravel:^8 www.domain.com
  1. Reset permissions.
cd /home/cloudpanel/htdocs/
clpctl system:permissions:reset www.domain.com 775
  1. Done! You can now open your domain in your browser to see the welcome page.

Daemons

Powered by Supervisor, daemons are used to keep long-running PHP scripts alive.

In case they will be terminated, Supervisor makes sure to restart them automatically.

Installation

  1. Login via SSH to the server e.g. as root user.

  2. Install supervisor

apt install -y supervisor
  1. Create a supervisor configuration file.
touch /etc/supervisor/conf.d/supervisor.conf
  1. Open the configuration file and put the following content:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php7.4 /home/cloudpanel/htdocs/www.domain.com/artisan queue:work redis --sleep=10 --daemon --quiet --queue="default"
numprocs=1
user=john-ssh
autostart=true
autorestart=true
stopsignal=KILL
stdout_logfile=/var/log/supervisor/laravel-worker.log
Attention

Make sure that the php version and the user are correct to avoid permission problems.

tip

For consuming messages in parallel, e.g., when you are working with rabbitMQ, you may increase numprocs.

  1. Update the configuration and start the worker.
supervisorctl reread
supervisorctl update
supervisorctl start laravel-worker:*

With the command supervisorctl you get information about the status, pid, and uptime.