Installing Apache, MySQL and PHP in Linux Operating System requires few prerequisites for the procedure. We will discuss all the installations and requirements in this article. Before installing LAMP environment for Linux, we need to install a shell program which will be used to install LAMP.
What is SUDO?
sudo is an abbreviation of “super user do” and is a Linux command that allows programs to be executed as a super user (aka root user) or another user. It’s basically the Linux/Mac equivalent of the run as command in Windows.
sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. By running sudo with the -v option, a user can update the cached credentials without running a command.
Sudo is a Linux program meant to allow a user to use root privileges for a limited time frame to users and log root activity. It allows users to run programs with the privileges of another user, by default, the superuser. The program is supplied for most UNIX and Linux-based operating systems.
After understanding SUDO, now we can easily learn how to install LAMP in Linux environment. Lets start installing LAMP with the simple or basic method. In which we will be installing Apache, MySQL and PHP individually.
Step 1: Install Apache
Apache is a free open source software which runs over 50% of the world’s web servers.
To install apache, open terminal and type in these commands:
sudo apt-get install apache2
Step 2: Install MySQL
MySQL is a powerful database management system used for organizing and retrieving data.
To install MySQL, open terminal and type in these commands:
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
During the installation, MySQL will ask you to set a root password. If you miss the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL shell.
Once you have installed MySQL, we should activate it with this command:
Finish up by running the MySQL set up script:
The prompt will ask you for your current root password.
It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
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 production environment. Remove anonymous users? [Y/n] y ... Success! 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] y ... Success! 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] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up...
Once you’re done with that you can finish up by installing PHP.
Step 3: Install PHP
PHP is an open source web scripting language that is widely use to build dynamic webpages.
To install PHP, open terminal and type in this command.
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
After you answer yes to the prompt twice, PHP will install itself. Add index.php to the beginning of index files.
PHP also has a variety of useful libraries and modules that you can add onto your virtual server. You can see the libraries that are available.
apt-cache search php5-
After reading out all the steps and methods you can also watch the fallowing videos to understand the steps to install LAMP or Xampp in Linux.
Installing Xampp Method: