LAMP stands for Linux Apache MySql and PHP. Basically LAMP consists of all the applications that are required to create and run a website.
- For hosting a website, you will need Webserver, which here is Apache.
- To store the data, we need a database. Here it is MySql.
- To run server side scripts we need a scripting language. Here it is PHP.
So basically, installing LAMP is installing and configuring Apache, MySql and PHP. Web-hosting companies, generally use Linux and they have LAMP installed in those servers. So if you have the html pages, you can install LAMP in Ubuntu, do some coding in PHP, configure it with MySql and host your own website for free.
Lets we will see how to setup your own LAMP server in Ubuntu.
Lets see how to install components of LAMP one by one.
- Apache
–apt-get install apache2
To install Apache, open terminal and write–
service apache2 restart
Once apache is installed start/restart the service.
-Check if apache is working, by entering ‘localhost‘ in your address bar of browser.
- PHP
apt-get install php5 libapache2-mod-php5
To install PHP, we also need to install its a package named ‘labapache-mod-php5’ with it.
service apache2 restart
After installing restart the server, restart apache service.– Now, we will test the installed PHP. So create a file in ‘/var/www‘ with any name but having the extension ‘.php’. For example, ‘testing.php‘
– <?php phpinfo(); ?>
Inside the php file, copy paste this code.– Open your browser and enter localhost/’filename’
here, localhost/testing.php
- MySql
– apt-get install mysql-server
To installMySql database, install packagemysql-server– It will ask for a root password. You can leave it blank, but its strongly recommended that you enter a root password. Remember this password.
vim /etc/mysql/my.cnf
(Optional)
If you want other computer in your network, to view the MySql server that you created, open my.cnf file
and insert your IP address in ‘bind-address’– mysql -u root -p
To use MySql, enter this in terminal.
Here ‘-u’ points to the user, as in this case it is root, and ‘-p’ is used to give the root password.
Enter the password. - phpMyAdmin (Optional)
– Earlier in LAMP, we used to install php, but recently industries are switching to phpMyAdmin because of its easy configuration and simple yet interactivve Graphical User Inter. If you wish to install phpMyAdmin, follow these steps :- apt-get install phpmyadmin libapache2-mod-auth-mysql php5-mysql
– It will then ask you which web server are you using? Select your webserver.
– Install database.
If you don’t have a database, you can create one in phpMyAdmin and set the Database Administrator password as well as MySql application password.
If you wish to configure the database on you own, select No.– Test phpMyAdmin by going to ‘localhost/phpmyadmin’