How to Install PHP and MySQL on the Linux Operating System

By Reddy Sharath

For beginners who start developing web applications on PHP, it is a common thing to find them in trouble while installing PHP and MySQL on the Linux operating system. However, there are a few simple steps which need to be followed in order to install PHP and MySQL on the Linux system. The first step is to ensure that the Linux operating system has been installed properly on the system. There are some specific distributions which are extremely developer-friendly like CentOS, Ubuntu and Suse Linux.

The first thing that needs to be installed in the system is the server. Generally, the Apache web server is preferred on a Linux system with PHP and MySQL completing the popular LAMP architecture (L – Linux, A – Apache, M – MySQL and P – PHP). On a CentOS linux system, the web server can be installed by opening the terminal and typing “yum install httpd”. Then the set of instructions needs to be followed for successful installation of the Apache web server.

After the server is installed, one can start with the installation of the PHP module on the server. Again, on a CentOS machine, you have to type in “yum install php” and the same process of following the on-screen instructions is to be followed. Once PHP is installed, the last thing left to do is to install mySQL.

Similarly, typing “yum install mysql-server mysql” and following the subsequent instructions would lead to the installation of the MySQL server. After the database server is installed, one needs to start the Apache server through the command “service httpd start”.

A notification would be sent on the screen if the web server service has successfully started. The next task is to start the mySQL server and this can be done by typing “service mysqld start” in the terminal window. When both the servers have been started, one can go to the “localhost” page and verify if the welcome page of CentOS is shown on the browser. This page confirms that the installation is correctly done.

The status of the PHP module can be checked by creating a same PHP page which prints the phpinfo() method. A purple PHP information page indicates that the PHP is working properly and is actively running on the server right now. Now, PHP and MySQL can be used to create web applications. The steps are easy to execute when followed in the order mentioned and when all the dependencies are present in the system.

To know about database management in greater details, you may visit Techyv.com – a website full of free online resources like articles, blogs, tips and tricks, questions and solutions to all things related to IT.