How To Install Laravel PHP Framework on a CentOS 7 or RHEL 7

1. Introduction

Laravel is a free, open source PHP framework designed for the fastest development of MVC (Model-View-Controller) web applications in PHP. After a great search for the best framework which I can work with, I found laravel to be the best. It is regarded as one of the most popular and secure PHP framework available today. This article will help you to install Laravel 5 PHP Framework on CentOS 7.

2. Prerequisites

2.1 Server Configuration

  • OS CentOS 7 / RHEL 7
  • Memory Minimum 512 MB
  • HDD Space Minimum

2.2 Requirements

This installation requires LAMP/LEMP with PHP 5.5 or above. You can follow my document (lampinstall.txt) to install apache, MariaDB. After that follow the steps given below to install the required php version and modules.

2.3 Setting up Yum Repositories

At first, you need to add REMI and EPEL rpm repositories in your system. These repositories have all the updated packages for the installation. Use the following commands to add them.

# rpm -Uvh
# rpm -Uvh

Hope you all are having the apache and MariaDB installed and configured. Now install the PHP and the required modules by the following.

# yum install php55w php55w-opcache php55w-xml php55w-mbstring php55w-pdo

Thus we have completed the basic server setup. Now we can move on to the installation of composer.

3. Install Composer

Laravel uses composer to manage its dependencies. So we need to install composer before the installation of laravel. Use the following command to install Composer.

[root@hostname-centos7 ~]# curl -sS | php
#!/usr/bin/env php
All settings correct for using Composer

Composer successfully installed to: /root/composer.phar
Use it: php composer.phar

Then move the composer.phar file to /usr/local/bin/ and rename it as below.

[root@hostname-centos7 ~]# mv composer.phar /usr/local/bin/composer

Give execute permission to the Composer.

[root@hostname-centos7 ~]# chmod +x /usr/local/bin/composer

Thus the installation of composer is completed. Now we can directly move on to the installation of laravel.

4. Install Laravel

Navigate to /var/www/ and download the latest version of Laravel using the commands below. Thus will clone master repo of laravel from github.

[root@hostname-centos7 ~]# cd /var/www
[root@hostname-centos7 www]# git clone
Cloning into 'laravel'...
remote: Counting objects: 25968, done.
remote: Total 25968 (delta 0), reused 0 (delta 0), pack-reused 25968
Receiving objects: 100% (25968/25968), 9.70 MiB | 6.02 MiB/s, done.
Resolving deltas: 100% (13061/13061), done.

After than move to the laravel code directory and use composer to install all dependencies required for Laravel framework.

# cd /var/www/laravel
# composer install

This will take a while according to the network speed. After than set proper permissions on files.

# chown -R apache.apache /var/www/laravel
# chmod -R 755 /var/www/laravel

Thus the basic setup of laravel is completed.

5. Set Encryption Key

At first, set the 32 bit long random number encryption key by using the command below, which used by the Illuminate encrypter service.

[root@hostname-centos7 laravel]# php artisan key:generate
Application key [WRAGp0Pu9kTHiZDqbsEKGXDjSWNL76iF] set successfully.

Then update the above generated application key into the config/app.php configuration file. Also make sure that cipher is set properly.

'key' => env('WRAGp0Pu9kTHiZDqbsEKGXDjSWNL76iF')/	This key is used by the Illuminate encrypter service and should be set. 					
'cipher' => 'AES-256-CBC',

6. Create Apache Virtual Host

Now create a Virtual Host in your Apache configuration file to access Laravel framework from web browser.

To do it edit the apache configuration file /etc/httpd/conf/httpd.conf and add the code below and save the file.

# vim /etc/httpd/conf/httpd.conf

       DocumentRoot /var/www/laravel/public

              AllowOverride All

After than restart the apache service and access Laravel framework using your favourite web browser and you will see a page like the image below which means laravel is properly installed.

# systemctl restart httpd


7. Conclusion

Thus we have installed the most popular PHP framework in an easy way.

How to install and configure LAMP ( Linux, Apache, MySQL and PHP ) in Ubuntu 14.04

1. Introduction

Short for Linux, Apache, MySQL and PHP, an open-source Web development platform, also called a Web stack, that uses Linux as the operating system, Apache as the Web server, MySQL as the RDBMS and PHP as the object-oriented scripting language. Perl or Python is often substituted for PHP.

2. Requirements

An ordinary server with Ubuntu 14.04 LTS installed. You can install it on any platform, but here the documentations are based on the Ubuntu / debian server.

3. Installation

Please proceed with the following steps:

3.1 Apache2 Installation

Type the below command for installing apache 2 package from repository.

#  apt-get install apache2

Restart apache service

# /etc/init.d/apache2 restart

Apache will start working with minimal configuration. Now Open your server-ip in the browser and You can see the apache ubuntu test page.( Default document root is located in this path /var/www/html )

apache3 ubuntu default

3.2 MySQL installation

Issue the below command to install mysql server with dependencies.

# apt-get install mysql-server

During installation it will prompt for a new password for mysql root . Give some strong password and retype the same password for confirmation.

After installation check the Database connection.

Check the service status.

# /etc/init.d/mysql status

Service is already up , Now Type this command to login

# mysql -u root -p

Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 42
Server version: 5.5.35-1ubuntu1 (Ubuntu)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

Mysql server installation is over.

3.3 PHP installation

Type the below command to install php5.

# apt-get install php5 php5-mysql

Create a php file and paste the below code into the file to show the php configuration . Goto the default apache root path /var/www/html . create a new file info.php and paste the below code and save it.

# vi /var/www/html/info.php

Please use the following codes to create a phpinfo page.


Now restart the apache2 service.

# /etc/init.d/apache2 restart

Now open the file in the browser ( Eg: http://yourip/info.php ) you can see the php information page as below.
Make sure you can see the mysql details in the php information page.

ubuntu phpinfo

We have successfully configured Apache2 , mysql and php.

How to install and configure Linux, Apache, Mariadb and PHP (LAMP ) on Centos7 or RHEL7

1. Introduction

Short for Linux, Apache, MySQL and PHP, an open-source Web development platform, also called a Web stack, that uses Linux as the operating system, Apache as the Web server, MySQL as the RDBMS and PHP as the object-oriented scripting language. Perl or Python is often substituted for PHP.

2. Requirements

You may need an operating system RHEL 7 or Centos 7 in your dedicated or vps server. Please make sure to set a hostname for your server and its dns is pointing to the IP address of the server.

3. Installation

Please proceed with the following step by step procedures:

3.1 Install Apache

Apache2 is directly available as a CentOS 7.0 package, therefore we can install it like this:

# yum -y install httpd

Now configure your system to start Apache at boot time.

# systemctl start httpd.service
# systemctl enable httpd.service

Now direct your browser to http://your-IP, and you should see the Apache2 place holder page:


3.2 Install MariaDB

To install MySQL, we do install mariadb like this:

# yum -y install mariadb-server mariadb

Then we create the system startup links for MySQL (So that MySQL starts automatically whenever the system boots) and start the MySQL server:

# systemctl start mariadb.service
# systemctl enable mariadb.service

Set passwords for the MySQL root account:

# mysql_secure_installation

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] 
New password: <--yourmariadbpassword
Re-enter new password: <--yourmariadbpassword
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them.  This is intended only for testing, and to make the installation go a bit smoother.  You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] <--ENTER
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <--ENTER
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] <--ENTER
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <--ENTER
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB installation should now be secure.
Thanks for using MariaDB!

3.3 Install PHP

We can install PHP5 and the Apache PHP5 module as follows:

# yum -y install php php-mysql

We must restart Apache afterwards:

# systemctl restart httpd.service

Testing PHP5 / Getting Details About Your PHP5 Installation

# vi /var/www/html/info.php

Now add the following phpinfo code content in this file.


Now we call that file in a browser (e.g. http://Your IP/info.php):


You may need We have successfully configured Apache2 , mysql and php.

How to install and configure Linux,Apache,Mysql(Mariadb) and PHP (a.k.a LAMP) in Centos 7 / RHEL7


LAMP (Linux, Apache, Mysql & PHP ) is an open source web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language. It is powerful and also comparatively simple and easy to use. This article will help you configure LAMP in Centos7.


Operating System: Centos 7 or RHEL 7

Before you begin LAMP INSTALLATION , you should have a server with root user privilege. By completing steps mentioned below you can configure LAMP in your server.

3. Install Apache

We can install Apache easily using CentOS’s package manager, yum.

# yum install httpd

Afterwards, your web server is installed , you can start Apache on your sever:

# systemctl start httpd.service

Now you can check webserver by using server IP address in your browser:

http://your_server_IP_address/    >>>>> here it is

Now you can see the default CentOS 7 Apache web page. Please see some sample screen shorts below,


4. Install MySQL (MariaDB)

MariaDB is one of the most popular database servers in the world. It’s made by the original developers of MySQL and guaranteed to stay open source.

# yum install mariadb-server mariadb

When the installation is complete, we need to start MariaDB with the following command:

# systemctl start mariadb

Now your mysql database is running.You can access database without any password its not secure so we need to provide password protection.

# mysql_secure_installation

The prompt will ask you for your current root password. Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter. Then the prompt will ask you if you want to set a root password. Go ahead and enter Y, and follow the instructions:

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorization.

New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

After this when you try to access database with out password it may show an error like this:

[root@arunima-centos7 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

You set a mysql root password for your database server so from now on you can’t access it without password.

“root” session do not know password to mysql root user.

If you want to make easier to access your mysql create a .my.cnf in /root/ and add the following content

# touch /root/.my.cnf
# vim /root/.my.cnf

user = root
password = mysqlrootpassword

where of-course “mysqlrootpassword” is your password for mysql’s root user so when you execute mysql command it uses this password.

Install PHP

PHP is the component of our setup that will process code to display dynamic content. It can run scripts, connect to our MySQL databases to get information, and hand the processed content over to our web server to display.

# yum install php php-common php-gd php-mysql

After installing PHP, you should restart apache.

# systemctl restart httpd.service

In order to test that our system is configured properly for PHP, we can create a very basic PHP script.

We will call this script info.php. In order for Apache to find the file and serve it correctly, it must be saved to a very specific directory, which is called the “web root” or “document root”.

In CentOS 7, this directory is located at /var/www/html/. We can create the file at that location as shown below:


Now we can test whether our web server can correctly display content generated by a PHP script.


Please see a sample screen short of phpinfo below,


How To Install PHP 5.2 on cPanel/WHM 11.40+

cPanel, Inc. has released EasyApache 3.24. This version removes Apache 1.3/2.0, PHP 5.2, and mod_frontpage. As mentioned in
Introducing EasyApachea Optimal Profiles, These End of Life (EOL) items are no longer available in EasyApache.

These items have been removed for the following reasons:

  • They are no longer supported by their respective developers.
  • They include unpatched CVEs (Common Vulnerabilities and Exposures).
  • EasyApache provides the most up-to-date, supported versions of Apache (2.2/2.4) and PHP (5.4/5.5).

Keep in mind that viable alternatives to mod_frontpage exist, such as WebDAV and FTP. Also, PHP 5.2 and mod_frontpage are available as custom modules (“opt mods”).

You can read more about how to use and install Custom Modules at :

Downgrading PHP version is not a good idea.We always suggest you to use latest updates version of software/Scripts you are using.In new cPanel version they have completely dropped support for PHP version 5.2 .If you PHP is corrupted or need to recompile it for some reason then you can’t rebuild your old PHP version using EasyApache (3.24) .So you may have to do it at custom.You can do this by following the steps given below.

Install Dependencies using ‘YUM’

# yum install libcurl-devel libmcrypt libmcrypt-devel aspell aspell-devel tidy libtidy libtidy-devel libxslt libxslt-devel 

# cd /var/cpanel/easy/apache/custom_opt_mods/

# wget

# tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf custom_opt_mod-PHP5217.tar.gz

# nano /var/cpanel/easy/apache/rawopts/all_php5



You can enable all relevant PHP modules in “/var/cpanel/easy/apache/rawopts/all_php5”.

Then recompile Apache using “/scripts/easyapache”. Go to step 3 “Please choose which specific PHP version(s) to build”
If you want no PHP except 5.2 then on the “PHP Version” screen chose “None” and continue to step 4, The “Short Options List” page you will see “PHP 5.2.17 support (no FastCGI)” listed. Check that box and continue your EasyApache like normal.

After EasyApache you can re-install IonCubeLoader and Zendopt using :

# /scripts/phpextensionmgr install IonCubeLoader
# /scripts/phpextensionmgr install Zendopt

You can install the following PHP extensions using script ‘/scripts/phpextensionmgr’

  • EAccelerator
  • IonCubeLoader
  • Zendopt
  • Xcache
  • SourceGuardian
  • PHPSuHosin

If necessary you can install other missing PHP modules without doing Easyapache.You can do this simply by login into the server as root :

# cd /home/cpeasyapache/src/php-5.2.17/ext/mcrypt/  (Go to particular extension folder,Here I need to install Mcrypt)

# phpize
# ./configure
# make
# make install

After that you can see extension directory path:

# php -i | grep extension_dir

# ls -al  /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
# vi /usr/local/lib/php.ini

add extension=”” .Then restart apache using :

# /etc/init.d/httpd restart

Other method is:

# wget -O /usr/local/src/tidy-1.2.tgz
# cd /usr/local/src/
# tar zxvf tidy-1.2.tgz
# cd tidy-1.2
# phpize
# ./configure
# make
# make install
# php -i | grep extension_dir
# ls -al  /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
# vi /usr/local/lib/php.ini

add extension=”” extension under your extension directory path and restart apache using:

# /etc/init.d/httpd restart

That’s it !

Install Mhash in php 5.3+ in cPanel Centos Linux servers

The php-mhash installation in php 5.3 is very easy. Please use the following steps to install it

1) Download the latest mhash from and install it as follows,

# tar -xzf  mhash-
# ./configure --prefix=/opt/mhash
#  make
#  make install

2) Now add it to the loader configuration in /etc/


3) Now edit the file /var/cpanel/easy/apache/rawopts/all_php5 and add the following line


4) Finally compile the php using the following command

#  /scripts/easyapache --build

You can test the mhash by creating a phpinfo page in your website document root.

How to find php extension_dir

The extension_dir is the php system path into which the thirdparty installations were installing the  modules like eaccelerator , memcache , etc,.  Sometimes this path will be missing from  server php.ini .  So then you need to find out the correct extension_dir and  update it in php.ini . So that the installed extension will work fine.

So the question is how to find the extension_dir . There will be a php-config file with every php  installations . You can find it from this file . To find it easily run the following command in shell

# grep extension_dir=  `which php-config`

The above result will show an out put like the following ,

#  grep extension_dir=  `which php-config`



Please note the path will  be different in your server .