Categories Tutorials

Install Laravel on CentOS 7

Laravel is a free, open-source PHP web application framework with expressive, elegant syntax. It is intended for the development of web applications following the model–view–controller (MVC) architectural pattern.

Some of the features of Laravel are a modular packaging system with a dedicated dependency manager, different ways for accessing relational databases, utilities that aid in application deployment and maintenance etc…

In this article we will install Laravel on a Centos 7 VPS.


We will be using our SSD 1 Linux VPS Hosting plan for this tutorial.

Log in to your server via SSH:

# ssh root@server_ip


Make sure your server is fully up to date:

# yum update

Before proceeding, let’s install Apache, MariaDB and PHP 5.6 along with it’s needed dependencies. First, install the EPEL and Webtatic repositories with the below commands:

# yum install epel-release

# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

You can now install LAMP (Linux Apache, MariaDB & PHP):

# yum install httpd php56w php56w-mysql mariadb-server php56w-mcrypt php56w-dom php56w-mbstring unzip nano

Start MariaDB and Apache, then enable them to start on boot:

# systemctl start mariadb

# systemctl start httpd

# systemctl enable mariadb

# systemctl enable httpd

Next, install Composer which is the tool for dependency management in PHP.

# curl -k -sS https://getcomposer.org/installer | php

Once Composer is installed, you need to move it so that Composer can be available within your machine path. To check your available path locations type the following:

# echo $PATH

The output will provide you with the path locations. Put composer in the /usr/local/bin/ directory:

# mv composer.phar /usr/local/bin/composer

Navigate into a directory where you will download Laravel. We are using /opt :

# cd /opt

Download Laravel and unzip the archive:

# wget https://github.com/laravel/laravel/archive/v4.2.11.zip

# unzip v4.2.11.zip

Then create a directory for your website and move the Laravel installation there:

# mkdir /var/www/html/your_site

# mv laravel-4.2.11/ /var/www/html/your_site

# cd /var/www/html/your_site

Move the files/directories from the laravel-4.2.11 unpacked archive into your website directory and then delete laravel-4.2.11:

# mv laravel-4.2.11/* .

# mv laravel-4.2.11/.* .

# rmdir laravel-4.2.11/

Issue the below command to download and install all dependencies. This can take some time, so feel free to make yourself a cup of tea:

# composer install

Once the installation is completed, set the ownership of your website files/directories to apache:

# chown apache: -R /var/www/html/your_site/

Now, create a virtual host directive for your website. Open a file called let’s say your_site.conf with your favorite text editor. We are using nano:

# nano /etc/httpd/conf.d/your_site.conf

Paste the following:

<VirtualHost *:80>
    DocumentRoot /var/www/html/your_site/public
    ServerName your_domain

    <Directory /var/www/html/your_site/>
        AllowOverride All

Don’t forget to replace your_domain with your actual domain.

Restart Apache so the changes can take effect:

# systemctl restart httpd

With that out of the way, open your web browser and navigate to http://your_domain to access the Laravel website.

Congratulations, you have successfully installed Laravel on your CentOS 7 VPS.

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Laravel for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

View Comments

  • Hey, you forgot the firewall, thanks for this guide! firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public --add-service=https firewall-cmd --reload