How to Install and Setup Laravel 5.6 on Ubuntu 17.10

Image is loading ...
Laravel UbuntuLeave a Comment on How to Install and Setup Laravel 5.6 on Ubuntu 17.10

How to Install and Setup Laravel 5.6 on Ubuntu 17.10

Laravel, a free and open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller architectural pattern is getting more popular nowadays.

Ubuntu is also getting much attention from the developers because of its extreme configurable and open-source nature.

Building powerful applications using Laravel in Ubuntu platform will be lovable to developers.

Installation

1. Install Apache2

Laravel requires a webserver to run. Apache2 is one of the most famous web server used today.

sudo apt-get install apache2

2. Install MySQL

When prompted, answer the questions below by following the guide.

Laravel also need a database server. Most using database with PHP is Mysql.

sudo apt-get install mysql-server mysql-client
sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

Enter current password for root (enter for none): (Press Enter)
Set root password? [Y/n]: Y
New password: (Enter password for mysql DB)
Re-enter new password: (Repeat password)
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y

3. Install PHP and It’s Extensions

sudo apt-get install php libapache2-mod-php php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-mysql php-cli php-mcrypt

4. Install Composer

sudo apt-get install composer

5. Choosing the Project Destination

In your Ubuntu system, you can choose any destination to do your projects. But in my case, I will choose /var/www/html for doing all projects in Ubuntu. It is just the default root folder of the webserver of your Ubuntu system.

cd /var/www/html

5. Creating a New Application

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

If the above command is failing, use

sudo composer create-project laravel/laravel AwesomeProject --prefer-dist

6. Setting Permissions for The Project Directory

You must set permissions for working with your project directory since as by default your system may only allow you to change the contents in your project directory as root.

On Terminal,

sudo chmod 777 -R /var/www/html/AwesomeProject
  • If your project directory is not inside /var/www/html (If you skip 4th step), then use your own directory URL in the top command.

7. Choosing the Code Editor

You can choose your own favorite code editor for editing your project. But in my case, I choose Sublime Text.

https://www.sublimetext.com/3

From the above link, you can download Sublime Text compatible with Linux system.

An alternative way of installing Sublime Text on your Ubuntu system is

sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

8. Directing to the Project Folder and Editing

After installing Sublime Text, direct to your project folder.

On Terminal,

cd AwesomeProject

Open your project using Sublime Text by just typing the below command.

On Terminal,

subl .

9. Creating Database

You have to create a database on your Mysql server which is the DB of your Laravel application.

  • Go to https://localhost/phpmyadmin and Enter username and password(As default, the username will be root and password will be your Mysql password).
  • Click on the New tab
  • Enter a database name
  • Press Create

10. Edit .ENV

Edit the .env file on your project folder. If there is no .env file in your project, you have to create a file and paste all the contents from sampe.env to the file you created and save the file with the .env filename.

DB_DATABASE=(The database name you created earlier)
DB_USERNAME=(Your Mysql username. Usually root)
BD_PASSWORD=(Your Mysql password)

11. Migrate Database

You have to migrate the database from your Laravel application to your localhost.

On Terminal,

php artisan migrate

12. Running the Application

On Terminal,

php artisan serv

It will open a new tab on your browser with address http://localhost:8000.

If you wanted to open the app in another port,

On Terminal,

php artisan serv --port=9000

It will open the app with address http://localhost:9000.

Hi, I'm Syamlal, the co-founder of Redmonark. I'm a developer, writer and also have a little bit of experience in graphic designing.
Website https://syam.me

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top
%d bloggers like this: