How to install and monitor Laravel on cPanel

Valerio Barbera

Laravel is one of the most popular PHP frameworks today for creating modern web applications. In this tutorial, you’ll discover how to set up a Laravel project on cPanel.

To install and use Laravel you must have composer installed in your system. Let’s first clarify what Composer is and what it means in Laravel before continuing.

What is cPanel?

cPanel is a user-friendly control panel used to streamline website and server management. It is an online GUI that is based on Linux. You may publish websites, manage domains, arrange web files, create email accounts.

The WebHost Manager administration interface allows users to manage their websites, and also provides hosting providers with the tools they need to manage the server.

What is Composer?

Composer is the package manager of the PHP ecosystem. 

With composer, you can install third-party libraries, create and distribute your own modules, and automate php application installation and distribution. 

So before utilizing Laravel, make sure Composer is set up on your machine.

Step 1: Create subdomain

You can open the cPanel administration dashboard at the port 2083 or “cpanel” subdomain: or

To enter a new subdomain for your brand-new Laravel project, click Subdomain under the Domain menu. If you want to host it under the main domain, skip this section.

Because the Laravel project starts from the public folder, enter the name of the subdomain, such as “myapp”, and place “public_html/myapp” under the documents root. 

Step 2: Create database

To enter a new database for your brand-new Laravel project, click MySQL database wizard under Databases.

Enter the name of the database such as “myapp_db”.

To access the database, create a new user account. Give the newly created database user all the privileges, then click the next button. Save all of this information. You need them to configure the database connection in your Laravel project .env file.


Step 3: Configure Composer 

A Laravel project can be loaded into cPanel in two different methods. Using File Upload, or the Terminal. In this tutorial, we’ll use Terminal to take advantage of Composer to pull it out.

Since Composer is installed as a remote script, you need to make sure that the allow_url_fopen directive is enabled in the .bashrc configuration file in your server.

Run the command below in your terminal:

echo 'alias composer="php -d allow_url_fopen=On /home/$USER_NAME/composer.phar"' >> ~/.bashrc source ~/.bashrc

Download composer using the below command. Curl will give you an error message if you attempt to connect to a website that has a self-signed SSL certificate because curl was unable to validate the certificate. 

In that situation, you could omit certificate validation by using the -k or —insecure flag.

The -O option will save the file with the same name as the remote in the current working directory.

curl -k -O

Set up composer using:

php -d allow_url_fopen=On installer

Step 4: Bring your application into the server

To organize your application, make a folder. Consider the folder myapp and place your project there.

mkdir myapp
cd myapp
git clone .

Step 5: Install dependencies

Composer install dependencies in the vendor directory inside your project:

composer install

Make a fresh application key. This command modifies the APP_KEY setting in your .env file.

php artisan key:generate

Next you must configure the database connection with credentials created at the Step 2:


Next, migrate your database. With this command, all of our schemas are published to the database. The database table is also created by this operation.

php artisan migrate

Establish the proper permissions for the storage folder:

chmod -R 775 storage

Step 6: Make your app publicly accessible

To make your application publicly accessible it should be loaded into the public_html folder of the webserver.

To link the installation of your application with the public_html folder of the webserver, just create a symbolic link.

ln -s /home/user/myapp/public /home/user/public_html

A symbolic link, or symlink, is a file or folder on your computer that points to another file system that is connected to it.Do the same for the storage directory:

ln -s /home/user/my_laravel_app/storage/my_laravel_app/public

Then activate the storage link by running the following command:

php artisan storage:link

Autofix your Laravel application for free

Inspector is a Code Execution Monitoring tool specifically designed for software developers. You don’t need to install anything on the infrastructure, just install the Laravel package and you are ready to go.

If you are looking for effective automation, and the ability to automatically receive code change proposals to fix application errors try Inspector for free. Register your account.

Or learn more on the website:

Related Posts

Laravel Http Client Overview and Monitoring

Laravel HTTP client was introduced starting from version 10 of the framework, and then also made available in all previous versions. It stands out as a powerful tool for making HTTP requests and handling responses from external services. This article will delve into the technical foundations of the Laravel HTTP client, its motivations, and how

Laravel Form Request and Data Validation Tutorial

In this article I will talk about Laravel Form Request to send data from your application frontend to the backend. In web applications, data is usually sent via HTML forms: the data entered by the user into the browser is sent to the server and stored in the database eventually. Laravel makes it extremely simple

Upload File in Laravel

You can upload file in Laravel using its beautiful unified API to interact with many different types of storage systems, from local disk to remote object storage like S3. As many other Laravel components you can interact with the application filesystem through the Storage Facade: Illuminate/Support/Facades/Storage This class allows you to access storage drivers called