How to change DOCUMENT_ROOT for PHP

Posted: Fri, Apr 22 01:22 AM (PDT)

If you are running into issues with the $_SERVER["DOCUMENT_ROOT"] variable showing "/usr/local/data/www/"; when using PHP5 and need to have it point to your correct document root for your application, here is a simple tutorial for changing it.

Create a file document_root.php into your root application directory with follow the code:

<?
$_SERVER["DOCUMENT_ROOT"]  = "/vhosts/domain.com/"
?>

Add to your root application directory .htaccess with follow the code

php_value	auto_prepend_file	"/vhosts/domain.com/document_root.php"

This tells Apache to parse the document_root.php file before doing anything else.

Tags:

Suppress Tomcat error pages using Nginx

Posted: Tue, Mar 8 06:26 PM (PST)

You need to add proxy_intercept_errors on to nginx configuration.

listen          10.10.10.10:80;
server_name     www.example.com;
location / {
		proxy_pass      http://127.0.0.1:8180;
		proxy_set_header        Host            $host;
		proxy_set_header        Client-IP       $remote_addr;
		proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_intercept_errors on;
}
location /images/ {
		root /usr/local/apache-tomcat-6.0/webapps/ROOT/;
		expires max;
}
location /css/ {
		root /usr/local/apache-tomcat-6.0/webapps/ROOT/;
		expires max;
}
location /js/ {
		root /usr/local/apache-tomcat-6.0/webapps/ROOT/;
		expires max;
}
error_page 500 502 503 504 404 = /404.html;
location /404.html {
		rewrite ^ http://www.example.com/ permanent;
}
Tags: