{"id":442,"date":"2010-12-27T12:17:31","date_gmt":"2010-12-27T20:17:31","guid":{"rendered":"http:\/\/blog.portnumber53.com\/?p=442"},"modified":"2010-12-27T12:17:31","modified_gmt":"2010-12-27T20:17:31","slug":"php-5-mass-virtual-hosting-points-_serverdocument_root-to-wrong-folder","status":"publish","type":"post","link":"https:\/\/blog.portnumber53.com\/index.php\/2010\/12\/27\/php-5-mass-virtual-hosting-points-_serverdocument_root-to-wrong-folder\/","title":{"rendered":"PHP 5: Mass Virtual Hosting points $_SERVER[&#8216;DOCUMENT_ROOT&#8217;] to wrong folder"},"content":{"rendered":"<p>When I set up mass virtual hosting for my servers, it seems PHP won&#8217;t get the right $_SERVER[&#8216;DOCUMENT_ROOT&#8217;]<\/p>\n<p>Here&#8217;s the solution I found:<\/p>\n<p>1.Edit your php.ini (the file location depends on\u00a0 how you have PHP setup)<\/p>\n<p>2. Edit this section<\/p>\n<pre class=\"brush:plain\">; Automatically add files before PHP document.\n; http:\/\/php.net\/auto-prepend-file\nauto_prepend_file = \/home\/httpd\/prepend.php<\/pre>\n<p>3. Create the prepend file:<\/p>\n<pre class=\"brush:plain\">&lt;?php\n$_SERVER['DOCUMENT_ROOT'] = str_ireplace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME']);<\/pre>\n<p>4. Restart your httpd server. I have done this for both Apache 2 and NGINX. (It probably doesn&#8217;t matter as it&#8217;s a PHP issue)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I set up mass virtual hosting for my servers, it seems PHP won&#8217;t get the right $_SERVER[&#8216;DOCUMENT_ROOT&#8217;] Here&#8217;s the solution I found: 1.Edit your php.ini (the file location depends on\u00a0 how you have PHP setup) 2. Edit this section ; Automatically add files before PHP document. ; http:\/\/php.net\/auto-prepend-file auto_prepend_file&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/blog.portnumber53.com\/index.php\/2010\/12\/27\/php-5-mass-virtual-hosting-points-_serverdocument_root-to-wrong-folder\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[117,232,272,273],"class_list":["post-442","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-document_root","tag-mass-virtual-hosting","tag-php","tag-php-ini"],"_links":{"self":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/comments?post=442"}],"version-history":[{"count":0,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/442\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/media?parent=442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/categories?post=442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/tags?post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}