Install Laravel on CentOS 6.X

You can easily install Laravel on a LAMP stack running on a CentOS 6.9 within less than an hour. For this Laravel install tutorial we are using a clean install of CentOS 6.9 on a Face VPS 1 package, however you can install it also on any Dedicated Server machine as well.

First, we will login via SSH as the root user:

ssh root@{IP_ADDRESS}

We’ll update the Operating System and all currently installed packages

# Updating the basic VPS’ packages

yum update

We’re acquainted with VIM so we’ll use it

# Installing VIM for text editor

yum install vim

In order to run Laravel on the VPS, we’ll need Apache, MySQL and PHP, the setup that we’ll show is using Apache 2.2, MySQL 5.6 and PHP 7.1 directly configured from Remi’s Repository.

# Installing Remi’s Repository

yum install epel-release
rpm -Uvh

After that, we’ll install the basic packages required to run a fresh Laravel installation

# Basic setup – Git, Apache, MySQL, PHP & Extensions

yum --enablerepo=remi,remi-php71 install git httpd php php-common mysql mysql-server php-pecl-zip php-mysql php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

We’ve chosen to install Laravel using Composer, so we’ll need to set it first:

# Installing Composer

chmod +x composer.phar
mv composer.phar /usr/bin/composer

We’re ready to install Laravel using Composer. We’ll set the installation path to be the default /var/ww/html and for testing purposes (or lack of imagination) we’ll use for domain

cPanel Hosting from WebhostFace

# Creating a directory and making the installation:

cd /var/www/html/

composer create-project --prefer-dist laravel/laravel

When this is done we’ll need to change the permissions so that Apache has access to write logs. In addition, we’ll also make a custom apache_logs folder for error and access logs.

# Default Apache Logs


# Fixing ownership

chown -R apache:apache*

Now we’ll need to instruct Apache to start responding to requests made for that domain. For this, we’ll use Named Virtual Hosts and we’ll also set a Virtual Host for our domain –

# Enabling and adding a Virtual Host

vim /etc/httpd/conf/httpd.conf

# Append the following at the end of the file (note that we’re using as domain and folder)

NameVirtualHost *:80

<VirtualHost *:80>

ServerAdmin webmaster@

DocumentRoot /var/www/html/


ServerAlias www.

<Directory /var/www/html/>

Options FollowSymLinks

AllowOverride All

Order allow,deny

allow from all


ErrorLog /var/www/html/

CustomLog /var/www/html/ common


After that we’ll need to start MySQL, create our Database and secure access to it:

# Starting MySQL and using it’s CLI to create a Database called “laravel”

service mysqld start



# Secure MySQL access:


When we’re ready with our Database we’ll need to adjust it in Larave’s .env configuration file:

# Adjusting DB Settings

vim config/database.php
'mysql' => [
    'read' => [
        'host' => [
    'write' => [
        'host' => [
    'sticky'    => true,
    'driver'    => 'mysql',
    'database'  => 'laravel',
    'username'  => 'root',
    'password'  => 'THE ONE YOU CREATED THE USER WITH',
    'charset'   => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix'    => '',

We should be done with our basic Laravel setup, now we just have to start Apache

service httpd start
service mysqld start

After that Laravel will be served if the domain is pointed towards the VPS. For this, we could use CloudFlare for DNS and simply change the A record over there to be the VPS’ primary IP address.