How to install Laravel on DirectAdmin server

In this article, we will show you how to install Laravel on CentOS 7 VPS with DirectAdmin control panel. Laravel is a popular PHP open source web application framework with an expressive and elegant syntax. This guide should work just as well on other Linux VPS systems, but was tested and written for CentOS 7 VPS.

This guide assumes that you already have:

  • PHP 5.6.4 or later (PHP-highly recommended)
  • OpenSSL, MBstring, PDO, Tokenizer, PHP and XML Extensions
  • Apache or Nginx

Login to your VPS via SSH

ssh [email protected]

Update the system and install the required packages

yum update
yum install git curl

Install Composer

Composer is a dependency manager for PHP with which you can install packages. Composer will pull in all the libraries and dependencies you need for your project.

curl -sS | php
mv composer.phar /usr/local/bin/composer

Installing Laravel

Installing Laravel is a straightforward process, in this tutorial we will install Laravel using the composer create-project command.

Remove the default files created by DirectAdmin:

rm -rf /home/USERNAME/domains/LARAVEL_DOMAIN_NAME/public_html/*

Go to the root directory of the domain:

cd /home/USERNAME/domains/LARAVEL_DOMAIN_NAME/public_html/

and install Laravel using the composer create-project command (note the dot at the end of the command):

composer create-project --prefer-dist laravel/laravel .

If you are logged in as root or a sudo user, you will need to set the correct properties and permissions:


Don’t forget to change “USERNAME” to a valid username and LARAVEL_DOMAIN_NAME to your domain name.

Setting up DirectAdmin

We need to edit the default web root server document and change it from public_html on public as per Laravel requirements.

Login to your DirectAdmin as an administrator at: https://YOUR_SERER_IP:2222and click on the ‘Custom HTTPD Configurations’ link under the ‘Extra Features’ section. In a new window you will see a list of all your domains, click on the area where you installed Laravel and you will be presented in a new window where you can change your web server configuration.

To change the root document, add the following lines to the “Httpd.conf Customization for” text-area:


If you are using Nginx, you also need to add the following lines so that Nginx can handle requests.

location / {
 try_files $uri $uri/ /index.php?$query_string;

Finally, click on the “Save” button.

That’s all. You have successfully installed and configured Laravel on your CentOS 7 VPS. For more information on Laravel, please refer to the official Laravel documentation ( and for more information on DirectAdmin, please refer to their official DirectAdmin documentation (http: // www.