Pages

How to Install Laravel on a DirectAdmin Server

Thứ Sáu, 15 tháng 9, 2017

In this article, we will show you how to install Laravel on CentOS 7 VPS with DirectAdmin control panel. 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.

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

Login to your VPS via SSH

ssh root@my_server

Update the system and install necessary 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 required libraries and dependencies you need for your project.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

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.

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 VPS. 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 do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Subscribe your email address now to get the latest articles from us

Không có nhận xét nào:

Đăng nhận xét

 
Copyright © 2015. VPS Review.
Design by Herdiansyah Hamzah. Published by Themes Paper. Powered by Blogger.
Creative Commons License