← Back to team overview

ubuntuforums-unanswered team mailing list archive

Re: [Question #77571]: You don't have permission to access / on this server

 

Question #77571 on apache2 in ubuntu changed:
https://answers.launchpad.net/ubuntu/+source/apache2/+question/77571

    Status: Open => Answered

Ufuk proposed the following answer:
I followed these steps to change the default site directory for apache
and I've had no problems. I think you should follow this according to
your directory names and should not forget the last two command to
activate your new site.

Taken from: https://help.ubuntu.com/community/ApacheMySQLPHP

Virtual Hosts

Apache2 has the concept of sites, which are separate configuration files
that Apache2 will read. These are available in /etc/apache2/sites-
available. By default, there is one site available called default this
is what you will see when you browse to http://localhost or
http://127.0.0.1. You can have many different site configurations
available, and activate only those that you need.

As an example, we want the default site to be /home/user/public_html/.
To do this, we must create a new site and then enable it in Apache2.

To create a new site:

Copy the default website as a starting point. sudo cp /etc/apache2
/sites-available/default /etc/apache2/sites-available/mysite

Edit the new configuration file in a text editor "sudo nano" on the
command line or "gksudo gedit", for example: gksudo gedit /etc/apache2
/sites-available/mysite

Change the DocumentRoot to point to the new location. For example,
/home/user/public_html/

Change the Directory directive, replace <Directory /var/www/> to
<Directory /home/user/public_html/>

You can also set separate logs for each site. To do this, change the ErrorLog and CustomLog directives. This is optional, but handy if you have many sites 
Save the file 

Now, we must deactivate the old site, and activate our new one. Ubuntu
provides two small utilities that take care of this: a2ensite
(apache2enable site) and a2dissite (apache2disable site).

sudo a2dissite default && sudo a2ensite mysite

Finally, we restart Apache2:

sudo /etc/init.d/apache2 restart

-- 
You received this question notification because you are a member of UF
Unanswered Posts Team, which is an answer contact for Ubuntu.