Installing LAMP in centOS 6.3

 

"LAMP is a solution stack of free, open source software. The acronym LAMP refers to the first letters of Linux (operating system), Apache HTTP Server, MySQL (database software) and PHP -- principal components to build a viable general purpose web server." -- LAMP wiki article

Though, the letters M and P could also stand for MariaDB, Perl and Python respectively, this was made as a guide to install and configure Apache, MySQL and PHP on centOS 6.3.

Installing Apache webserver

1. Go to Applications > System Tools > Terminal




2. Access root privileges by typing su and pressing enter afterwards. Input your root password.



3. Type cd .. until you get to your root directory.



4. Type the following command yum install httpd and press enter.



5. Type the command service httpd start to start your apache server, or type service httpd restart to restart your apache server.

6. Type yum install nano to install the nano command (nano is used to edit the contents or source codes of files).

7. Type cd /var/www/html . Type nano index.html . Type any text you want in the field (this is the text which will appear if your apache server / localhost is working). Press Ctrl + X to save your file.


8. Configure your system to start Apache on boot by typing the following command: chkconfig --levels 235 httpd on

9. Restart your apache server by typing service httpd restart.

10. Now, go to your web browser, and type localhost. If you see the text you have saved in your index.html file, you have successfully installed and configured your apache server. Congratulations. 




Installing MySQL in centOS
 
1. Go to Applications > System Tools > Terminal




2. Access root privileges by typing su and pressing enter afterwards. Input your root password.



3. Type cd .. until you get to your root directory.





4. Type the command yum install mysql mysql-server . If prompted: input your desired mysql root username, and password, else proceed to the next step.

5. Type the command chkconfig --levels 235 mysqld on so that mySql would start on boot, and type service mysqld start.


6. Type the following commands mysql -u root , to access mysql, and type the following command: SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘<password>’) where <password> is the new password for the root user. 

Installing PHP in centOS

1. Go to Applications > System Tools > Terminal


2. Access root privileges by typing su and pressing enter afterwards. Input your root password.


3. Type cd .. until you get to your root directory.


4. Input the following command yum install php


5. Check whether PHP has been installed or configured properly in your system, by doing the following steps:

  a. Type cd var/www/html/
  b. Create a file entitled info.php by typing the following command: nano info.php
  c. Place the following script in the file: <?php phpinfo(); ?> and save the file.
  d. Access localhost/info.php in your browser. If this screen appears, you have successfully installed PHP on your system.