Search This Blog

Saturday, July 28, 2012

Setting Up a LAMP Server In Ubuntu Hardy Heron

LAMP stands for Linux, Apache, MySQL and PHP. It is the most widely used combination for setting up a Web Server. By far, the easiest way to install LAMP server is simply installing the Ubuntu Server Edition itself. However, many of us have installed the Ubuntu Desktop edition, only to find that we need to set up a LAMP server later on. In the following tutorial, I am going to show you how to install and configure a LAMP server in your Ubuntu Hardy Heron in less than 10 minutes.

Installing Apache, Php and MySql

In your Ubuntu desktop, go to System->Administration->Synaptic Package Manager.
Scroll down the list to search for apache2. Check the box beside it and select ‘Mark for installation‘. This will also install other dependency packages. When prompted, click ‘Mark‘.
Apache in Synaptic Package Manager
Next, scroll down the list and search for php5. Similarly, place a check beside the box and select ‘Mark for installation‘.
PHP5 in Synpatic Package Manager
Do the same for ‘mysql-server‘ and ‘phpmyadmin
MySQL in Synpatic Package Manager
phpmyadmin in Synpatic Package Manager
Once you are done, click ‘Apply‘ on the top icon bar.
The Synaptic Package Manager will now fetch all the files and install it in your Ubuntu.
When installing MySQL, you will be prompted to enter and reconfirm your password. Make sure that you enter a password that you can remember.
Setting mysql password
Also, the phpmyadmin will ask you which version of apache to use. Select apache2
Configuring Phpmyadmin
Testing your installation
Once you have finished installing the LAMP, you will need to test if it is working.
Open your browser and point the URL to http://localhost
If you see the words ‘It works’, then apache is working fine.
Testing Apache
Next, you want to create a php file to test your php setting.
gksu gedit /var/www/testphp.php
paste the following line to the file
Save and close the file.
In your browser, point the URL to http://localhost/testphp.php. You should see all the php information on the browser. If it prompt you to download the file, then your php configuration is not successful. Go to Synaptic Package Manager and reinstall php5
Testing PHp
Testing of phpmyadmin
On your browser, go to http://localhost/phpmyadmin. It should loads up the phpmyadmin login page. Log in with the user name root and the password you supplied when installing.
phpmyadmin login page
This will bring you to the main screen of phpmyadmin.
Putting it all together
To test if the apache, php5, MySQL and phpmyadmin are working together, we can test it out by installing WordPress.
Download WordPress here.
Extract the wordpress folder to your home folder.
Inside the folder, open up the wp-config-sample.php file. Edit the following information.
define(‘DB_NAME’, ‘wordpress’);    // The name of the database
define(‘DB_USER’, ‘root’);     // Your MySQL username
define(‘DB_PASSWORD’, ‘yourpasswordhere’); // …and password
Remember to change the ‘yourpasswordhere‘ to the password that you supplied during the MySQL installation.
Save the file as wp-config.php.
Next in your phpmyadmin, create a new database call wordpress.
phpmyadmin-new-db
Open a terminal, copy the wordpress folder to the apache working directory (the working directory is located at /var/www)
sudo cp -R wordpress /var/www/
Once done, on your browser, go to http://localhost/wordpress. The famous 5 minutes installation will show on screen. Follow the instructions. If is your LAMP configuration is good, your wordpress will be up in 1 minute.
That’s it. Enjoy!
[Reference: Lijamex's Blog, Howto Forge]

No comments:

Post a Comment

Thank you