4

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.

Finglish
  • 9,692
  • 14
  • 70
  • 114
  • Are u running suPHP or PHP? This [page](http://www.crazysquirrel.com/computing/debian/servers/ubuntu-mail-server.jspx) explains how to fix those suPHP errors. – Alvin K. Nov 21 '11 at 07:44
  • just standard php5, hence why I did not think this would be my answer – Finglish Nov 21 '11 at 09:09
  • Two suggestions, after reading entries below. #1) Uninstall suPHP #2) install PHP following [this example for Ubuntu 11.04](http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-ubuntu-11.04-lamp). (assuming u are on 11.04) – Alvin K. Nov 22 '11 at 05:30

3 Answers3

14

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.

Mike
  • 23,542
  • 14
  • 76
  • 87
  • I also saw a lot of posts for suphp related to this error, I have no idea what this would have to do with my issue, but for the sake of trying everthing I tried changing the docroot in the suphp.conf file, restarted apache, but the problem still persists – Finglish Nov 21 '11 at 08:25
  • I keep my projects under `/data/web/projects` e.g. `/data/web/projects/sample-project`, so I added `/data/web/projects` to **docroot** variable in **suphp.conf** and all works as desired. Thank you @Mike – Tomasz Kuter Sep 29 '13 at 22:02
1

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>
Andrii Radyk
  • 394
  • 1
  • 4
  • currently my virtualhost configuration is defined as – Finglish Nov 21 '11 at 08:12
  • currently the only difference between my configuration and your sample is that virtualhost is defined as in each file. I know this is a catch all and not specific to port 80, but it has worked to date. I tried changing it as you suggest just in case it has an effect and restarted apache but I still have the same issue. – Finglish Nov 21 '11 at 08:34
  • sure, to enable the sites I sites I wanted I used 'sudo a2ensite [site-name]'. To disable the default site I use 'sudo a2dissite default' – Finglish Nov 21 '11 at 13:22
  • It look you really have the issue with suphp. Could you try to find anything with suphp like **suPHP_Engine on** – Andrii Radyk Nov 21 '11 at 13:27
  • As far as I know I am not using suPHP, at least I have never knowingly installed it, but please correct me if I am wrong? – Finglish Nov 21 '11 at 13:37
  • after looking at my package list it would seem the suPHP does seem to be installed (must have been part of the upgrade because I did not install it myself). How do I know if it is active? Can I just disable it? Should I? – Finglish Nov 21 '11 at 14:00
0

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.

Finglish
  • 9,692
  • 14
  • 70
  • 114