Changing default Apache webroot in Ubuntu

By default the webroot for apache/php is in /var/www

To change this, say, to /home/user/workspace/public_html

1 Go to file: /etc/apache2/sites-available/default
2. Change the /var/www to /home/user/workspace/public_html – as simple as this!!

OR,

If you are changing root just to abscond some difficulty from your IDE or just for temporary purpose, you can use the symlik: just open your terminal and -
cd /home/user/workspace/public_html
ln -s /var/www/project project

, , ,

  1. #1 by Vinny Benson on January 12, 2011 - 10:19 am

    I am new to Ubuntu(Just installed it 3 hours ago), I have a problem, it wont let me edit the “default” file located in “\etc\apache2\sites-available” as it is set to read only, but when i go to properties the permissions tab page is grayed out, how can i edit the file

    • #2 by gullele on January 14, 2011 - 2:30 am

      Hello Vinny, Sorry, was busy these days and was not able to respond fast.
      The problem is probably with the owner of the file. Some file in the Ubuntu would not be available to be edited unless you logged as root.
      In your case you have two options to do:
      1 is to log as root and edit it
      2. to use sudo access
      I will explain the second one as it is too easy

      Step:
      1. Go to Applications (if u have default Ubuntu theme, it would be on the top left menu) -> Accessories -> Terminal
      2. On the terminal enter the following command:
      Sudo gedit /etc/apache2/sites-available
      3. You would be prompted for a password and enter the password
      4. you would get the sites-available file in text editor.

      *You can also change the owner of the file so that you can simply open it using the command chown, but it is not recommended to do that.
      Let me know if this helped,
      thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.