Skip to content
Advertisement

Why am i getting forbidden error in browser

I am a new user to apache and trying to learn and have setup a domain just for learning and testing. However, before I even start i am getting Forbidden You do not have permission to access this document.. I know after research that this error has to do with either http.conf or .htaccess file.

I do not have .htaccess file in directory and have posted my http.conf file. I would be grateful if someone could help me to overcome this problem. Many thanks

FYI I have replaced sensitive data with leading zeros.

PHP: v5.4 fastcgi APACHE: Apache/2.2.15 (Unix)

Here is result of: ls -la

total 468
dr-xr-x---  5 root root   4096 Aug 10  2014 .
dr-xr-xr-x 26 root root   4096 Apr  3 12:19 ..
-rw-------  1 root root   1325 Jul 11  2011 anaconda-ks.cfg
drwxr-xr-x  2 root root   4096 Jan 23 03:49 .autoinstaller
-rw-------  1 root root   9454 Apr  3 12:18 .bash_history
-rw-r--r--  1 root root     18 May 20  2009 .bash_logout
-rw-r--r--  1 root root    176 May 20  2009 .bash_profile
-rw-r--r--  1 root root    176 Sep 23  2004 .bashrc
-rw-r--r--  1 root root     29 Aug  5  2014 created
-rw-r--r--  1 root root    100 Sep 23  2004 .cshrc
-rw-r--r--  1 root root   8730 Jul 11  2011 install.log
-rw-r--r--  1 root root   3094 Jul 11  2011 install.log.syslog
-rw-r--r--  1 root root 130324 Jan  8  2013 kmod-e1000e-2.1.4-1.el6.elrepo.x86_64.rpm
-rw-r--r--  1 root root 135820 Sep 23  2013 kmod-e1000e-2.5.4-1.el6.elrepo.x86_64.rpm
-rw-r--r--  1 root root 116252 Sep 23  2013 kmod-igb-5.0.5-1.el6.elrepo.x86_64.rpm
drwxr-xr-x 59 root root   4096 Apr  3 03:25 parallels
drwx------  2 root root   4096 Aug 10  2014 .spamassassin
-rw-r--r--  1 root root    129 Dec  3  2004 .tcshrc


#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
#IF YOU REQUIRE TO APPLY CUSTOM MODIFICATIONS, PERFORM THEM IN THE FOLLOWING FILES:
#/var/www/vhosts/system/domain.co.uk/conf/vhost.conf

<VirtualHost 00.00.00.00.:0000 >
    ServerName "domain.co.uk:80"
    ServerAlias "www.domain.co.uk"
    ServerAlias "ipv4.domain.co.uk"
    ServerAdmin "pa@domain.com"
    UseCanonicalName Off

    DocumentRoot "/var/www/vhosts/domain.co.uk/httpdocs"
    CustomLog /var/www/vhosts/system/domain.co.uk/logs/access_log plesklog
    ErrorLog "/var/www/vhosts/system/domain.co.uk/logs/error_log"

    <IfModule mod_suexec.c>
        SuexecUserGroup "peterc" "psacln"
    </IfModule>

    <IfModule mod_userdir.c>
        UserDir "/var/www/vhosts/domain.co.uk/web_users"
    </IfModule>

    <IfModule mod_sysenv.c>
        SetSysEnv PP_VHOST_ID "7d9a2c29-8013-470b-a6eb-36549a513f6b"
    </IfModule>

    ScriptAlias "/cgi-bin/" "/var/www/vhosts/domain.co.uk/httpdocs/cgi-bin/"

    Alias "/plesk-stat" "/var/www/vhosts/system/domain.co.uk/statistics"
    <Location  /plesk-stat/>
        Options +Indexes
    </Location>
    <Location  /plesk-stat/logs/>
        Require valid-user
    </Location>
    Alias /webstat /var/www/vhosts/system/domain.co.uk/statistics/webstat
    Alias /webstat-ssl /var/www/vhosts/system/domain.co.uk/statistics/webstat-ssl
    Alias /ftpstat /var/www/vhosts/system/domain.co.uk/statistics/ftpstat
    Alias /anon_ftpstat /var/www/vhosts/system/domain.co.uk/statistics/anon_ftpstat
    Alias /awstats-icon /var/www/html/awstats/icon

    <IfModule mod_ssl.c>
        SSLEngine off
    </IfModule>

    SetEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/domain.co.uk/etc/php.ini
    SetEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi

    <IfModule mod_fcgid.c>
        FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/domain.co.uk/etc/php.ini
        FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi
        FcgidMaxRequestLen 134217728
    </IfModule>

    <Directory /var/www/vhosts/domain.co.uk/httpdocs>

        <IfModule mod_perl.c>
            <Files ~ (.pl$)>
                SetHandler perl-script
                PerlHandler ModPerl::Registry
                Options +ExecCGI
                allow from all
                PerlSendHeader On
            </Files>
        </IfModule>
        <IfModule mod_python.c>
            <Files ~ (.py$)>
                SetHandler python-program
                PythonHandler mod_python.cgihandler
            </Files>
        </IfModule>
        <IfModule mod_fcgid.c>
            <Files ~ (.fcgi$)>
                SetHandler fcgid-script
                Options +ExecCGI
            </Files>
        </IfModule>
        <IfModule mod_fcgid.c>
            <Files ~ (.php$)>
                SetHandler fcgid-script
                FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
                Options +ExecCGI
            </Files>
        </IfModule>

        Options -Includes +ExecCGI

    </Directory>

    <Directory "/var/www/vhosts/system/domain.co.uk/statistics">
        AuthType Basic
        AuthName "Domain statistics"
        AuthUserFile "/var/www/vhosts/system/domain.co.uk/pd/d..httpdocs@plesk-stat"
        require valid-user
    </Directory>

    Alias /error_docs /var/www/vhosts/domain.co.uk/error_docs
    ErrorDocument 400 /error_docs/bad_request.html
    ErrorDocument 401 /error_docs/unauthorized.html
    ErrorDocument 403 /error_docs/forbidden.html
    ErrorDocument 404 /error_docs/not_found.html
    ErrorDocument 500 /error_docs/internal_server_error.html
    ErrorDocument 405 /error_docs/method_not_allowed.html
    ErrorDocument 406 /error_docs/not_acceptable.html
    ErrorDocument 407 /error_docs/proxy_authentication_required.html
    ErrorDocument 412 /error_docs/precondition_failed.html
    ErrorDocument 414 /error_docs/request_uri_too_long.html
    ErrorDocument 415 /error_docs/unsupported_media_type.html
    ErrorDocument 501 /error_docs/not_implemented.html
    ErrorDocument 502 /error_docs/bad_gateway.html
    ErrorDocument 503 /error_docs/maintenance.html

    <IfModule mod_security2.c>
    </IfModule>

</VirtualHost>

Advertisement

Answer

in response to comment:

$ sudo chown -R apache:root /path/to/website
$ sudo find /path/to/website -type f -exec chmod 644 {} ;
$ sudo find /path/to/website -type d -exec chmod 755 {} ;

this will chown (change owner) recursivly in your website root to apache:root (you can change to your server user). It then finds all the files (-type f) and executes a chmod 644 and find the directories (-type d) and executes a chmod 755 – hope this helps 🙂

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement