Install Laravel on Ubuntu 18.04 with Apache, MySQL, PHP7 (LAMP) stack

How to install Laravel, phpmyadmin, php 7.2 and LAMP on Ubuntu less than 10 minute!

Step 0 — update your system, Install prerequisites

sudo apt update
sudo apt install -y git curl wget zip unzip

Step 1 — Install Apache:

sudo apt install apache2
sudo systemctl status apache2

Step 2 — Adjust the Firewall to Allow Web Traffic

sudo ufw allow in "Apache Full"

Attention: Enabling mod_rewrite

sudo a2enmod rewritesudo systemctl restart apache2

Step 3— Install MySQL:

sudo apt install mysql-server
sudo mysql_secure_installation
sudo mysql -u root -p

Step 4— Install PHP:

sudo apt install php libapache2-mod-php php-mysql
sudo apt install php7.2-common php7.2-cli php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-mbstring php7.2-bcmath php7.2-imap php7.2-xml php7.2-zip

Step 5— Tell the web server to prefer PHP files over others, so make Apache look for an index.php file first.

sudo nano /etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.xhtml index.htm
sudo systemctl restart apache2


sudo nano /var/www/html/info.php

Step 6— Install composer on Ubuntu

curl -sS | phpsudo mv composer.phar /usr/local/bin/composer# this make the composer executable -> sudo chmod +x /usr/local/bin/composer# check versioncomposer --version

Step 7 — Install Fresh Laravel Project on Ubuntu

cd ~composer create-project --prefer-dist laravel/laravel my_linux_app
cd my_linux_app
php artisan serve

Step 8 — Verify Laravel Installation:


Note 0:

sudo a2enmod rewrite

Note 1:

git clone
sudo composer install

Note 2:

chmod -R 755 ~/my_linux_app
chmod -R 777 ~/my_linux_app/storage

Note 3:

php artisan key:generate

Note 4:

sudo mysql -u root -p
mysql> CREATE DATABASE laravel;mysql> GRANT ALL ON laravel.* to 'laravel'@'localhost' IDENTIFIED BY 'secret';mysql> FLUSH PRIVILEGES;mysql> quit
mv .env.example .env
php artisan config:cache
php artisan make:auth
php artisan migrate

Note 5:

cd /var/www/html
composer create-project --prefer-dist laravel/laravel my_linux_app

Note 6:

sudo apt install phpmyadmin php-gettext
sudo systemctl restart apache2

Previous Tips You will Love:

Posting daily about Python, Nuclear Physicist PhD