Install Laravel 5.0+ LAMP + PhpMyAdmin on CentOS 7.2

Now a days PHP frameworks like Laravel, Codeignitor and CakePHP etc getting popular as they provide more security and flexibility. MVC programs are developed fast with these frameworks. Unlike normal core PHP, PHP Frameworks requires installation.  We can install Laravel via composer. In this guide we are going to install Laravel  5.0 on LAMP  with PhpMyAdmin.

First Lets update

yum update

LAMP (Linux + Apache + MySql + PHP) Installation 

Now we are going to install the LAMP package which is basic building block for a Linux Server. To install Laravel ,we must need a LAMP server running.  If you have already LAMP installed You can skip this step.

Install Apache

The chkconfig command used to set apache automatically on after a server start.

yum install httpd
service httpd restart
chkconfig httpd on

Install MySql Server

Now we are going to install MySql  server which will handle our databases.

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
ls -1 /etc/yum.repos.d/mysql-community*
yum install mysql-server

 

Now lets start MySql Server

systemctl start mysqld

 

You can restart or stop also by using restart or stop command.

systemctl restart mysqld

 /

systemctl stop mysqld

 

Now lets move to MySql setup, use following command to enter into setup.

mysql_secure_installation

Just hit enter as you don’t have any MySql root password. After that enter your desired password and continue. You can use “Y” for all next prompts.

MySql Server Installation Finished.

Install EPEL release and REMI

Install EPEL

yum install epel-release

Install REMI

wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm

Now Open Remi Config file and change Enable 0 to Enable 1 in [php] and [php56] section.  Basically help to install PHP 5.6 instead of PHP 5.4.

Use following command to open Remi Config file.

vi /etc/yum.repos.d/remi.repo

Install PHP

Use following command to install PHP 5.6. Make sure you have edited the remi file via above command else this command will install PHP 5.4.

yum install php

You can now check your PHP version by using below command

php -v

 

PhpMyAdmin Installation 

Now we are going to install PhpMyAdmin. Use the below command to install.

yum -y install phpmyadmin

Now lets configure the PhpMyAdmin. Open the config file in editor

vi /etc/httpd/conf.d/phpMyAdmin.conf

Just change the value of Require under Apache 2.4 Section

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       
       Require all granted
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

Install PHP dependencies 

The Following command will install php dependencies like php-mysql, php-mcrypt, php-mbstring, php-dom.

yum install php-mysql php-mcrypt php-mbstring php-dom

Install Composer For Laravel

Use the following command to install & setup composer.

curl -k -sS https://getcomposer.org/installer | php
echo $PATH
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer

 

Setup Virtual Host For Laravel

Now lets make virtual host setup for Laravel.  First navigate to /etc/httpd/conf.d folder. use the following command .

cd /etc/httpd/conf.d

Now delete welcome.conf  file and create default.conf file.

Add the following lines to default.conf file.

<VirtualHost *:80>

        DocumentRoot /var/www/html/public

        Options +Indexes
        DirectoryIndex index.html index.php

<Directory /var/www/html/public>
        Options Indexes FollowSymLinks
        AllowOverride all
        Order allow,deny
        allow from all
</Directory>
        ErrorLog /var/log/httpd/error.log
        CustomLog /var/log/httpd/access.log combined

</VirtualHost>

Save & Exit

 

Laravel 5.0 Installation 

composer create-project laravel/laravel /var/www/html

Now lets give permission to respective folders

chmod 755 -R /var/www/html
chmod -R o+w /var/www/html/storage

Restart Apache

service httpd restart

 

You are Done. Navigate to your IP. You will see a beautiful Laravel Logo.

 

Leave a Reply

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