How to Install Laravel on VPS using ServerAvatar?

Laravel is one of the best PHP Framework you will ever know! At least, According to me, It is! And Yeah, ServerAvatar supports everything that can save Apache and PHP, I love them!

So, Let’s get straight into the tutorial. First of all, Let me tell you that I am not posting this article without testing it. I have 2 sites built with Laravel and Hosted on VPS through ServerAvatar.

It’s not as hard as you think. Let’s get into the tutorial. First of all, Let us consider you have your server connected with ServerAvatar. If not, Follow these guides.

Once done, You are good to go!

Install Laravel on VPS Using ServerAvatar

First, You have to add the domain to your server on which you want to install Laravel. It’s very easy, Just click on the Domains section in your Server Panel, Click on the Add Domain button, Enter the domain name you want to add and you are good to go, Just like the following image.

Add domain - ServerAvatar

It will take about 5-7 seconds to configure the domain on your server. Once done, you can connect to your server through SSH and Start installing Laravel as given below. You can blindly follow the tutorial.

Now, we have to change the Document root in the Apache configuration file for the domain. Apache configuration file for your domain is located at /etc/apache2/sites-available/your-domain.conf.

Execute the following command to edit the configuration file.

$ nano /etc/apache2/sites-available/YOUR_DOMAIN.conf

You have to replace YOUR_DOMAIN with the domain or subdomain on which you want to install Laravel. This file will look like:

Apache configuration file

In this image, You will see one Directive named DocumentRoot. Change Document root,

FROM: /var/www/YOUR_DOMAIN

TO: /var/www/YOUR_DOMAIN/public

Change the path everywhere you can see that path in the whole file! Once done, You can follow the tutorial.

Now, There are three ways to Install Laravel. They are:

  1. Install Fresh Laravel
  2. Install Laravel from Git Repository
  3. Upload Laravel files and Install

Let’s start with the first and the Easiest!

1. Install Fresh Laravel

To install the brand new Laravel project, You have to run the following commands.

$ cd /var/www/YOUR_DOMAIN

$ rm -rf *

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

Make sure you are in the right directory before running rm -rf * because it is used to remove all the files in current directory. Without removing the files in the domain directory, You will not be able to install laravel.

2. Install Laravel from Git Repository

It’s always great to use git repositories. If you have your project on git repository, You can run following set of commands to install Laravel project from Git repository.

$ cd /var/www/YOUR_DOMAIN

$ rm -rf *

$ git init; git clone GIT_REPOSITORY_URL

$ mv REPO_NAME/* ./

By running these commands, Your project will be cloned from your repository. Now, We have to update dependencies using the following command.

$ composer update

So, this is how you can setup Laravel project on ServerAvatar from Git repository.

3. Upload Laravel files and Install

It’s Easy too! You just have to upload the laravel files in the /var/www/DOMAIN directory. You can create FTP Account to upload files from Server Panels. Just like we added the domain, You can add FTP Account and upload files using FileZilla or any other FTP client.

 

So, This is how you can install laravel on VPS using Hosted with ServerAvatar.com. The Key Part is changing the DocumentRoot. So, Don’t miss that part. In case if something goes wrong, You can contact us using Live support and we will solve anything for you. We are Great at Laravel 😉 .

Leave a Reply

Your email address will not be published. Required fields are marked *