Lately I’ve been using ubuntu 7.10 for all my projects/daily work.
As a web developer i should have LAMP on my machine and now i would guide you through installing it on yours.
This guide is divided into 3 steps: installing/tesing Apache, PHP and finally MySQL.
Lets start with Apache:
1. Open the terminal (we will be using it through most of my guide) from Applications > Accessories > Terminal
2. Install apache2 using apt-get by typing the following
Note that you should know the root password.
Now everything should be downloaded and installed automatically.
To start/stop apache2 write:
Your www folder should be in: /var/www/
If everything is OK you should see an ordinary HTML page when you type: http://localhost in your firefox browser
Finished with Apache ? lets conquer PHP:
1. Also in terminal write:
or any php version you like
2. restart apache
This is it for PHP ![]()
Wanna test it ? Just create an ordinary PHP page in /var/www/ and run it.
Example:
and write in it: < ?php echo “Hello World”; ?>
Now run it by typing http://localhost/test.php in firefox… You should see your ” Hello World ”
66 % is over, lets continue to installing MySQL:
1. Again and again in terminal execute:
2. (optional) If you are running a server you should probably bind your address by editing bind-address in /etc/mysql/my.cnf and replacing its value (127.0.0.1) by your IP address
3. set your root password (although mysql should ask you about that when installing)
4. Try running it
where xxx is your password.
Note: You can install PHPMyAdmin for a graphical user interface of MySQL by executing
5. restart apache for the last time
Congratulions your LAMP system is installed and running ![]()
Happy Coding
//Jo
UPDATE:
Due to the large number of people emailing about installing/running phpmyadmin.
Do the following:
The phpmyadmin configuration file will be installed in: /etc/phpmyadmin
Now you will have to edit the apache config file by typing
and include the following line:
Restart Apache
Another issue was making mysql run with php5
First install these packages:
then edit php.ini and add to it this line : ” extensions=mysql.so” if it isnt already there
Restart Apache
Hope this helps ![]()
Popularity: 82% [?]

Why dont you use the package provided from apachefriends.org? It’s done with 3 easy steps:
1. Download
2. Untar/Unzip
3. Start the script
I am using it and I can say that for development machine it’s prefect - saves a lot of effort and everything is in one folder.
Using APT (apt-get) the Apache, MySQL and PHP software installations will be updated from the Ubuntu repositories when new code is available. So that means bugfixes and security patches will get made available for download automatically. The OS handles this for you. I’m not sure you get that same functionality using the ‘apachefriends version’.
Coming from a Windows world it takes a little time to get used to the APT thinking of things, especially the fact that software is installed ‘all over the file directory structure’ and not in one particular user defined directory… I guess there are pros and cons with both.
You are completely right Lee, actually thats the exact purpose of apt-get
Please please please tell me how two things…
1) How do I stop and start apache?
2) And do I open phpmyadmin?
I am new to linux and could really use the help… thanks.
Fantastic, straightforward at to the point. Just what I was looking for
I also tried the LAMPP package, but I prefer to let apt take care of things. Besides, its actually easier to find things with a standard install as all other product install guides refer to locations used by this type of setup.
Bardic: to stop and start apache write
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 start
to do a restart
sudo /etc/init.d/apache2 restart
this is perfect guide for newbies to linux, it’s written perfectly easy and understandable. I used this to install so called LAMP server on my machine and it workes perfect
Big thanks to Jo
(i’m sorry for any mistakes in my english)
Excellent guide!
I have two additions:
When apt-get shows the error message “couldn’t find package phpmyadmin” you need to enable the universe repositories in “/etc/apt/sources.list”.
And MySQL did not ask me for a password, it told me:
* Root password is blank. To change it use:
* /etc/init.d/mysql reset-password
To change the password using your method you first need
to start the mysql interface using the following command:
$ mysql -uroot
After that you can change your password with:
mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’xxxxxx’);
After that you need to specify your password using -pxxxxxx
Thanks for your guide!
Nice Des, Thank you for sharing
Hey Jo,
Thanks for writing this guide, I’s been very useful! I Tried the Apachefriends.org version - It didn’t work. Whereas this, has worked a treat! *Bookmarks Website*
Thanks again,
Joe
Hi Jo,
Great tutorial thanks! It works a charm! Another cool thing you can do when testing whether PHP is properly installed is to create a phpinfo.php file with the following line in it:
It will then give you a whole raft of details on your PHP install when you go to http://localhost/phpinfo.php and it’s also a good file to drop somewhere on your web site to check what your ISP supports.
Bardic, to get to phpmyadmin, type http://localhost/phpmyadmin in your browser: as simple as that!
I got caught by the filtering of angle brackets and stuff so the phpinfo.php file mentioned in my previous post should contain:
<?php phpinfo(); ?>
thanx for the mysql tip bro
i couldn’t remember the name of the package for the love of god
I’ve been an Ubuntu user for about 36 hours. Using your article, I was able to install and test a web server, PHP, MySQL and PHPmyAdmin in under 15 minutes. I have yet to do the same in a Windows server in under 3 hours, and that is if all goes well. Incredible article and incredible OS.
Everything works great until I try to install the PHP stuff. After running for 8 hours repeatedley trying to load the following:
Get:135 http://sg.archive.ubuntu.com gutsy/main libapache2-mod-php5 5.2.3-1ubuntu6 [2542kB]
Seems to be stuck trying to load from sg.archive.ubuntu.com ?
I am in Singapore, is there a way I can force it to load from another repository, since Singapore seems unresponsive (I gather that is the 135th attempt to download, since he same message has been repeated constantly with the only thing changing being the number at the front.
Fantastic, just what I needed, thanks Jo.
One tiny thing I noticed. I was feeling lazy so I was just copying and pasting everything you put. When i tried testing PHP with the ‘Hello world’ example you gave, it didn’t appear to be working. I soon realised it was because there is a space after the opening bracket and before the question mark (”< ?” instead of “<?”)!!!! Simple thing but not sure if it would throw some people!
Thanks again.
Jo… Thanks very much for the very clear steps on getting the Ubuntu LAMP turned on! Only thing I would suggest is remove the space between the “< ?” in the “”. The space will trip up php, and show the code as plain text on the web page.
Thanks to Des too for his tip!
HEHE, I dont know how that space got there :p … fixed it now
Hi, Its good tip.
What if you want to use mssql i.e an external db. Tried to apt-get source php5 so that i can compile the mssql.so but always getting error.
I too got tripped up with the test.php space, I thought something was wrong with the install.
I did mine with synaptic packet manager but great to see the command line version, next time I will do it that way.
Thanks for the tutorial, was helpful.
Ubuntu 7.10
Hello guys,
I’ve the my apache2, php, and mysql using the above tutorial. It was successfully installed but what i’ve notice is the when i run the phpinfo there’s no mysql enabled there. I’ve tried to uncomment mysql.so in the /etc/php5/apache2/php.ini but still not showing in the phpinfo. Anyone has an idea?
Thanks.
I installed phpmyadmin but do not see it anywhere, itsnot in my www folder, how do I get to it?
Dave, go to:
http://localhost/phpmyadmin
Jo,
that doesn’t work either, 404 error. There is no phpmyadmin folder in my /var/www folder, the only folder I have is a /etc/phpmyadmin folder. Should I just copy it over? Thanks for taking the time to help me.
Nice….
But I have problem..
I am using ubuntu 7.10 server.
My server name is ubuntu.
I can’t run php in my localhost
when I run http://localhost/phpinfo.php, save dialog appear.
But http://ubuntu/phpinfo.php, OK and run it.
How to solve it ????
saturngod
open your http.conf and go to the line: ServerName … edit it so it becomes http://localhost/
Thank Jo…
How To Edit it ?
My http.conf have
ServerName localhost
only 1 line.
How to change it !!!!
the line should be:
ServerName localhost:80
Also make sure the location of ur file is the same one specified in http.conf
Thank Jo…
I testing it…
Hi! Joe…
I also do that
Not Work
$ sudo a2enmod php5
But Not Work.. http://locahost/phpinfo.php ( save dialog apperar )
Only work http://ubuntu/phpinfo.php
phpinfo.php at /var/www/
Hi i cant start my phpmyadmin when i type in my explorer http://localhost/phpmyadmin
I see this :
Not Found
The requested URL /phpmyadmin was not found on this server.
Apache/2.2.4 (Ubuntu) PHP/5.2.3-1ubuntu6.2 Server at localhost Port 80
Please tell me what to do My phpmyadmin is not in folder var/www
it is in usr/share/phpmyadmin
Please need help
Update not work please tell me what to do
Hi again i am sorry for my post before one hour. It working now http://localhost/phpmyadmin
When i restart my computer it working
Thank tou Very Very much Jo!
I am sorry for my bad english
I m glad it did
I think you forgot to restart Apache the first time
Hi there, thank you very much for this tutorial, it’s very helpful and has allowed me to successfully get LAMP set-up on my Ubuntu 7.10 desktop.
The problem I have now is that I’m unable to make any changes to the /var/www directory, i.e. I’m unable to add/edit any files in there. I think I know what the problem is, the directory has permissions set to it for root, but as I’m logged in as my user, it’s not letting me do anything.
Now I’m sure that I can use the terminal command sudo gedit to create and edit files in that directory, but this isn’t really solving my problem, firstly because I want to be able to access the files via the file manager, but also because I’m sure it’s not designed so you have to log into the superuser every time you want to do something like this.
This also would not solve the problem of remote access, i.e. either using FTP or windows explorer (via the network) to access the directory. I’m more interested in allowing specific users (such as myself, and my user on my windows machine) to access this folder.
As a result, I think a nice addition to this tutorial would be information on how to do this… Thank you.
Hi Daniel
Try doing ‘ sudo chown OWNER DESTINATION ‘
this will change the owner of all files inside the DESTINATION folder.
if you set OWNER = www . then everyone can access the file.
check ‘ man chown ‘ for more details
Jo
Hi, thank you for your reply.. I tried running ’sudo chown www /var/www’, but it just told me there was no user http://www.
I’ve got it working locally now by using ’sudo chown daniel /var/www’, which is a step in the correct direction, but as I said before, I’d be very keen on making that directory a shared directory so I can access it via the network from my windows machine.
Thank you
Great job!
I’d only change one thing.
You could test for a valid installation with the following script:
Not only does this test the installation, it shows all of PHP’s configuration information.
Since this message is so far down the page, I hope you’ll add this to your tutorial.
that script is
< ?php phpInfo(); >
Well done, ive been looking for ages for a way to install LAMP and this is the first guide i have found that got strait to the point, Thanks
hello world
i have installed Ubuntu 7.10 from a dvd which apparently doesn’t have the next packages : apache,mysql ,php,phpmyadmin,java and maybe other stuff which a developer might be interested in…
how the hell is that possible and what solution do you suggest,if any ?
Thx.
An excellent tutorial - many thanks for that.
Two very minor points.
1) Where you say edit php.ini and add to it this line : ” extensions=mysql.so” if it isnt already there
The word extension should be singular. The line should be
extension=mysql.so
2) The apt-get install of phpmyadmin created a link from /etc/apache2/conf.d/phpmyadmin.conf to /etc/phpmyadmin.apache.conf, so adding the line to /etc/apache2/apache.conf is unnecessary. Included twice the file triggered a warning from Apache. The alias was hidden by an earlier alias or similar. You either need the link or the line in /etc/apache2/apache.conf, not both.
Hi,
Very nice tutorial!
One minor issue though is that phpmyadmin installs to /usr/share/phpmyadmin (at least on my computer). That is probably why some of you get a “site not found error” when trying localhost/phpmyadmin. And that is because the phpmyadmin files is simply not in the /var/www directory. I solved the problem by creating a link:
cd /var/www
ln -s /usr/share/phpmyadmin phpmyadmin
and now it works fine…
/Dan
Hi how i can change the ip of the apache so i dont get tha message? apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
Just wondering….is MySQL necessary for LAMP?
Thanks
Be sure if you just installed Ubuntu and just did all the new updates, you need to restart before the apt packs will install. You will get an error saying that the file can’t be found. So…
1) install ubuntu
2) do all updates
3) restart
4) install LAMP using above methods
works
well i installed ubuntu server LAMP, when i start it takes me to GRUB, how do i accualy get on ubuntu.
I can not access phpmyadmin from the localhost/phpmyadmin in my browser. I tried to reload phpmyadmin then placed this command in the terminal prompt like suggested:
sudo vi /etc/apache2/apache2.conf
After that I’m supposed to put this phrase:
Include /etc/phpmyadmin/apache.conf
How do I do this and will this fix the problem of accessing phpmyadmin.
Thanks for your help
Thanks,very nice tutorial!
I just wanted to ask, what should I install or configure to run python scripts?
Thanks again.
Thanks alot for this tutorial. If you run a home network, I dare you to check this out http://aflog.org/misc.php
Nice tutorial…great help while setting up a LAMP server for the first time!
thanks !! First time I can install LAMP on my Gutsy…. thanks again. It’s nice tutorial
First time trying to install LAMP….. worked previously with WAMP
Great Tutorial!!!!!!
hi jo.,
i have installed lamp successfuly as u said,,, and iv tried working out all siple php programs and they do work… but the problem is when im working on a program that links php to mysql it shows an error which says “undefined call to mysql_connect on line watever it appeared…
i would be very thankful if u cud tell me something about this..
Thanks..
G’day
I’ve just installed Apache on my private web server (for testing sites) and when it runs non-scripted files (.html and the like) it’ll display them.
Though, when I try to run a PHP file it comes up with a dialog box asking me to download a .phtml file.
What do I need to do to configure it properly?
Cheers,
Seb.
sudo tasksel install lamp-server
Works perfectly
Also -
** Webmin is useful as is phpinfo()
** You can also install the Ubuntu LAMP via
SYS->ADMIN->SYNAPTIC->EDIT->MARK PACKAGES BY TASK->LAMP SERVER
well
the php installation part…
it doesnt run the php itself instead it just displays the code ;/
how to fix that?
thx
Thanks Joe, you really made the process a heck of a lot easier for me. I wish everyone’s tutorials were so straight to the point and easy to follow.
..oh.. and if anyone is trying to get rails up..
here a walk-through…
hey sam,
“Example:
sudo gedit /var/www/test.php
and write in it: ”
dont give a space between ‘<’ and ‘?’
the structure
tells that there is some php code in between.
so the correct code to test would be –
Hey Joe,
Thanks for the tutorial. I too am new to the linux world. I need help and wanted to know if you have installed and used PHPmailer? If so any help you can give would be greatly appreciated.
Scott
Hi there, thank you for your useful guide.
I took the liberty to make a spanish translation of it and add a little extra bit to it, at:
http://lobotuerto.com/blog/2008/04/30/como-instalar-lamp-en-ubuntu-804/
Useless guide. Lamp from ubuntu repositories has default configurations that are only usefull if you intend to play a litle, otherwise you better install from source so that it gets configured as you want.
Hi
I am using ubuntu 8.04 and This lesson not work propertly for ubuntu 8.04
Can you tell me how to setup my LAMP server on ubuntu 8.04
I will be very happy becose i am a new in unix OS
Thanx & Sorry for the bad english
great tutorial, making setting up real monkey work
Hi great tutorial.
Just 1 Q, will this work for Ubuntu 8.04 aswell?
Hey,
yes it will work on ubuntu 8.10 as well
// Jo
Worked Perfectly for Ubuntu Hardy,
Awesome Guide,
Thanks,
Excellent tutor Jo!
Thanks for the sharing. In several minutes i already have my local server environment, great!
just one attempt and i can use it now.
hi every body i am new to linux i lamp in my ubuntu linux 8.04 .i successfully installed it the only problem is when i disconnect the internet phpmyadmin and php is not working it showing an error page but apache is running i want to run phpmyadmin and php when i disconnect the internet could any one tell the solution for this problem
About getting the 404 not found error, Dans suggestion on using the symbolic link worked for me. Thanks!
Steve posted the command
sudo tasksel install lamp-server
a ways back. Have a look at these;
https://help.ubuntu.com/community/ApacheMySQLPHP
https://help.ubuntu.com/community/Tasksel
Makes life even easier.