No announcement yet.

Steps to install Lamp (Linux, apache, mysql php) on CentOS

  • Filter
  • Time
  • Show
Clear All
new posts

  • Steps to install Lamp (Linux, apache, mysql php) on CentOS

    Following is the simple steps for creating web server. LAMP (Linux, Apache, MySQL, PHP) is group of free software’s which is useful to run web server. Since Linux part is already taken care. Here is steps how to install Apache, MySQL, PHP.

    To setup LAMP server you require root access of the server.

    Step One Apache Installation

    Apache is free open source software which is running on more than 70% web servers in the world.

    To install Apache run following command:

    #yum install httpd

    Once installation is done, you can start Apache on your server.

    #service httpd start

    To start while booting run following command.

    #chkconfig –level 3 5 httpd on

    Now you can check if Apache is installed or not correctly. You just need to put your servers IP address in browser.


    Step two MySQL Installation.

    MySQL is a powerful database management system used for organizing databases on the server. We have mentioned very simple steps for MySQL installation below.

    To install MySQL follow the steps.

    # yum install mysql-server

    # service mysql start

    During MySQL installation it will ask you for permission twice. After you say Yes to both, MySQL will install.

    Once it’s done. You can set MySQL root password using following command.


    It will prompt you for current MySQL root password. Currently there is no password so you can keep it blank.

    Enter current password for root (enter for none):
    OK, successfully used password, moving on...
    CentOS will automatically prompt you for setting up MySQL, asking you questions like Yes or No. Now you are done with MySQL installation.

    Step three PHP installation.

    PHP is an open source scripting language that is used to build dynamic web pages.

    To install PHP on your server. Follow the steps.

    # yum install php php-mysql

    Once you answer yes in prompt then it will be successfully installed on your server.

    PHP Modules installation

    Php has a variety of useful libraries and modules that you can add to your server.

    You can see the libraries are available to install using following command.

    #yum search php-

    Above command will show you available modules and if you want more details about that modules then you can type following command.

    #yum info modulename

    Once you get the information and you decided to install module then start installation using following command.

    # yum install module name

    Congratulations!! Now you have installed LAMP on your server.

    And don’t forget to run following command to start your Apache and MySQL service when the server boots up.

    # chkconfig httpd on

    # chkconfig mysql on

    Step Four: Check PHP on your server.

    You can create phpinfo page and check php installation and modules installed on server using php info page.

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

    And add following lines in php info page.

    You can now visit php info page using following URL.


    Now your LAMP server is ready. You can upload your website pages and start your website.
    Aarav 92
    Red Hat Certified Security Specialist.

  • #2
    Re: Steps to install Lamp (Linux, apache, mysql php) on CentOS

    Hello Aarav92,

    Thank you for sharing such a nice and important information. Very useful for me......


    • #3
      Re: Steps to install Lamp (Linux, apache, mysql php) on CentOS

      Thank you, the above information is quite helpful, I've shared this thread with my folks for more awareness