Last Updated on 2 days by Sachin G
This article guides you through installing and configuring the Laravel PHP framework on CentOS, RHEL, and Ubuntu servers. It covers installing prerequisites like Apache, PHP, and Composer, setting up the Laravel environment, and configuring the Apache virtual host for your Laravel project deployment.
Laravel is a php based web application framework that manages its dependencies through Composer. It will download on the system, can archive its phar file in the local project path, or you can use it globally through usr/local/bin. For Windows Composer, it has its own installer. The use of the Laravel framework will enjoy the developer to write the best code. Laravel is oan pen, powerful tool for large and robust applications.
Installation of the Laravel PHP framework is not complicated, we will discuss in this article the guide installation of composer and Laravel 5 on CentOS / RHEL / Ubuntu Server.
Prerequisite Server Requirements :
Laravel needs PHP >= 5.4 version and MCrypt Extension(php-mcrypt) .
If php 5.5 version using , it can be required php json extension.
Install Apache Web Server on Centos / RHEL / Ubuntu :
Here we are assuming that you have fresh Operating System of Linux flavor server , so you need to fresh install apache web server .
Set up Yum Repository for CentOS 7 / RHEL 7 Version :
Install and Configure yum epel and RepoForge repository on Centos 7 / RHEL 7 Version. we have other articles for yum repository configure. Please click on below link.
Install apache :
For CentOs / RHEL 7 :
To set up apache webserver on centos and rhel server, you need to run below command.
# yum --enablerepo=epel install httpd -y
Start and active the service of apache on server.
# systemctl start httpd.service # systemctl enable httpd.service
For Ubuntu Server :
# apt-get install apache2
Start and active the service of apache2 on ubuntu server.
# service apache2 start
Install PHP and its extension
For Laravel , only need php , php mcrypt extension and some common module should be install.Run below command to install php and its module.
For ubuntu user :
# apt-get install –y php5 php5-gd php5-mcrypt php5-mysql
For CentOS / RHEL 7 :
#yum --enablerepo=epel install php php-mcrypt php-mysql
After that restart apache web server.
Install Composer
Below steps of composer install for both ubuntu and centos server, for run the command you should have root privileges other wise you have sudo user previleges.
# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer Downloading... Composer successfully installed to: /root/composer.phar Use it: php composer.phar
Use this file for globally on system , we have move to /usr/local/bin .
# mv composer.phar /usr/local/bin/composer
Give executable permission to composer file.
# chmod +x /usr/local/bin/composer
Configure Laravel
Go to server path where you want to configure framework. Here we are going to configure framework application on our document root of domain name. which is /www/wwwroot/techtransit.org .
# cd /www/wwwroot/techtransit.org # git clone https://github.com/laravel/laravel.git
then go to laravel folder which is in /www/wwwroot/techtransit.org directory.
# cd /www/wwwroot/techtransit.org # composer install
Now after composer installation dependency will install then give web server user access to the laravel application code.
Laravel Apache Configuration on CentOs / RHEL / Ubuntu Server :
Create a new Virtual host configuration file in apache. We have create a apache configuration file framework.conf in our apache configuration directory .
For CentOs / RHEL Server : # cd /etc/apache/conf.d/ # vim framework.conf For Ubuntu Server : # vim /etc/apache2/sites-available/framework.conf # ln -s /etc/apache2/sites-available/framework.conf /etc/apache2/sites-enabled/framework.conf
Add the follow lines in our apache configuration file.
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /home/techtransit/pubic_html/framework ServerName laravelframework.techtransit.org <Directory /home/techtransit/pubic_html/framework> Options FollowSymLinks AllowOverride All </Directory> </VirtualHost>
After that, restart your web server daemon according to your OS.
# systemctl restart httpd.service ( For CentOs / RHEL 7 ) # service apache2 restart ( For Ubuntu Server )
Now open the website in the browser and enjoy the Laravel framework.
I’m Sachin Gupta — a freelance IT support specialist and founder of Tech Transit. I’m certified in Linux, Ansible, OpenShift (Red Hat), cPanel, and ITIL, with over 15 years of hands-on experience. I create beginner-friendly Linux tutorials, help with Ansible automation, and offer IT support on platforms like Upwork, Freelancer, and PeoplePerHour. Follow Tech Transit for practical tips, hosting guides, and real-world Linux expertise!