How to Install Laravel on a DirectAdmin Server

We will show you how to install Laravel on DirectAdmin server. Laravel is a popular, open-source PHP web application framework with expressive and elegant syntax. This guide should work on other Linux VPS systems as well but was tested and written for a DirectAdmin VPS. Installing Laravel on DirectAdmin server is easy task, just follow the steps below carefully and you should have it installed in less than 10 minutes.

This guide assumes that you already have:

  • PHP 5.6.4 or later (PHP 7 is highly recommended)
  • OpenSSL, Mbstring, PDO, Tokenizer, PHP and XML Extensions
  • Apache or Nginx

1. Login to your VPS via SSH

ssh root@my_server

2. Update the system and install necessary packages

yum update
yum install git curl

3. Install composer

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

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

4. Install Laravel

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

Delete the default files created by DirectAdmin:

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

Switch to the domain root directory:

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

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

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

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

chown -R USERNAME:USERNAME /home/USERNAME/domains/LARAVEL_DOMAIN_NAME/public_html/

Do not forget to change ‘USERNAME’ with the actual username and LARAVEL_DOMAIN_NAME with the actual domain name.

5. Configure DirectAdmin

We need to edit the default web server document root and change it from public_html to public as required by Laravel.

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

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

|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html/public|

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

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

Finally click on the ‘Save’ button.


That’s it. You have successfully installed and configured Laravel on your DirectAdmin Server. For more information about Laravel, please refer to the official Laravel documentation and for more information about DirectAdmin please refer to their official DirectAdmin documentation .


Of course, you don’t have to Install Laravel on a DirectAdmin Server if you use one of our Laravel Hosting services, in which case you can simply ask our expert Linux admins to Install Laravel on a DirectAdmin for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to install Laravel on a DirectAdmin, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.