Tags

, , , ,

Being as a web developer I often have to configure my Ubuntu as a web server for developing PHP projects. This is actually pretty common thing that you have to make it whether you are in windows or mac. In this tutorial I will show you how to make web server in your favorite OS Ubuntu. So, let’s do it.

First install the apache2 php5 and mysql

sudo apt-get install apache2 php5 php5-gd mysql-server phpmyadmin

This will install all the necessary applications you need. You may be prompted to decide on a MySQL root password (set one if you want), and to configure PHPMyAdmin (select apache2 as the server type). After that, we need to perform some minor configuration to get PHPMyAdmin working.

Open your terminal from applications->accessories->terminal and type the following line.
sudo gedit /etc/apache2/apache2.conf

Add this line at the bottom
# Enable PHPMyAdmin
Include /etc/phpmyadmin/apache.conf

Now Save and Exit then restart Apache
sudo /etc/init.d/apache2 restart

Everything should now be configured – go to http://localhost for local webpages , and http://localhost/phpmyadmin for database administration. If everything is okay you should see

localhost

phpmyadmin

Adding a virtual host to your LAMP server

To add virtual hosts in your server follow my previous post here.

Now enable mod_rewrite

cd /etc/apache2/mods-enabled
sudo touch rewrite.load
sudo gedit rewrite.load

Now paste this following line
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

Then edit
sudo gedit /etc/apache2/sites-available/default
Find the following lines
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

and change it to
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all

Finally restart Apache
sudo /etc/init.d/apache2 restart

That’s it now your PC is ready for development. Enjoy!

Advertisements