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

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

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, MySQL 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 server.unixmen.local 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 -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEP

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_001

Install MySQL

MySQL is an enterprise class, open source, world’s second most used database. MySQL is a popular choice of database for use in web applications, and is a central component of the widely used LAMP open source web application software stack.

To install MySQL, enter the following command:

# yum install mysql mysql-server -y

Start the MySQL service and make to start automatically on every reboot.

# service mysqld start
# chkconfig mysqld on

Setup MySQL root password

By default, mysql root user doesn’t has password. To secure mysql, we have to setup mysql root user password.

# mysql_secure_installation
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, 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):     ## Press Enter ## 
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n]     ## Press Enter ##
New password:                ## Enter new password ##
Re-enter new password:       ## Re-enter new password ##
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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]     ## Press 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]     ## Press Enter ## 
... Success!
By default, MySQL 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]     ## Press 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]     ## Press Enter ##
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!

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.

If you wanna to get MySQL support in your PHP, you should install “php-mysql” package. If you want to install all php modules just you use the command “yum install php*”

[root@server ~]# yum install php-mysql -y

Now open the phptest.php file in your browser using http://ip-address/testphp.php or http://domain-name/testphp.php. Scroll down and you will see the mysql module will be presented there.

phpinfo() - Mozilla Firefox_002Install phpMyAdmin

phpMyAdmin is a free open source web interface tool, used to manage your MySQL databases. By default phpMyAdmin is not found in CentOS official repositories. So let us install it using EPEL repository.

To install EPEL repository, follow the below 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
#<Directory /usr/share/phpMyAdmin/>
#   <IfModule mod_authz_core.c>
#     # Apache 2.4
#     Require local
#   </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”.

phpMyAdmin - Mozilla Firefox_003Now you will be redirected to the phpmyadmin as shown below. - localhost | phpMyAdmin 4.1.2 - Mozilla Firefox_004

Now you will able to manage your MariaDB databases from phpMyAdmin web interface.

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


  • Mario

    Hi i install all you here on vbox, but a can’t see my index.php, any suggestion? thanks in advance. Mario

  • Robert

    Hi, I tried to install CentOS 6.4 on my VMware with dynamic IP (not the static IP).
    and try install Apache. but i cannot see the Apache home page?
    (I got localhost IP from “#ifconfig”, but still not luck)

    any idea?

  • SK

    Hi probably iptables may restrict you. Allow the default port 80 through your firewall/router.
    See the updated article here.

  • Hiro Ferreira

    GREAT tutorial! Congratulations.

  • Abin Thomas Mathew

    Simple and easy to follow tutorial to install and start of phpMyAdmin. Thank you

  • Pingback: Monitoring | Knowledge Repository()

  • Pingback: Setup Newsletter And Mass Mailing System Using poMMo On CentOS 6.5 | GANGESH SHARMA(MCA,MCP,JCHNP)()

  • Pingback: Setup Document Management System Using OpenDocMan On CentOS 6.5 | GANGESH SHARMA(MCA,MCP,JCHNP)()

  • Pingback: LAMP Server Configuration | kamruddin()

  • Pingback: راه اندازی LAMP سرور همراه با ماژول mpm_itk در CentOs 6.4 | Linux Services Group()

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

  • Pingback: Setup Newsletter And Mass Mailing System Using poMMo On CentOS 6.5 | Windows – Linux()

  • Pingback: Setup Document Management System Using OpenDocMan On CentOS 6.5 | Windows – Linux()

  • Pingback: Setup Web Server Centos | Kuplux's()

  • Pingback: nagios installation on centos 6.5 | Linux Keeda()

  • Pingback: Install LAMP Server pada Linux Cent Os 6.5/6.4 -

  • Pingback: Manage Data Center Rack Like A Boss With RackTables - Techtunebd.Net()

  • Pingback: Install Zarafa On CentOS 6.5 – An Alternative To Microsoft Exchange Mail Server()

  • Pingback: OpenDCIM – A Free, Open Source Data Center Management Tool | Người Đến Từ Bình Dương()

  • Pingback: Charlie Ren's Blog | Install Zabbix in Centos 6.5()


    I love looking through an article that will make people think.
    Also, thanks for permitting me to comment!

  • sbothai

    Pretty section of content. I just stumbled upon your website and in accession capital to assert that
    I get in fact enjoyed account your blog posts.

    Any way I will be subscribing to your augment and even I achievement you access consistently quickly.

  • sniper shooter level 7 walkthrough

    I’ve been browsing online more than three hours today, yet I never found any interesting article like yours.
    It is pretty worth enough for me. Personally, if all web owners and bloggers made good content as you did, the web will be a lot more useful than ever before.

  • Sherri

    I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get setup?
    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web savvy so I’m not 100% certain. Any tips or advice would be
    greatly appreciated. Appreciate it

  • cool hoodies for men

    I have read so many articles on the topic of the blogger lovers however
    this post is really a good post, keep it up.

  • juegos de agilidad mental android

    En respuesta a sus comentarios, mejoras y optimizaciones incluyen un conjunto
    de presión mayor on line multijugador y el incremento de jugadores por
    el juego.

  • best tycoon games

    My spouse and I absolutely love your blog aand find a lot of your post’s to be exactly I’m looking for.
    Would yoou offer guest writers to write content for you?
    I wouldn’t mind writing a post or elaborating on a lot of the subjects yyou write
    related to here. Again, awesome website!

  • lol hack

    I like the valuable information you provide in your articles.
    I’ll bookmark your blog and check again here frequently.

    I’m quite sure I’ll learn lots of new stuff right here!
    Good luck for the next!

  • company facebook page

    Hi there very cool blog!! Guy .. Excellent .. Wonderful ..
    I will bookmark your blog and take the feeds additionally?
    I’m happy to serch out a lot of useful inf here in the post, we
    need work out extra techniques in this regard, thanks for sharing.
    . . . . .

  • chiropractor

    Jusst want to say your article is as astonishing. The clarity in your post is simlly
    cool and i could assume you are ann expert oon this subject.
    Welll with ypur permission let me to grab your RSS feed to keep up to date ith forthcoming post.
    Thanks a million and please continue the enjoyable work.

  • f1 2015 game trailer

    Glad there’s another venue for outdated video games since Bombastica is so rare.
    I nonetheless imagine in Operation: Quick Look All the pieces.

  • dolor de muelas remedios medicos

    Una vez tranquilizada, el ahogo prosiguió hasta mucho rato
    después. ); otras, de que se toman versos oraciones suyas para valorar
    trabajos ajenos (I, 33; X, cien, etc. ); otras, de que se usa su firma para autorizar envenenadas diatribas (VII, once y 72; X, tres y treinta
    y tres, antes que nada felicitarle por este artículo
    y agradecerles, en tanto que ayuda a bastantes personas.
    y los azúcares naturales de alta concentración endulzantes como miel, fruta
    seca, Introducí con suavidad un poco de hilo
    bucal en la muela que te duele.

  • grüner tee fettverbrennung

    Hello There. I found your blog using msn. This is an extremely well written article.
    I’ll be sure to bookmark it and return to read more of your useful info.
    Thanks for the post. I’ll definitely return.

  • Rafael

    Hi there! I know this is kinda off topic but I was wondering which blog platform are you using for this site?
    I’m getting tired of WordPress because I’ve had problems with hackers and I’m looking at options for another platform.

    I would be awesome if you could point me in the direction of a good platform.

  • los mejores celulares samsung galaxy

    El diseño también influye en el grado de protección que un equipo puede tener
    al padecer golpes caídas accidentales. Para mejorar todavía más su desempeño, Motorola ha incluido una memoria
    RAM de 3 GB, acompañada de una memoria interna que puede
    ser de hasta Lo que nos gusta: Es un celular desbloqueado de alto rendimiento con un costo de $ 300.
    GB, expandible hasta Todas estas mejoras en hardware, vienen acompañadas por
    cambios precisos en software.

  • Pingback: Install and Configure Nagios On CentOS, RHEL, Scientific Linux 6.5/6.4 | network999blog()