Installing Laravel PHP Framework on Ubuntu 16.04 for Apache Server

Installing Laravel PHP Framework on Ubuntu for Apache Server

Wiki Laravel is a free, open-source[3] PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller (MVC) architectural pattern and based on Symfony.

Install on Ubuntu 16.04

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1 php7.1-mcrypt php7.1-xml php7.1-gd php7.1-opcache php7.1-mbstring
sudo apt-get install apache2 libapache2-mod-php7.1
sudo

cd /tmp
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

sudo add-apt-repository –remove ppa:ondrej/php

cd /var/www/html
sudo composer create-project laravel/laravel YOUR_PROJECT –prefer-dist

sudo chgrp -R www-data /var/www/html/your-project
sudo chmod -R 775 /var/www/html/your-project/storage

cd /etc/apache2/sites-available
sudo nano laravel.conf

<VirtualHost *:80>
ServerName localhost

ServerAdmin [email protected]
DocumentRoot /var/www/html/your-project/public

<Directory /var/www/html/your-project>
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

sudo a2dissite 000-default.conf
sudo a2ensite laravel.conf
sudo a2enmod rewrite
sudo service apache2 restart

sudo apt-get install php-common php-mysql php-gd mysql-server
(put a mysql password)

mysql -u root -p
than create user laravel with password laravel

CREATE USER ‘laravel’@’localhost’ IDENTIFIED BY ‘laravel’;
GRANT ALL PRIVILEGES ON * . * TO ‘laravel’@’localhost’;
quit

mysql -u laravel -p
create database testapp;
quit

cd /var/www/html/your-project
sudo nano .env

DB_DATABASE=testapp
DB_USERNAME=laravel
DB_PASSWORD=laravel

sudo service apache2 restart

sudo php artisan migrate

sudo php artisan serve

See laraver default page here
http://127.0.0.1:8000

or
http://localhost

Leave a Reply

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