How to Install Apache, MySQL and PHP (LAMP) on Centos

Recently my laptop was having some issue, and send to hewlett packet service center for repair. Due to no computer use, and kinda free at office, I decide to continue setup a linux base web server which is in my wish list long time ago. (As mention on free antivirus for linux operating system).

Centos Operating System

I have download Centos 5.2 (www.centos.org) few month ago, also try to install it and experience it, but not much time to really put my self in study on Linux base operating system. After install centos linux base operation system, now I require web server script, Apache, web programming script, PHP, and a database script, MySql. So how to install all this script? I found a easy way to install Linux Apache MySql PHP (LAMP) using Yum command. Just simple 5 step to fully setup your own web server.

How to install Apache using Yum command:
install apache using Yam

Open Terminal, type in ” yum install httpd “, the command will instruct the centos to download apache web server and install it into the server.

How to install MySql using Yum command:
install mysql using yum

After install Apache Web Server, now we require to install MySql database. Type in ” yum install mysql-server mysql “, this command will download MySql dabatase into the server and install it.

How to install PHP using Yum command:
install php using yum

Once finish install MySql server script, lastly, we need to install PHP programming script by type in ” yum install php ” it will download php script and install into the linux server.

After finish install Apache, MySql and PHP, now we require to start the Apache Web Server service and MySql database service.

Optional Method: You can install Apache, MySql and PHP into centos together with using ” yum install httpd php mysql-server mysql ” command, after hit enter, you can sit a side wait for all this 3 script install into your Linux Web Server.

How to start Apache web server:
start apache

Simply type in ” service httpd start ” in the terminal, and the service will be activated.

How to start MySql database service:

To start the MySql server, type in ” service mysqld start ” in the terminal, and MySql service is ready to use. You can create a database, create table, and create record using MySql command line at the terminal.

How to test the Web Server and ensure it is running?
After both Apache Web server and MySql database is start running, now we open a internet explorer, access “http://localhost/” or “http://127.0.0.1” and you will see a welcome page!

centos welcome page

The root directory for the web server will be located at ” var/www/html “, you can try to create an index.html, save it at ” var/www/html “, you will saw this webpage when you access “ http://localhost/ ” or “ http://127.0.0.1/

How to test the Web Server and ensure it is running on the network?
If you are in the network environment, you can use the other computer within the network, and access the web server IP address. For example, the web server local IP address is 192.168.1.5, you can use other computer within the network to access ” http://192.168.1.5 “, you will see the welcome page or the index.html you create in ” var/www/html ” at the web server.

Ok, is time for me to play around the web server, will keep you guys posted if I found any special during my hand on experience. 😀

12 Responses to “How to Install Apache, MySQL and PHP (LAMP) on Centos”

  1. hyperX April 14, 2009 at 1:11 am #

    Nice tips! But for lazy people like me who uses Windows OS, I usually use easyPHP or WAMP.

  2. calvyn April 16, 2009 at 11:45 am #

    EasyPhp and WAMP got Linux version?

  3. susetips April 16, 2009 at 11:35 pm #

    Nice tips. Will try to find out the linux version

  4. CrumX April 17, 2009 at 3:32 pm #

    You can download LxAdmin and install it on your CentOS its come with everything u need ^^

  5. Neo April 17, 2009 at 4:44 pm #

    Can I type yum install sexy-girls?

  6. calvyn April 19, 2009 at 10:55 pm #

    CrumX >
    Thank for the information, I shall try this LxAdmin too 😉

    Neo >
    Lol.. I wish to hav this command too…

  7. Ah Hong April 20, 2009 at 10:29 am #

    I tried before Centos LAMP, quite stable…

  8. Dan June 22, 2009 at 6:52 pm #

    Once the LAMP stack is installed, it is recommended to secure all applications (Apache, PHP, MySQL).

    You can find the steps about security here:
    http ://www.sysadmin.md/install-and-secure-lamp-on-centos.html

  9. sohag September 7, 2009 at 10:27 am #

    i want get free ppt

  10. khairul Amin February 22, 2010 at 11:09 am #

    Better to use sudo or su -c
    preceding the commands. using root access is highly not recommended.
    For e.g. try

    su -c ‘yum install php’

    This gives temporary root authorisation to the yum app.

    Nice space btw.

    Khairul A.

  11. Saint_Ian June 10, 2011 at 5:03 pm #

    Xampp is the easiest way:

    Linux : http://www.apachefriends.org/en/xampp-linux.html
    Windows: http://www.apachefriends.org/en/xampp-windows.html

  12. lam September 7, 2011 at 7:04 pm #

    please help me , step by step , how to install joomla on centos ,

Leave a Reply