Saturday, March 2, 2013

How to install LAMP server on CentOS

LAMP is a solution stack of free, open source software. LAMP refers to the first letters of Linux (operating system), Apache (web server), MySQL (database server) and PHP (server side programming language).


For the sake of simplicity you need to turn off the firewall and SELinux.



Apache Server (The HTTP service)

The below commands by the order will install the service, run it and make it run in the startup

sudo yum install httpd
sudo service httpd start
sudo chkconfig httpd on

Now point your web browser to the IP address of the server http://Your-IP-Address/, The page should display the words “It works!

MySQL Server (The Database)

The below commands by the order will install the service, run it and make it run in the startup

sudo yum install mysql-server
sudo service mysqld start
sudo chkconfig mysqld on

Now setup the root password and basic configuration by writing the below command, for the beginner user it is recommended to use the default setting during the wizard

sudo /usr/bin/mysql_secure_installation

PHP (The Server side programming language)

You need to install each PHP module by typing the following

sudo yum install php-MODULENAME

as an example

sudo yum install php-mysql

to list all the available module run the following

yum search php-

Now test your server

Before the testing you need to restart the apache server by typing the below command

sudo service httpd restart

Create a new file in /var/www/html/ directory and name it as an example phpinfo.php and write the below inside the file

<?php
phpinfo();
?>

Now point your web browser to http://Your-IP-Address/phpinfo.php, The page should display all the information about your web server

I hope this been informative.


No comments:

Post a Comment