Buzzzz
Buzzzz

Reputation: 81

Apache2 changing localhost directory

I had been install apache2 and php5 and i know that is index.php file in var/www/html/index.php but i want to change it to /home/pc/www/public/index.php and i setup in etc/apache2/sites-available/000-default.conf document root to "DocumentRoot /home/pc/www/public/" here is my conf file:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /home/pc/www/public/


    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

And when i try to get access to localhost in firefox i get this error:

Forbidden

You don't have permission to access / on this server.
Apache/2.4.7 (Ubuntu) Server at localhost Port 80

But when i set DocumentRoot to default directory it works. Please help.

Upvotes: 0

Views: 8664

Answers (2)

Cœur
Cœur

Reputation: 38667

Solution from OP.

I was need change directory in apache2.conf too.

Here is code what I was need to change in apache2.conf file:

 <Directory /home/pc/www/public/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

Upvotes: 0

Josh Ghiloni
Josh Ghiloni

Reputation: 1300

Does the Apache user (usually apache or nobody) have permissions to that directory? Make sure you have at least o+r permissions on the directory.

Upvotes: 0

Related Questions