Laravel is a powerful MVC-PHP framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications. Laravel was created by Taylor Otwell. In this guide, we will install Laravel 5.5 on CentOS 7 and as you might already know Laravel 5.5 depends on PHP 7.0+ so we are going to install the latest stable version of PHP which is 7.1 and finally serve the whole thing with Apache web server.
This Tutorial Contains
- Installing Apache
- Installing PHP 7.1
- Download & Install Composer
- Configuring Apache
- Set the Permissions
We are assuming that you have root permission, otherwise, you may start commands with “sudo”.
You can install Apache easily using “yum” with the following command:
yum install httpd
After the installation process is finished you can use the commands below to start your Apache service and make it run at startup:
systemctl start httpd
systemctl enable httpd
Install PHP 7.1
PHP 7.1 is not provided by the official repository so you have to add “Webtatic” repo in order to install it easily.
First, install EPEL repository with the following command:
yum install epel-release
Now you can add the Webtatic repository using an RPM package:
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Update your repository list to fetch the latest packages with the command below:
execute the command below to easily install PHP 7.1 and the needed extensions:
yum install php71w php71w-xml php71w-mbstring php71w-mysql php71w-json php71w-curl php71w-cli php71w-common php71w-mcrypt php71w-gd php71w-zip
For installing the latest version of Laravel we need to get the Composer dependency manager:
curl -sS https://getcomposer.org/installer | php
Execute the following command to move your Composer binary file to the executable path:
mv composer.phar /usr/bin/composer
Now you can run the command below to download and install Laravel directly into your Apache document root:
composer create-project laravel/laravel /var/www/html/laravel
Set the correct DocumentRoot
Open the Apache configuration file:
Find the line that refers to:
and change it like below:
Then save and exit.
Restart Apache to take effect:
systemctl restart httpd
Set the Permissions
Execute the following command one by one to set the proper permissions:
chown -R apache:apache /var/www/html/laravel
chmod -R 755 /var/www/html/laravel/storage
Test if everything works fine
Now you can open your browser and see your public IP address or your Domain through it.
You should see a page like below:
And you can verify that you installed Laravel 5.5 with the following command:
php artisan -V
You probably see something like below:
Laravel Framework 5.5.25
For more information and news you can check out Laravel official website!