How to Setup a LAMP Server on Ubuntu – Locally run and test WordPress on LAMP Server

Many think that setting up a local Web Server is costly, and can be done by professionals only. It is not true. Nowadays it easy to setup one yourself, without spending a dime and without any headache. Why would a non professional or blogger need a Web Server? You can test new WordPress themes, plugins, and try to find solutions to issues before loading them on your main Server.
The LAMP Server is made up of;a Linux distro, Apache web server, MySQL database and PHP. So we’ll install Apache2, MySQL Server, and PHP scripting language on the Ubuntu/Debian Linux platform. A minimum 256MB of RAM is needed if you don’t want to have issues with the mysql server.
Install Apache together with PHP 4 or PHP 5. From your terminal do
sudo apt-get install apache2 php5 libapache2-mod-php5 – If you prefer PHP4 then replace the ’5′ with ’4′ Restart apache with sudo /etc/init.d/apache2 restart
You’ll find the Apache configuration file at: /etc/apache2/apache2.conf and the web folder at /var/www
Check if PHP was properly installed by carrying-out this simple test. Create a file called test.php in your web folder /var/www and place this function in it <?php phpinfo(); ?> Point your browser to this page e.g http://localhost/test.php. If all is set and done, then you’ll see the PHP settings, with a heading like “PHP Version 5.2.4-2ubuntu5”
Install MYSQL Database Server
This is the sequential database server that WordPress uses to store all your personal configurations, articles and more. You certainly need it to get WordPress fully operational. Many other CMS blogging portals use it.
Now install mysql 5 and client; sudo apt-get install mysql-server
Since we’ll be running PHP4 or PHP5 then we need to install the correspondent php module for mysql 5;
sudo apt-get install mysql-server mysql-client php5-mysql – Change ’5′ to ’4′ if you’re using PHP4.
You’ll find the mysql configuration file at /etc/mysql/my.cnf
Change the root password during the installation if you find it necessary, you can do so later with
mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=”Your new-password” WHERE user=’root’ ;
mysql> FLUSH PRIVILEGES;
It is advisable to create a new account to connect to your mysql databases, this way you avoclass using your root account. The best way to get this done is with phpMyAdmin. phpMyAdmin is a simple GUI administration interface that makes things easier when trying to set-up accounts, databases and tables on MySQL database.
To install it do; sudo apt-get install phpmyadmin. You’ll find the configuration file located at /etc/phpmyadmin.
To complete the installation of phpmyadmin under Apache2, add the following line in the Apache configuration file at /etc/apache2/apache2.conf Include /etc/phpmyadmin/apache.conf (preferably at the end of that file where you’ll find other Include syntaxes)
Next restart Apache with sudo /etc/init.d/apache2 restart.
Now test your phpmyadmin installation- point your browser to phpmyadmin e.g http://localhost/phpmyadmin. You shall be taken to the login page, use your root account to get in.
Finally to get WordPress on your newly created web server, all you have to do is
1)Download WordPress and unzip
2)Load the WordPress folder in /var/www
3)Login into phpMyAdmin as root and create a database called wordpress
4)In the WordPress folder that is /var/www/wordpress edit the wp-config-sample.php and rename it wp-config.php
5)Now point your browser to your wordpress e.g http://127.0.1.1/wordpress/
6) Fill-in the form, You’re done. Enjoy
Remember that all the applications above mentioned are Open Source, released under the GPL/GNU license and have no cost.




10:00 am on May 14th, 2008
The best free web server setup anyone can lay hands on, Linux,apache, Mysql, PHP+ phpMyAdmin +Wordpress
10:01 am on May 15th, 2008
Well given that i’m trying to create my one themes I’ll down to trying this, I’ll be back to you if i get issues
10:02 am on May 15th, 2008
Not doubts about how free and useful this setup could be
10:06 pm on June 18th, 2008
[…] Lamp Server installieren [via Frank Mazny] « Wörter als Schlagwortwolke darstellen […]
9:13 am on July 30th, 2008
Yes, you are right. It isn’t so hard to install LAMP server, but I would like to point you to some main steps in LAMP post configuration like minimize running services (daemons), firewall, forbid ssh root access … It can be useful and if you are interested, please read at http://www.redips.net/linux/lamp-setup/
9:16 am on July 30th, 2008
Darko => Thanks for the addition…
8:37 pm on September 6th, 2008
Brilliant guide, worked liked clockwork! thank you so much
9:24 pm on September 6th, 2008
Hi Callaghan; welcome to the LAMP world and to Kabatology. I’m happy it worked for you.
12:42 am on April 19th, 2009
i followed the steps mentioned. the default index.html in /var/www works, but when i have added a php file there and ran http://localhost/test.php, it does not work and browser attempts to downaload the file.
Please let me know any tip to set any config file.
Thanks
zahir
12:14 pm on April 30th, 2009
@ ZAHIR: After installing the LAMP Server, all files for your website go inside this directory: /var/www
But this directory is often Writable only by root/admin. In your case, you’ll certainly have to do this:
sudo chmod 775 /var/www
sudo chgrp admin /var/www
And to ensure that you are part of the admin group
groups | grep ” admin ” -color=always
To have full write access to that directory, re-log-in.
You can now copy/move your php scripts directly to that folder.
1:29 pm on April 30th, 2009
@jadoon88 How to Setup a LAMP Server on Ubuntu and test WordPress on LAMP Server http://tinyurl.com/5fbd5z
2:58 pm on May 4th, 2009
I am a newbie and have a question, I have not changed the config.inc.php file for controluser authentication mode.
When I log in to phpMyAdmin I get an error message displayed at the bottom of the control panel screen, “Connection for controluser as defined in your configuration failed.”
Do I need to set my username and password in the config.inc.php or can I fully use Mysql and php as it is without changing this file?
Martin Kaba Thank you for your valuable help so far.
12:43 am on May 12th, 2009
Just wanted to thank you for the instructions. It worked great on my new Jaunty setup. One of the best things about Linux is the great community!
11:48 am on May 19th, 2009
First: Thanks for providing this. Helped me get going with serving WordPress.
To the point: There’s a small typo in the guide that makes the php test fail:
You see there’s a space between the “<” and “?”.
Remove the space and the tag begins to work !
Greetings from gunnar in Sweden
12:04 pm on May 19th, 2009
@[email protected]: Many thanks Gunner, what a mess, it has been sitting there for so long now and has certainly given head-ache to many. thanks again.
11:31 am on June 17th, 2009
How to Setup a LAMP Server on Ubuntu #linux #ubuntu http://bit.ly/16Ba8j
11:32 am on June 17th, 2009
How to Setup a LAMP Server on Ubuntu #linux #ubuntu http://bit.ly/16Ba8j by @leibowitz
11:42 am on June 17th, 2009
RT @leibowitz How to Setup a LAMP Server on Ubuntu #linux #ubuntu http://bit.ly/16Ba8j
12:25 pm on June 17th, 2009
How to Setup a LAMP Server on Ubuntu #linux #ubuntu http://bit.ly/16Ba8j (via @leibowitz)
2:57 am on June 28th, 2009
nice instructions thanks!
9:34 pm on July 19th, 2009
mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=”Your new-password” WHERE user=’root’ ;
mysql> FLUSH PRIVILEGES;
one part missing. ..
if v use this way.. password wont get encrypted and we may not be able to login to mysql again
correct way
UPDATE user SET password=PASSWORD(‘Your new-password’) WHERE user=’root’ ;
OTHER THAN THIS.. THE INSTRUCTIONS WERE AWESOME
thanks
changing the the root password should be corrected as follows
3:00 pm on August 3rd, 2009
I tried above steps…When I point to http://127.0.1.1/wordpress/ it prompts as “Error establishing a database connection”.
2:08 pm on October 17th, 2009
????? ????? ????? ???? ??? ?????? lamp http://tinyurl.com/5fbd5z #ubuntu
2:11 pm on October 17th, 2009
http://bit.ly/eeeRx ????? ????? ????? ???? ??? ?????? lamp #ubuntu
2:38 pm on October 17th, 2009
RT: @vipnewstoday: RT: @dailybarid: ????? ????? ????? ???? ??? ?????? lamp http://tinyurl.com/5fbd5z #ubuntu ??? ??? ???? ????
4:02 pm on December 5th, 2009
Using this tutorial to set up an Ubuntu LAMP server w\ WordPress: http://bit.ly/YAixN