Getting PHP granularity in user resource reports

If you run a lot of PHP scripts, then the reports in /home/user/logs/resources/ may show only "php.cgi" instead of the proper script. This is because of the way we run php scripts on the web server.

'''Note: the following steps are no longer valid since mod_php is now disabled.

To fix this, try the following workaround:

All steps below are required for this to work

1) Change the permissions of all your php scripts to be 755. For example:

chmod 755 script.php

You can do all your files at once with the following find command:

find /home/your_username/ \( -name "*.php[34]" -or -name "*.php" \) -exec chmod a+x {} \;

Note that this is performed by our system every morning on your machine, so you probably don't have to do this step for existing scripts.

2) For each of your domains, add the following line to your .htaccess:

AddHandler cgi-script .php .php3 .php4

If you don't already have an .htaccess, just create a file named:

/home/your_username/mydomain.com/.htaccess

and put the line above in that file. Make sure the permissions are set to 644 for your .htaccess file.

3) Change your domains to not run PHP as CGI : From the webpanel, click on: Domains > Web Then next to each of your domains, click on "Edit". Uncheck the box titled "Run PHP as CGI" and click "Save Web Service" at the bottom. NOTE: Some third party software will break during this transition. Because of that, we've made sure that your changes will go live within 2 - 10 minutes after you click "Save Web Service". If things break, you can quickly change it back!

4) If you have any custom .htaccess files, you may have to edit them. You'll have to do this for every domain that you have setup with a custom .htaccess file. You might have something like this: AddHandler application/x-httpd-php If you had the line above, you would need to remove it. In fact, you might have something else in your .htaccess file that causes your PHP scripts to be run as a cgi. If that's the case, you'll need to remove it as well.

If the approach above is not feasible for you, the best work-around for this is to examine your stats page and look for the php scripts with the most requests.

Last updated: Dec 27, 2007.