In this post we will learn how to install LAMP on your linux distribution but first and the foremost we need to learn that whats LAMP. LAMP is derived from some important pillars of Linux where L stands for Linux A for Apache HTTPD server, M for Mysql and P for PHP/Perl/Python.
We will start from Apache
To install Apache we need to use following command for centos
# yum install httpd
#apt-get install apache2
You need understand the difference of Apache between Centos and Debian as in Centos its httpd and for Debian its apache2
Now we can start the service of apache by
For Centos: /etc/init.d/httpd start
For Debian: /etc/init.d/apache2 start
Next Step is to install MySQL on you linux server
For Centos : # yum install mysql mysql-server
For Debian : #apt-get install mysql-server
The next step is very important as we always need to use this step for a more secure installation
You will be prompted with the following screen
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): ## Press Enter ##
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] ## Press Enter ##
New password: ## Enter new password ##
Re-enter new password: ## Re-enter new password ##
Password updated successfully!
Reloading privilege tables..
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
Remove anonymous users? [Y/n] ## Press Enter ##
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] ## Press Enter ##
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] ## Press Enter ##
- Dropping test database...
- Removing privileges on test database...
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] ## Press Enter ##
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Note: MySQL contains data that is very critical sometimes so its important for you to secure you database with mysql_secure_installation
Now we will install PHP on our Linux distribution
For Centos: #yum install php-mysql
For Debian: # apt-get install php5 php-pear php5-mysql
One thing everyone should keep in mind that after installing PHP you have to restart apache on you server by the command which was shown you before
To check that you have successfully installed create a PHPinfo page on your server and access it through your browser
For Centos: #nano /var/www/html/info.php
For Debian: #nano /var/www/info.php
Add these lines
Save the file and access it through browser
Congratulations you have successfully installed LAMP on your linux server