Installing Apache Mysql and PHP on Ubuntu 8.10

If you are doing any type of development on a Linux box you are probably going to need the LAMP suite. That is, Linux, Apache, Mysql, and PHP. This is by far the most common collection of apps used to serve web content. It is often used to serve open source projects like Wordpress and many others. The other benefit is that it is free!

In this guide I am going to assume you already have Ubuntu 8.10 (intrepid) installed. If not you can head over to Ubuntu.com and grab it.

Installation

Apache

The first app we will install is the web server Apache. To get started open your console and type:

sudo apt-get install apache2

After you put in your password and accept and a short wait you should have a working installation of Apache. To test it point your web browser to http://localhost

Apache default screen

PHP

sudo apt-get install php5 libapache2-mod-php5

Once this finishes we need to restart Apache. This will apply the changes.

sudo /etc/init.d/apache2 restart

Now lets test it by replacing ‘/var/www/index.html’ with index.php adding the following line:

Vim phpinfo

MySQL

Install all the MySQL stuff:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

When you get a prompt enter a password you would like to use as the root MySQL user.

Once done open, ‘/etc/mysql/my.cnf’ and change the bind-address to your local IP. (usually 192.x number).

mysql bind-address

Extra Stuff

phpmyadmin

sudo apt-get install phpmyadmin

After phpmyadmin is installed you can see it view it, http://localhost/phpmyadmin/.

mod_rewrite

Chances are you want to use mod_rewrite in your applications to make URLs a bit more pretty. It is also required by lots of software, like Wordpress.

sudo a2enmod rewrite

/etc/init.d/apache restart

Starting and Stopping Apache

Run, Stop, Test, And Restart Apache

Use the following command to run Apache :

sudo /usr/sbin/apache2ctl start

To stop it, use :

sudo /usr/sbin/apache2ctl stop

To test configuration changes, use :

sudo /usr/sbin/apache2ctl configtest

Finally, to restart it, run :

sudo /usr/sbin/apache2ctl restart