Monday, July 5, 2010

Changing your default apache publishing directory

Hi, :)

Always change the default setting. That's a word my friend always told me. Ok now i will show you how to edit the default apache 2 publishing directory. By the way, this howto is on ubuntu 10.04 server edition. It can be applied to ubuntu 9.10, 9.04, 8.10 and 8.04. NOt so sure for the older version of it.

Ubuntu have its own way to manage the apache files. They splitted httpd files into files called mods_available, sites_available and so on. That means, there's no single file named httpd.conf anymore.All that files stored nicely at /etc/apache2/

From our default installation for LAMP Server, our website or apps will be stored at /var/www/. Almost every version of ubuntu is the same. NOw for extra security, we need to change this directory to our own directory. Here is how i done it :-

# ssh into your server, for example :- ssh 10.23.140.222 -l dzul

# after successfully login, switch to root by issuing the following command ,

sudo su
and enter your password once again

you're now root!
then cd to /etc/apache2 dir
then go directory name sites_available

now, make sure you have two files on it, which is default and default-ssl

we need to edit the default file, so at the terminal :-

# nano default
[nano is the editor, it is up to you to use other editor like vi or vim.]

make some changes there.

let say you wanted to host your file at /var/web/dzul then you the change the line /var/www to /var/web/dzul

ctrl+x to save

now make your directory under /var

# mkdir web
# cd web
# mkdir dzul
# cd dzul
# pwd
# /var/web/dzul
now your /var/web/dzul is created.

it's time to restart the apache service.

# /etc/init.d/apache2 restart

If there's no errors, you're successfully make changes of ubuntu apache default publishing directory. Get your files and dump it into /var/web/dzul

But before that you need to chown and chmod user dzul to use that directory. Remember, ONLY root can access everything in your system. To accomplish that, issue the following command :-

# chown root:dzul /var/web/dzul/
# chmod g+w /var/web/dzul/

now you're ready to rock!

0 comments:

Post a Comment