We’ll show you how to 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… Installing Laravel on CentOS 7, is an easy task, just follow the steps in the tutorial below and you should have it installed in few minutes.
We will be using our SSD 1 Linux VPS Hosting plan for this tutorial.
Log in to your server via SSH:
# ssh [email protected]_ip
1. Update the System
Make sure your server is fully up to date:
# yum update
2. Install Apache, MariaDB and PHP
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
3. Install LAMP Stack
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
4. Start MariaDB and Apache
Start MariaDB and Apache, then enable them to start on boot:
# systemctl start mariadb # systemctl start httpd # systemctl enable mariadb # systemctl enable httpd
5. Install Composer
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
6. Download Laravel
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/
7. Download and Install all Dependencies
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/
8. Create Virtual Host Directive
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 </Directory> </VirtualHost>
Don’t forget to replace your_domain with your actual domain.
9. Restart Apache and Test Laravel installation on CentOS 7
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 Install Laravel on CentOS 7, if you use one of our Laravel VPS Hosting services, in which case you can simply ask our expert Linux admins to Install Laravel on CentOS 7 for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to install Laravel on CentOS 7, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.