How To Install Laravel 5 PHP Framework on CentOS / RHEL / Fedora

Laravel is an open source PHP framework designed for the faster development of MVC web applications in PHP. This article will help you to install Laravel 5 PHP Framework on CentOS, Red Hat and Fedora System.

Step 1: Setup Yum Repositories

First you need to add REMI and EPEL rpm repositories in your system. these repositories have updated packages. Use one of the below command as per your OS version and system architecture.
 CentOS/RHEL 7, 64 Bit System:  # rpm -Uvh http://free.nchc.org.tw/fedora-epel/7/x86_64/e/epel-release-7-5.noarch.rpm # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm   CentOS/RHEL 6, 32 Bit System:  # rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm   CentOS/RHEL 6, 64 Bit System:  # rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm   CentOS/RHEL 5, 32 Bit System:  # rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm   CentOS/RHEL 5, 64 Bit System:  # rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-releas5-4.noarch.rpm # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm 

Step 2: Install Apache, MySQL and PHP

To start with Laravel, we first need to setup a running LAMP server. If you have already running LAMP stack skip this step else use followings commands to setup lamp stack.

Install Apache

# yum --enablerepo=remi,epel install httpd 

Install MySQL

# yum --enablerepo=remi,epel install mysql-server # service mysqld start # /usr/bin/mysql_secure_installation 

Install PHP

# yum --enablerepo=remi,epel install php php-mysql php-mcrypt # service httpd restart 

Step 3: Install Composer

Composer is required for installing Laravel dependencies. So use below commands to download and use as a command in our system.
# curl -sS https://getcomposer.org/installer | php # mv composer.phar /usr/local/bin/composer # chmod +x /usr/local/bin/composer 

Step 4: Install Laravel

To download latest version of Laravel, Use below command to clone master repo of laravel from github.
# cd /var/www # git clone https://github.com/laravel/laravel.git 
Navigate to Laravel code directory and use composer to install all dependencies required for Laravel framework.
# cd /var/www/laravel # composer install 
Dependencies installation will take some time. After than set proper permissions on files.
# chown -R apache.apache /var/www/laravel # chmod -R 755 /var/www/laravel 

Step 5: Set Encryption Key

Now set the 32 bit long random number encrypption key, which used by the Illuminate encrypter service.
$ php artisan key:generate  Application key [Z4hfTHU7hFMwHauzOwv7rO9e0MJ9UnhQ] set successfully. 
Now edit config/app.php configuration file and update above generated application key as followings. Also make sure cipher is set properly.
 'key' => env('APP_KEY', 'Z4hfTHU7hFMwHauzOwv7rO9e0MJ9UnhQ'),  'cipher' => 'AES-256-CBC', 

Step 6: Create Apache Virtual Host

Now add a Virtual Host in your Apache configuration file to access Laravel framework from web browser. To do it edit Apache configuration file /etc/httpd/conf/httpd.conf and add below code at end of file
# vim /etc/httpd/conf/httpd.conf 
<VirtualHost *:80>        ServerName laravel.example.com        DocumentRoot /var/www/laravel/public         <Directory /var/www/laravel>               AllowOverride All        </Directory> </VirtualHost> 
Restart Apache service and access Laravel framework using your favourite web browser and start developing a great web application.
 # service httpd restart 
Now access the Laravel website in web browser.
install laravel 5

Thanks for Visit Here

Comments