How to Deploy Laravel Project on Linux Server

In this tutorial you will learn about the How to Deploy Laravel Project on Linux Server and its application with practical example.

In this Laravel deploy project on linux ubuntu server tutorial. II’ll show you how to deploy laravel project app on linux ubuntu server.

In this tutorial I’ll demonstrate you two different methods to deploy laravel project on linux server. The first method is deploy laravel project using git repo. And second method is to create a new Laravel project inside our project directory. And at the end of these solutions, adjust vertual host file.

Deploy Laravel Project App with Apache on Linux Ubuntu Server

In this tutorial we will use two different methods to deploy laravel project on linux ubuntu server.

first of all, we are required to install all the required dependencies on the linux ubuntu server. So use the following command to install all dependencies on linux ubuntu server:

Above commands will have installed composer on the linux server because install Laravel’s dependencies using composer update or composer install command.

Deploy Laravel Project Using Clone GIT Repository

To deploy Laravel from it’s official GitHub repository. And deploy laravel inside the default document root of Apache webserver. That means, go to /var/www/html and run the git clone command, as follow:

Deploy a New Laravel Project

To deploy a fresh Laravel project on your linux server. Now, you can use the composer and run the following command on your terminal as follow:

Now, you need to update .env file and generate an encryption key. So use the following command for that:

The above commands will copy the file from .env.example to .env and generate an encryption key.

Setup VertualHost On Linux Server

Now, you need to adjust vertualhost in your linux server. To open your virtual host file in edit mode, execute the following command.

Do not forget to replace 000-default.conf with the name of your virtual host file if you are using multiple virtual hosts on your server. Now, add /public at the end of the document root so that Apache will route all the traffic inside the /public route that holds the main index.php file of our project. For example, Here is the updated default virtual host configuration file without comments.

Once you done with updating virtual host file, press CTRL+X followed by Y followed by the Enter key to save the updated virtual host file.

Finally, we are good to restart the Apache server to apply the changes. Run the following command to restart the Apache server.

Now, your apache server successfully restarts, now you can  access your Laravel project in the browser.

In this tutorial we have learn about the How to Deploy Laravel Project on Linux Server and its application with practical example. I hope you will like this tutorial.