Install LAMP Server (Apache, MariaDB, PHP) On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3

Install LAMP Server (Apache, MariaDB, PHP) On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3

LAMP is a combination of operating system and open-source software stack. The acronym LAMP is derived from first letters of Linux, Apache HTTP Server, MariaDB database, and PHP/Perl/Python.

In this tutorial let us see how to setup LAMP server on RHEL/CentOS/Scientific Linux 6.x. Here x stands for version such as 6.1, 6.2, 6.3, 6.4, 6.5 etc.

My testbox hostname and IP address are and, respectively.

Install Apache

Apache is an open-source multi-platform web server. It provides a full range of web server features including CGI, SSL and virtual domains.

To install Apache, enter the following command from your terminal:

# yum install httpd -y

Start the Apache service and let it to start automatically on every reboot:

# service httpd start
# chkconfig httpd on

Allow Apache server default port 80 through your firewall/router if you want to connect from remote systems. To do that, edit file /etc/sysconfig/iptables,

# vi /etc/sysconfig/iptables

Add the following lines.

-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

Restart iptables:

# service iptables restart

Test Apache:

Open your web browser and navigate to http://localhost/ or http://server-ip-address/.

Apache HTTP Server Test Page powered by CentOS - Mozilla Firefox_001Install MariaDB

MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements.

First you have to remove existing MySQL packages if any:

# yum remove mysql* mysql-server mysql-devel mysql-libs

Install REMI Repository to resolve MySQL Compatibility issue

You will probably get dependencies errors while installing MariaDB. So let us add REMI Repository to solve dependencies problems:

Thanks to AskMonty Knowledgebase to help me to solve the dependencies issues.

# rpm -ivh

Install compat-mysql55 package now:

# yum --enablerepo=remi-test --disablerepo=remi install compat-mysql55

Create a repository file for MariaDB and add the following lines:

For 32bit systems:

# vi /etc/yum.repos.d/mariadb.repo
# MariaDB 5.5 CentOS repository list - created 2013-06-06 07:42 UTC
name = MariaDB
baseurl =

For 64bit systems:

# vi /etc/yum.repos.d/mariadb.repo
# MariaDB 5.5 CentOS repository list - created 2013-06-06 07:53 UTC
name = MariaDB
baseurl =

Save and exit the file and run yum update command:

# yum update

Now start installing MariaDB:

# yum install MariaDB-devel MariaDB-client MariaDB-server -y

Start MariaDB service and let it to start automatically on every reboot:

# service mysql start
# chkconfig mysql on

Set MySQL root password

By default MySWL root password is empty. So to prevent unauthorized access to MySQL, let us set root user password:

# /usr/bin/mysql_secure_installation 
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
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.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] y
New password: 
Re-enter new password: 
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] 
... 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] 
... 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] 
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed!  Not critical, keep moving...
- 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] 
... 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!

Install PHP

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Install PHP with following command:

# yum install php -y

Test PHP

Create a sample “testphp.php” file in Apache document root folder and append the lines as shown below:

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

Add the following lines.

Restart httpd service:

# service httpd restart

Navigate to http://server-ip-address/testphp.php. It will display all the details about php such as version, build date and commands etc.

phpinfo() - Mozilla Firefox_002If you want to install all php modules, enter the command yum install php* -y and restart the httpd service. To verify for the modules, open web browser and navigate to http://server-ip-address/testphp.php. You will able to see all php modules.

Install phpMyAdmin (Optional)

phpMyAdmin is a free open-source web interface tool used to manage your MySQL databases. By default phpMyAdmin will not be not found in CentOS/RHEL/Scientific Linux official repositories. So let us install it from EPEL repository.

To add EPEL repository, just follow the link.

Install EPEL Repository on RHEL/CentOS/Scientific Linux 6

Now install phpMyAdmin:

# yum install phpmyadmin -y

Configure phpMyAdmin

Edit the phpmyadmin.conf file.

# vi /etc/httpd/conf.d/phpMyAdmin.conf

Find and comment the whole /<Directory> section as shown below:

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
## Comment the following Section ##
#<Directory /usr/share/phpMyAdmin/>
#   <IfModule mod_authz_core.c>
#     # Apache 2.4
#     <RequireAny>
#       Require ip
#       Require ip ::1
#     </RequireAny>
#   </IfModule>
#   <IfModule !mod_authz_core.c>
#     # Apache 2.2
#     Order Deny,Allow
#     Deny from All
#     Allow from
#     Allow from ::1
#   </IfModule>

Open “” file and change from “cookie” to “http” to change the authentication in phpMyAdmin:

# cp /usr/share/phpMyAdmin/ /usr/share/phpMyAdmin/ 
# vi /usr/share/phpMyAdmin/

Change cookie to http.

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';

Restart the Apache service:

# service httpd restart

Now you can access the phpmyadmin console by navigating to http://server-ip-address/phpmyadmin/ from your browser.

Enter your MySQL username and password which you have given in previous steps. In my case its “root” and “centos”.

Mozilla Firefox_003You will be redirected to PhpMyAdmin main web interface. - localhost | phpMyAdmin - Mozilla Firefox_004Now you will able to manage your MariaDB databases from phpMyAdmin web interface.

That’s it. Your LAMP server is up and ready to use.


  • Rizwan Mohammed

    Very good article, appreciable.

  • Rizwan Mohammed

    Any Solutions to have MariaDB and MySQL both installed in the same system ?
    While doing yum remove mysql* mysql-server mysql-devel mysql-libs
    I have to compromise followings:
    Dependencies Resolved
    Package Arch Version Repository Size
    mysql-libs i686 5.1.71-1.el6 @base 3.9 M
    Removing for dependencies:
    cronie i686 1.4.4-12.el6 @base 165 k
    cronie-anacron i686 1.4.4-12.el6 @base 38 k
    crontabs noarch 1.10-33.el6 @anaconda-CentOS-201303020136.i386/6.4
    2.4 k
    google-chrome-stable i386 31.0.1650.63-1 @google 150 M
    libcgroup i686 0.40.rc1-5.el6 @base 295 k
    libvirt i686 0.10.2-29.el6 @base 5.0 M
    numad i686 0.5-9.20130814git.el6 @base 52 k
    policycoreutils-gui i686 2.0.83-19.39.el6 @base 730 k
    policycoreutils-python i686 2.0.83-19.39.el6 @base 913 k
    postfix i686 2:2.6.6-2.2.el6_1 @anaconda-CentOS-201303020136.i386/6.4
    9.3 M
    redhat-lsb i686 4.0-7.el6.centos @anaconda-CentOS-201303020136.i386/6.4
    redhat-lsb-compat i686 4.0-7.el6.centos @anaconda-CentOS-201303020136.i386/6.4
    redhat-lsb-core i686 4.0-7.el6.centos @anaconda-CentOS-201303020136.i386/6.4
    22 k
    redhat-lsb-graphics i686 4.0-7.el6.centos @anaconda-CentOS-201303020136.i386/6.4
    redhat-lsb-printing i686 4.0-7.el6.centos @anaconda-CentOS-201303020136.i386/6.4
    setroubleshoot i686 3.0.47-6.el6 @base 222 k
    setroubleshoot-plugins noarch 3.0.40-2.el6 @base 4.4 M
    setroubleshoot-server i686 3.0.47-6.el6 @base 2.4 M
    sysstat i686 9.0.4-22.el6 @base 799 k
    virt-who noarch 0.8-5.el6.centos @base 225 k

    Transaction Summary
    Remove 21 Package(s)

    Installed size: 179 M
    Is this ok [y/N]: ?

  • SK

    Thank you.

  • SK

    Very strange Rizwan. I haven’t got this problem before. Let me check.

  • Pingback: Setup Fileserver Using Pydio On CentOS 6.5/6.4 | GANGESH SHARMA(MCA- IGNOU,MCP,JCHNP)()

  • Pingback: Install Oracle VirtualBox And Manage It Using phpVirtualBox On A CentOS Headless Server | Windows – Linux()

  • Pingback: Setup Fileserver Using Pydio On CentOS 6.5/6.4 | Windows – Linux()

  • Pingback: 使用ownCloud在Linux安装你的个人云服务 | 学习记录()

  • Pingback: 리눅스 버추얼박스 설치 . vboxweb-service, How to Install VirtualBox & phpVirtualBox on Centos / Redhat | Everything System Engineer()

  • Pingback: 用于vSphere服务器虚拟主机的CentOS基本环境配置 | This is ocLab()

  • Pingback: Setup Centralized Log Server Using Rsyslog And LogAnalyzer On CentOS, RHEL, Scientific Linux 6.5/6.4 - Techtunebd.Net()

  • Pingback: Setup your personal Cloud server in minutes using ownCloud On RHEL, CentOS, Scientific Linux 6.5 - Techtunebd.Net()

  • Pingback: Setup Document Management System Using OpenDocMan On CentOS 6.5 - Techtunebd.Net()

  • Pingback: Install Ampache Streaming Media Server On CentOS 6.4 - Techtunebd.Net()

  • Pingback: IPplan – An IP Address Management System - Techtunebd.Net()

  • Análisis completo Aprende más Aprende Más Aquí Aquí la respuesta Artículo completo blog aquí Bonus click aquí Click en este link Click Here click para ir a la fuente Clickando aquí Consigue Más Info Consigue Más Información contenido de utilid

    I know this if off topic but I’m looking into starting my own blog
    and was curious what all is required to get setup?
    I’m assuming having a blog like yours would cost a pretty penny?

    I’m not very internet savvy so I’m not 100% sure. Any tips or advice would be greatly appreciated.
    Many thanks

  • Julio

    My programmer is trying to persuade me to move to .net from PHP.
    I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using WordPress on several websites for about a year and am concerned about switching
    to another platform. I have heard good things about
    Is there a way I can import all my wordpress content into
    it? Any help would be really appreciated!

  • eliminar el dolor de espalda

    Heya i am for the first time here. I came across this board and I find It truly useful & it helped me out much.

    I hope to give something back and help others like you aided me.

  • Noelia

    I am in fact delighted to glance at this blog posts which
    carries tons of valuable data, thanks for providing these information.

  • wayne banks

    Exceptional post however I was wanting to know if you could
    write a litte more on this subject? I’d be very grateful if you could elaborate a little bit further.

  • Liliana

    Piece of writing writing is also a fun, if yyou know after that you can write otherwise it is
    complicated to write.

  • Roxie

    It’s great that you are getting ideas from this piece of writing
    as well as from our dialogue made at this place.

  • Skye

    You can make a lot of money potentially if you work hard, as it
    can net you significant earnings. Trading on a mini account will give you more realistic training on how
    to manage risk and leverage when trading live.
    However, mostly, when these funds start running short of prospects, they generally shut down with whatever
    money they have acquired.

  • Detox My Mac

    I also have the option to split my VPN connection so some apps use the VPN IP,
    and some use the local IP. Come, try these new Mac cosmetic products that are completely safe and natural and
    you too will find the joy of looking the best you can. If you didn’t put the
    files in a folder, they may be spread on the
    desktop or at the original location where the zip file was located.