Finglish
Finglish

Reputation: 9956

How do fix apache error "not within configured docroot" under Ubuntu

Greetings experts and gurus, I am looking for some help with an apache php configuration problem.

I have been running several websites from an apache2 setup on an ubuntu server for some time now without problems using the line NameVirtualHost * in my etc/apache2/conf.d/virtual.conf file. I recently updated the server version to the latest lts version and I am now unable to run php files.

I am running all my sites for the location "/home/www/[site-name]/htdocs" and I have setup and enabled all my sites in /etc/apache2/sites-available. I have also disabled the default site.

for each sites file I have specified the following:

    # Indexes + Directory Root.
    # DirectoryIndex index.html index.htm index.php
    DocumentRoot /home/www/[site-name]/htdocs/

    # CGI Directory
    ScriptAlias /cgi-bin/ /home/www/[site-name]/cgi-bin/
    <Location /cgi-bin>
            Options +ExecCGI
    </Location>

    # Logfiles
    ErrorLog  /home/www/[site-name]/logs/error.log
    CustomLog /home/www/[site-name]/logs/access.log combined

I restart apache and enter the url for a php test page on my server and I am met with an "Internal Server Error". When I check the error log I get:

Script "/home/www/[site-name]/htdocs/test.php" resolving to "/home/www/[site-name]/htdocs/test.php" not within configured docroot.

Upvotes: 4

Views: 8764

Answers (3)

Finglish
Finglish

Reputation: 9956

Thanks for all the help, I got there in the end. It seems that upgrading to Ubuntu 10.04 turned on suPHP. It has ended up being a good thing as the reason why I was getting errors was down to file management in my htdocs getting sloppy.

To fix my issues I had to do several things:

First I turned on suphp error messages in /etc/apache2/sites-available/[site-name]. This gave me the true error, which told me that some of my pages had the wrong permissions. I then set all my folder permissions in www to 755 and the files to 644. I also had to lower the min_uid and min_gid fileds in suphp.conf to 33.

Upvotes: 0

Mike
Mike

Reputation: 24383

For some reason when looking into the error, suphp came up a lot. According to this link:

Don't be fooled into thiking this has anything to do with the Apche virtual host document root, this is actually another setting in the suphp config file. Including the paths which contained the RoundCube scripts fixed this one. For example: docroot=/var/www:/usr/share/roundcube:/var/lib/roundcube:${HOME}/public_html

You need to edit your /etc/suphp/suphp.conf file and change the docroot to whatever is appropriate.

Upvotes: 14

Andrii Radyk
Andrii Radyk

Reputation: 394

It looks you missed the virtual hosts configuration for every site name:

<VirtualHost IP:80>
    ServerName      yourdomainname
    ServerAlias  www.yourdomainname
    DocumentRoot /home/www/[site-name]/htdocs/
    ScriptAlias /cgi-bin/ /home/www/[site-name]/cgi-bin/
    <Location /cgi-bin>
        Options +ExecCGI
    </Location>
    ErrorLog        /home/www/[site-name]/logs/yourdomainname.ua-error.log
    CustomLog       /home/www/[site-name]/logs/yourdomainname-access.log combined
</VirtualHost>

<Directory "/home/www/[site-name]/htdocs/">
    Options         FollowSymLinks
    AllowOverride   None
    Order           allow,deny

    <Limit GET POST OPTIONS>
        Order allow,deny
        Allow from all
    </Limit>

    <LimitExcept GET POST OPTIONS>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>

Upvotes: 1

Related Questions