Popular Posts
Tools and Tips
Search
Tuesday, May 20. 2008
How to install Apache, MySQL and PHP (LAMP) in Ubuntu 8.04
Just like our Ubuntu 7.10 LAMP how to, this guide will cover the installation of Apache, MySQL and PHP on Ubuntu 8.04. I assume you're already running Ubuntu 8.04 for this guide. If you're still running 7.10, you can use this guide.Let's go ahead and open up a terminal (Applications->Accessories->Terminal) and if you want to save some time, Firefox or your favorite browser as well.
Time to get started. In our terminal window...
Once that's finished installing, we can start up Apache to test it by typing...
Now open up your browser (or if you're a time saver,) and point it to...
If you're cleanly installing Apache, you'll see the default installed folder index, or you'll see your normal server pages if you've updated.
Now that Apache is installed, PHP is next...
Once PHP has finished installing, if we restart Apache...
To test PHP, we'll make a new PHP document with any editor you want...
And paste the following code into the file to run PHP's phpinfo() function, which will show us a myriad of information about PHP...
Now we can save the file, and browse to...
To see all of the information about your PHP installation. For security reasons, you should remove this page when you're done with it. If you want to do that quickly...
Assuming you named the file phpinfo.php.
To install MySQL, in our terminal window...
If this is a clean installation of MySQL, it will prompt you to set your root password. Make sure that you type it correctly, as it will only ask you once. If you've upgraded, or installed MySQL before, it may not prompt you for a password.
Once MySQL is finished installing, we can test MySQL by connecting to it, using...
After filling in your own password after -p, you'll see a MySQL prompt.
That's it, you're done! You can type 'exit' to get out of MySQL.
if you want to install phpMyAdmin to administrate your MySQL, you can type...
Again, like MySQL, if this is a clean installation, it will ask you to choose a webserver to configure automatically. If you have had phpMyAdmin installed before, it won't prompt you to choose. You can use the space bar to select apache2 and then enter. Once that's finished, we need to restart one more time...

Now, to pull up your phpMyAdmin panel, you can point your browser at...
To log in and use PMA.
To Save yourself some time, you can make launchers for Apache or MySQL start, stop, and restart if you feel the need.
Installing Apache
Time to get started. In our terminal window...
sudo apt-get install apache2Testing Apache
Once that's finished installing, we can start up Apache to test it by typing...
sudo /etc/init.d/apache2 startNow open up your browser (or if you're a time saver,) and point it to...
http://localhostIf you're cleanly installing Apache, you'll see the default installed folder index, or you'll see your normal server pages if you've updated.
Installing PHP
Now that Apache is installed, PHP is next...
sudo apt-get install php5Once PHP has finished installing, if we restart Apache...
sudo /etc/init.d/apache2 restartTesting PHP
To test PHP, we'll make a new PHP document with any editor you want...
sudo gedit /var/www/phpinfo.phpAnd paste the following code into the file to run PHP's phpinfo() function, which will show us a myriad of information about PHP...
<?php phpinfo(); ?>Now we can save the file, and browse to...
http://localhost/phpinfo.phpTo see all of the information about your PHP installation. For security reasons, you should remove this page when you're done with it. If you want to do that quickly...
sudo rm -rf /var/www/phpinfo.phpAssuming you named the file phpinfo.php.
Installing MySQL
To install MySQL, in our terminal window...
sudo apt-get install mysql-serverIf this is a clean installation of MySQL, it will prompt you to set your root password. Make sure that you type it correctly, as it will only ask you once. If you've upgraded, or installed MySQL before, it may not prompt you for a password.
Testing MySQL
Once MySQL is finished installing, we can test MySQL by connecting to it, using...
mysql -uroot -pyourpasswordAfter filling in your own password after -p, you'll see a MySQL prompt.
That's it, you're done! You can type 'exit' to get out of MySQL.
Installing phpMyAdmin
if you want to install phpMyAdmin to administrate your MySQL, you can type...
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadminAgain, like MySQL, if this is a clean installation, it will ask you to choose a webserver to configure automatically. If you have had phpMyAdmin installed before, it won't prompt you to choose. You can use the space bar to select apache2 and then enter. Once that's finished, we need to restart one more time...

The End
Now, to pull up your phpMyAdmin panel, you can point your browser at...
http://localhost/phpmyadminTo log in and use PMA.
Useful Commands and Default Locations
To Save yourself some time, you can make launchers for Apache or MySQL start, stop, and restart if you feel the need.
Apache
sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restartMySQL
sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql restartLocations
/var/www/ -- Document Root
http://localhost/phpmyadmin -- phpMyAdmin
/usr/share -- phpMyAdmin local location
Posted by Joey
in Articles, How to, Linux, Misc, MySQL, PHP, Resources
at
01:24
| Comments (3)
| Trackbacks (0)
Trackbacks
Trackback specific URI for this entry
No Trackbacks

