Install laravel app on a fresh Ubuntu server

7 Nov

Install laravel app on a fresh Ubuntu server

In this blog we will discuss how to install laravel on Ubuntu server. By fresh ubuntu server, we mean that we got an Ubuntu server with no packages installed in it.

We have to install php, apache and mysql server before deploying the laravel app. In this article all lines in red color are commands to be run in terminal.

Install laravel on Ubuntu server

1) Let’s start with first upgrading packages.

apt-get update && apt-get upgrade

2) Second step is to install apache 2.

sudo apt-get install apache2

3) After that we can install php and php apache 2 module.

sudo apt-get install php libapache2-mod-php

4) In the fourth step we can install myql server.

sudo apt install mysql-server

5) open the file
/etc/apache2/sites-available/000-default.conf

using a text editor like vim, and then change
DocumentRoot /var/www/html to DocumentRoot /var/www/html/public

6) We need to install more php packages now. Run the following commands

sudo apt-get update
sudo apt install php-xml

sudo apt-get install php-mbstring
sudo apt-get install php-mysql

7) Enable rewrite mode
sudo a2enmod rewrite
/etc/init.d/apache2 restart

8) then go to /var/www/html
deploy your laravel app here. If you laravel app already has already a git repository, then you can clone your code here. For that first you have to install git and then run git clone. Then you have to install composer and then run composer install.

(We will update this blog with more details on that later)

9) Create database and configure it in .env

We have already installed mysql server on the Ubuntu server. Now we have to create a user and then database.

We have to login to the mysql server from the terminal first

just type mysql from the terminal

mysql

Now you can start adding the user,

CREATE USER ‘my_user’@’localhost’ IDENTIFIED BY ‘my_password’;

That will create a user.

Now we have to create a database.

CREATE DATABASE my_db;

After that we have to give privileges for the user my_user to the db my_db.

grant all privileges on my_db.* to my_user@localhost identified by ‘my_password’;

That’s the basics of on how to Install laravel on Ubuntu server. If you face any issue to Install laravel on Ubuntu server, please post the issues and we will look in to that for you.

Leave a Reply

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