What is LAMP?LAMP - the abbreviation of first letters of words Linux + APache + MySQL + PHP:
Linux - the operating system;
Apache - Web server;
MySQL - a database management system (DBMS);
PHP - scripting language used to create the server-side sites.
In fact, this is all that is needed for the local host. The only thing missing, it's phpMyAdmin, which makes working with databases MySQL. PhpMyAdmin is installed separately, and it is discussed in later part of this article.
Installing LAMP on UbuntuOpen a terminal and type the following command:
sudo apt-get install lamp-server^
After entering the password, the administrator will check what packages are already in the operating system and which should be set.
A message will appear asking: "Do you want to continue? [Y/n]". Enter the letter "Y" and press Enter.
It will begin installing LAMP on Ubuntu .
During the installation, you will be asked to enter administrator password of MySQL only twice, the rest is done automatically.
Testing ApacheOnce the installation is complete for LAMP, open a browser and enter the address of the local server: http://localhost. You should see the test page that says «It works!».
If you want to start, stop, and restart Apache Web server, you can enter appropriate command from the following:
sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart
Root directory of the local site directory will be /var/www. By default, you need to be administrator to modify the files under this directory. If desired, you can change this by setting the directory permissions to 777 using the following command:
sudo chmod -r 777 /var/www
After this, any user can do with the folder and files in it anything you like.
To check whether PHP is working fine, create a new file using following command:
sudo nano /var/www/testing.php
Paste the following code into the file:
<?php phpinfo(); ?>
It will look like this,
Press CTRL+O to save the file, and then CTRL+X to exit.
Restart Apache using command as stated above.
Go to following link in your web browser
It will display something like this:
MySQL Bind AddressTo check the bind address that your system has, enter:
sudo cat /etc/hosts | grep localhost
It will show you your system's Bind address, which is 127.0.0.1 in my case.
Now, open MySQL Config file using:
sudo nano /etc/mysql/my.conf
Scroll down some line until you see "Bind Address" like this:
If this Bind address matches the one shown earlier, it's well and good. Otherwise change this field to match your band address that you found earlier.
phpMyAdminIf you are a new to MYSQL and commands related to it, it will be troublesome to manage databases and everything. phpMyAdmin helps you in dealing with those problems by introducing a PHP interface for MySQL administration.
Enter following command to install it:
sudo apt-get install phpmyadmin
After this, another blue screen will appear before you asking which web server you want to configure to run phpMyAdmin. Confirm that you choose "Apache2" by hitting Spacebar. Selected option will be marked by an asterick, then you can press Enter.
It will ask you if phpMyAdmin should configure a default database for its own use. Select Yes and proceed.
Enter MySQL root password as we haven't added any MySQL user yet.
Enter the password that you would like to use for phpMyAdmin account and confirm it.
It's now turn to restart Apache2. You have done it before too.
You can log in to your phpMyAdmin account using the URL shown below
Username will be "root" and password will be root MySQL Password.
- Use strong passwords as you are allowing others to access your computer after you install this software.
- All the files you wish to host will reside in /var/www directory. You need to change the permissions if you want access to this directory.