Results 1 to 5 of 5

Thread: Change the location of localhost

  1. #1
    Join Date
    Apr 2008
    Location
    Vienna, Austria
    Beans
    18
    Distro
    Ubuntu 8.04 Hardy Heron

    Change the location of localhost

    Hi,
    About, apache and web servers... I'd like to know, how can I change the current default localhost folder that can be found under /var/www/ to some other folder, of my own choice...

  2. #2
    Join Date
    Aug 2006
    Location
    tuesday
    Beans
    6,502
    Distro
    Kubuntu Development Release

    Re: Change the location of localhost

    I could be a little off here but this should be close.

    sudo gedit /etc/apache2/sites-enabled/000-default
    DocumentRoot /var/www/
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>
    Change the bolded sections, save, and restart apache.

    sudo /etc/init.d/apache2 restart

  3. #3
    Join Date
    Nov 2007
    Beans
    395
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Change the location of localhost

    EDIT: hikaricore points out that the file is in 'sites-enabled'. On my web server the 'sites-enabled/000-default' is a link to 'sites-available/default'. So edit whichever file is real and not a link.


    OriginalPost:
    In the file /etc/apache2/sites-available/default find the line:

    DocumentRoot /var/www

    Comment it out (don't delete it)

    # DocumentRoot /var/www

    And add your desired location

    DocumentRoot /Path/to/My-www-folder


    Beware of the need to use correct ownership and permissions to allow Apache to serve pages. I know mine are usually messed up or not secure enough, but I have a private intranet. You can view the default folder permissions by typing this in a terminal window
    Code:
    ls -l /var/www
    Last edited by Coreigh; December 15th, 2008 at 11:31 PM.
    -- Coreigh

    "Only those who attempt the absurd will achieve the impossible"
    ... Einstein or Escher, you pick ...

  4. #4
    Join Date
    Nov 2005
    Location
    NEK Vermont
    Beans
    Hidden!
    Distro
    Ubuntu UNR

    Re: Change the location of localhost

    you can easily use the virtual hosts file /etc/apache2/sites-available.
    Copy the file called "default" to one called "my-site" (for example.)
    Then edit that file to suit your desires. So you might point to /home/user/www instead of /var/www
    When you are ready to use the new site:
    Code:
    sudo a2dissite default && sudo a2ensite my-site
    sudo /etc/init.d/apache2 restart
    Edit: lol I'm too slow. Any of the above will work too.
    Last edited by spiderbatdad; December 15th, 2008 at 11:30 PM.

  5. #5
    Join Date
    Apr 2008
    Location
    Vienna, Austria
    Beans
    18
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Change the location of localhost

    Thank you guys, hikaricore's solution worked fine for me...

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •