07 July, 2011

Change the DocumentRoot of Apache webserver (/var/www) in Debian / Ubuntu

The document root (also called as the web root) of the Apache web server is located at the /var/www directory by default. Document root is the place where we find all the web pages and server scripts. These files are loaded on the browsers when we type in a particular url to point to that server. 

The /var/www directory doesn't allow access for a user who doesn't have the root permission. It's a headache task to switch to the root mode by typing in the root password everytime even though you know the password, since you may have to change your webpages or scripts during its development stage  very frequently. So a better idea to avoid this problem is to change the default Document root directory to some other location which doesn't require root permission for access.


Change it dude !!!
- - - - - - - - - - - - - - - - - -#

Inorder to change the document root,

#1. Make a directory somewhere inside your home directory to use as the Document root. (not necessarily be home... you can make it anywhere). I named it 'www'

$ mkdir /home/jo/www

#2. Now we have to edit the one of the configuration file of the Apache webserver. The file is located @  /etc/apache2/sites-available/default (requires root permission to edit it).

$ sudo gedit /etc/apache2/sites-available/default

The file will be opened up in the gedit text editor. Now you have to edit the DocumentRoot directive in this file. Replace the /var/www with the /path/to/your/new/document/root in the lines 4 and 9 as shown in the figure below.


#3. Restart the apache webserver.

$ sudo /etc/init.d/apache2  restart



Now test it !!!
- - - - - - - - - - - - - - - - - -#

#1. Create a html/php file inside the Document Root directory (mine is @ /home/jo/www).

#2. Take the terminal and navigate to the Document Root directory (using cd command). Use chmod command given below to allow read+write+execute permission to all.

$ chmod 777 *

#3. Take your web browser and type in http://localhost and hit the enter key! The apache server will load the contents of your Document Root directory as in the figure.


Hope you have done it right!!!


Read rest of entry

Use the Debian Squeeze DVD/pendrive as a package repository

The Debian Squeeze DVD contains many application level packages which are not installed during the base operating system installation. Only core packages are installed during the basic Debian Operating system installation. For example the DVD is loaded with the graphical display managers such as Gnome, KDE and XFCE, but during the installation you can select only one among them.  There are a lot more stuff in the dvd, such as vlc media player, phpmyadmin, mysql etc. Here I am sharing how i used these Debian squeeze DVD as a repository to install those packages.

Adding the dvd to the repository
                 --------------------------------------------------

Take the terminal and type the following

$ sudo apt-cdrom add



This will add your DVD to the repositories list. 


For those who are using the pendrive as the installation media, pendrive should be mounted on the /media/cdrom directory. This can be done in two steps.


#1. Plug in the USB pendrive, then the new block device will be added under the /dev directory. We have to find this block device location for mounting and using the device. Use the following command to detect the block device's filename (selected in the image).
$ sudo fdisk -l


#2. Mount the block device into /media/cdrom.  

$ sudo mount  /dev/sdb1  /media/cdrom/


#3. Add the cdrom to the software repository list, as described earlier in the  case of the DVD.

$ sudo apt-cdrom add


Installing Packages
-------------------------------------
Now install the packages using the apt package manager. Check the sample below :- 
$ sudo apt-get install vlc

Thatz up...This trick will work for Ubuntu also...
Read rest of entry
 

Terminal Diary | techblog Copyright © 2009 Gadget Blog is Designed by jintu jacob Powered by Blogger