AMP AMP

How to install laravel 5.6.16 on centos 7

How to install laravel 5.6.16 on centos 7

Laravel is a powerful MVC-PHP framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications In this guide, we will install Laravel 5.6.16 on CentOS 7

Installation

start with installing apache web server by using the following command

[root@linuxhelp ~]# yum install httpd
Loaded plugins: fastestmirror, langpacks
base                                                                                                      | 3.6 kB  00:00:00     
extras                                                                                                    | 3.4 kB  00:00:00     
updates                                                                                                   | 3.4 kB  00:00:00     
(1/2): extras/7/x86_64/primary_db                                                                         | 185 kB  00:00:00     
(2/2): updates/7/x86_64/primary_db                                                                        | 6.9 MB  00:00:09     
.
.
Installed:
  httpd.x86_64 0:2.4.6-67.el7.centos.6                                                                                           
Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1          apr-util.x86_64 0:1.5.2-6.el7         httpd-tools.x86_64 0:2.4.6-67.el7.centos.6        
  mailcap.noarch 0:2.1.41-2.el7        

After the installation process, you can use the commands below to start your Apache service and make it run at startup

[root@linuxhelp ~]# systemctl start httpd.service 
[root@linuxhelp ~]# systemctl enable httpd.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

Next, we are going to install php 7.1 It is not provided by the official RHEL repository so you have to add “ Webtatic” repo in order to install it easily.
First, install EPEL repository with the following command

[root@linuxhelp ~]# yum install epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.dhakacom.com
 * extras: mirror.dhakacom.com
 * updates: mirror.dhakacom.com
Resolving Dependencies
-->  Running transaction check
--->  Package epel-release.noarch 0:7-9 will be installed
-->  Finished Dependency Resolution

.
.
Running transaction
  Installing : epel-release-7-9.noarch                                                                                       1/1 
  Verifying  : epel-release-7-9.noarch                                                                                       1/1 

Installed:
  epel-release.noarch 0:7-9                                                                                                      

Complete!

Now you can add the Webtatic repo

[root@linuxhelp ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.BH9cmU: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:webtatic-release-7-3             ################################# [100%]

execute the command below to easily install PHP 7.1 and the needed extensions

[root@linuxhelp ~]# yum install php71w php71w-common php71w-gd php71w-phar php71w-xml php71w-cli php71w-mbstring php71w-tokenizer php71w-openssl php71w-pdo
Loaded plugins: fastestmirror, langpacks
epel/x86_64/metalink                                                                                      | 7.6 kB  00:00:00     
epel                                                                                                      | 4.7 kB  00:00:00     
webtatic                                                                                                  | 3.6 kB  00:00:00  
.
.
Installed:
  mod_php71w.x86_64 0:7.1.14-1.w7         php71w-cli.x86_64 0:7.1.14-1.w7              php71w-common.x86_64 0:7.1.14-1.w7        
  php71w-gd.x86_64 0:7.1.14-1.w7          php71w-mbstring.x86_64 0:7.1.14-1.w7         php71w-pdo.x86_64 0:7.1.14-1.w7           
  php71w-xml.x86_64 0:7.1.14-1.w7        

Complete!

Verify the php version using the following command

[root@linuxhelp ~]# php -v
PHP 7.1.14 (cli) (built: Feb  4 2018 09:05:29) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

Download Composer for installing the latest version of Laravel and also we need to get the Composer dependency manager

[root@linuxhelp ~]# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.6.3) successfully installed to: /root/composer.phar
Use it: php composer.phar

Execute the following command to move your Composer binary file to the executable path

[root@linuxhelp ~]# mv composer.phar /usr/bin/composer

Now you can run the command below to download and install Laravel directly into your Apache document root

[root@linuxhelp ~]# composer create-project laravel/laravel /var/www/html/laravel
Installing laravel/laravel (v5.6.12)
  - Installing laravel/laravel (v5.6.12): Downloading (100%)         
Created project in /var/www/html/laravel
>  @php -r " file_exists(' .env' ) || copy(' .env.example' , ' .env' ) " 
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 70 installs, 0 updates, 0 removals
.
.
Generating optimized autoload files
>  IlluminateFoundationComposerScripts::postAutoloadDump
>  @php artisan package:discover
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
>  @php artisan key:generate
Application key [base64:La3/wukUecCGrWo466D/vfN0s9nUac9ej1w6qe8aCsA=] set successfully.

we have to Set the correct DocumentRoot so Open the HTTPD global configuration file

[root@linuxhelp ~]# nano /etc/httpd/conf/httpd.conf

Find the line that refers to

DocumentRoot " /var/www/html

And change with the following line

DocumentRoot " /var/www/html/laravel/public" 

Then save and exit. Now Restart Apache to take effect

[root@linuxhelp ~]# systemctl restart httpd

Set the Permissions, execute the following command one by one to set the proper permissions:

[root@linuxhelp ~]# chown -R apache:apache /var/www/html/laravel
[root@linuxhelp ~]# chmod -R 755 /var/www/html/laravel/storage

Now you can open your browser and see navigate to your IP address or your Domain
You should see a similar page that shown below

And you can verify that you installed Laravel 5.5 with the following command

[root@linuxhelp ~]# cd /var/www/html/laravel
[root@linuxhelp laravel]# php artisan -v
Laravel Framework 5.6.16

with this, the method to install laravel 5.6.16 on centos 7 comes to an end.

Tag : CentOS Laravel
Comment
scarmelchorgaln
Oct 20 2018
Perfect for me, thank!
Add a comment
FAQ
Q
How do I log in to my cPanel interface with SSL certificate?
A
To log in to your cPanel interface, enter one of the following URLs in your address bar:
for SSL (more security):
https://example.com:2083
Q
Do I have two domains and two different web hosts on the same cPanel account?
A
No, because the accounts are on different web servers.

You can have multiple domains on one cPanel account if you use addon domains or aliases.
Q
How do I log in to my cPanel interface?
A
How do I log in to my cPanel interface?
To log in to your cPanel interface, enter one of the following URLs in your address bar:

http://example.com:2082
Q
Why the need the Laravel installation on WHM and Cpanel?
A
Laravel is a PHP framework used to develop PHP based applications in Linux systems. Laravel is especially designed for easy development of web applications. It supports multi-platform and all
Q
Does I change the root user’s default shell?
A
cPanel requires the root user to use the bash shell by default. Other users can use shells that are not bash if the system administrator wishes to make this an option.