How to Install Laravel 6 on CentOS/RHEL 7/6

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 6 PHP Framework on CentOS/RHEL 7/6 system.

Step 1 – Setup Yum Repositories

First of all, you need to add REMI and EPEL rpm repositories in your system. these repositories have updated packages. Use one of the below commands as per your OS version and system architecture.

CentOS/RHEL 7:

rpm -Uvh
rpm -Uvh

CentOS/RHEL 6:

rpm -Uvh
rpm -Uvh

Step 2 – Install Apache, MySQL and PHP

Here is short instruction for the installation of LAMP stack. Its required to run the Laravel framework on your CentOS system. Use this guide for the detailed LAMP setup on CentOS

Install Apache

yum --enablerepo=remi,epel install httpd

Install MySQL

yum --enablerepo=remi,epel install mysql-server
service mysqld start

Install PHP

yum --enablerepo=remi,epel install php php-zip php-mysql php-mcrypt php-xml php-mbstring
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 | php
mv composer.phar /usr/bin/composer
chmod +x /usr/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

Navigate to the Laravel code directory and use the composer to install all dependencies required for the Laravel framework.

cd /var/www/laravel
composer install

Dependency 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
chmod -R 755 /var/www/laravel/storage

SELinux enabled systems also run the below command to allow write on storage directory.

chcon -R -t httpd_sys_rw_content_t /var/www/laravel/storage

Step 5 – Set Encryption Key

Laravel uses .evn file for environment configuration. Use .evn file for configuring all the environment variables for your application like the database, SMTP, security key, etc.

cp .env.example .env

Now set the 32 bit long random number encryption key, which used by the Illuminate encrypter service.

php artisan key:generate

Application key set successfully.

You can view the .env file to find the Application key is configured.

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
File: /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
       DocumentRoot /var/www/laravel/public

       <Directory /var/www/laravel>
              AllowOverride All

Restart Apache service and access the Laravel framework using your favorite web browser and start developing a great web application.

service httpd restart

Now access the Laravel website in a web browser.

install laravel on centos

Leave a Reply

Your email address will not be published.