PHP 5: Mass Virtual Hosting points $_SERVER[‘DOCUMENT_ROOT’] to wrong folder

When I set up mass virtual hosting for my servers, it seems PHP won’t get the right $_SERVER[‘DOCUMENT_ROOT’]

Here’s the solution I found:

1.Edit your php.ini (the file location depends on  how you have PHP setup)

2. Edit this section

; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
auto_prepend_file = /home/httpd/prepend.php

3. Create the prepend file:

<?php
$_SERVER['DOCUMENT_ROOT'] = str_ireplace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME']);

4. Restart your httpd server. I have done this for both Apache 2 and NGINX. (It probably doesn’t matter as it’s a PHP issue)

Squeeze: Installing VirtualBox 3.2_3.2.12-68302~Debian~squeeze_amd64

First we install some required packages

sudo aptitude install libqt4-network libqt4-opengl libqtcore4 libqtgui4

Then we install VirtualBox download from VirtualBox.org :

sudo dpkg -i virtualbox-3.2_3.2.12-68302~Debian~squeeze_amd64.deb

Include your user in the group "vboxusers"

Linux:: settings shortcuts for your ssh connections to hosts

If you wish you could use friendly names to access your servers, here’s how to do it:

Edit your ~/.ssh/config and add the following:

Host myserver
    HostName 123.123.123.123
    Port 12345
    User bob
Host other_server
    HostName test.something.org
    User alice
    CheckHostIP no
    Cipher blowfish

Please, remember to customize "HostName" and "User" values to your needs. 🙂

  • IGlr