Apache is the most commonly used web server. It is a free open source web server. PHP is an open source server scripting language. It has a lot of advantages. MySQL is also an open source database used for small and medium data storage. It can also used for large data storage also.
We can install apache, PHP and MySQL in two ways. 1. Download source code from their site and install. 2 the easiest way install it from synaptic package manager. If you use this method apt-get automatically manage all dependencies. So I explain the second method here.
1. Open the Terminal from Applications -> Accessories -> Terminal
2. Install apache2 copy paste command to terminal
sudo apt-get install apache2
3. Install PHP5
sudo apt-get install php5 libapache2-mod-php5
4. Restart apache
sudo /etc/init.d/apache2 restart
Now the PHP was installed. To test it create a php page in /var/www/ - the webroot and run it
Example sudo gedit /var/www/hello.php
write a basic php code in it
to run this script type http://localhost/hello.php in your browser and you can see "Hello World" in it.
5. Install mySQL
sudo apt-get install mysql-client mysql-server mysql-query-browser mysql-admin mysql-navigator php5-mysql php5-gd
6. Restart apache
sudo /etc/init.d/apache2 restart
7. If you need phpmyadmin follow this step. If you like to use MySQL GUI then skip this step
sudo apt-get install phpmyadmin
Restart apache
sudo /etc/init.d/apache2 restart
Add following lines in httpd.conf
# Enable PHPMyAdmin Include /etc/phpmyadmin/apache.conf
To access httpd.conf copy paste following line to terminal
sudo gedit /etc/apache2/httpd.conf
Restart apache
8. If you need to access your url as http://localhost/~username, enable userdir module in apache2. enable mod_rewrite to allow clean url
cd /etc/apache2/mods-enabled sudo ln -s ../mods-available/userdir.load sudo ln -s ../mods-available/userdir.conf sudo ln -s ../mods-available/rewrite.load sudo /etc/init.d/apache2 reload
9. Create folder /home/<username>/public_html -- > this is the folder which we are going to use as the document root for local development. So you will be accessing your local websites as http://localhost/~username/sitename
10. Edit /etc/apache2/mods-available/userdir.conf and change the AllowOverride line to just read AllowOverride All
Now you can use public_html as user document root
Enjoy scripting