Change where server root points to on Apache, without changing DocumentRoot

Discussion in 'Apache' started by djia, Dec 23, 2010.

  1. #1
    Hey guys,

    I want to change where the server root point to for my site. So say my document root right now is:

    /var/www

    which is where the site www.example.com would point to. But I want it to point to:

    /var/www/new

    instead, without changing DocumentRoot. I know I can make a VirtualHost and change the DocumentRoot value to /var/www/new to achieve this, but in PHP code, I rely on the fact that $_SERVER['DOCUMENT_ROOT'] points to /var/www in some of my code, so I won't be able to change DocuemtnRoot value from /var/www. So is there a way to do this?

    Any help would be greatly appreciated :)

    Thanks,
    -David
     
    djia, Dec 23, 2010 IP
  2. naskin

    naskin Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I recomment to you use this code for every domain on your server:
    <Directory /usr/local/www/domain.com>
        Options FollowSymLinks Includes
        Order Allow,Deny
        Allow from all
        AllowOverride All
    </Directory>
    
    <Directory /usr/local/www/domain.com/tmp>
        Options FollowSymLinks Includes
        Order Allow,Deny
        Deny from all
    </Directory>
    
    <VirtualHost *:80>
        ServerName domain.com
        Redirect permanent / http://www.domain.com/
    </VirtualHost>
    
    <VirtualHost *:80>
        ServerName www.domain.com
        DocumentRoot /usr/local/www/domain.com
        ErrorLog /var/log/httpd/domain.com-error_log
        CustomLog /var/log/httpd/domain.com-access_log combined
        php_admin_value open_basedir /usr/local/www/domain.com
        php_admin_value upload_tmp_dir /usr/local/www/domain.com/tmp
        php_admin_value session.save_path /usr/local/www/domain.com/tmp
    </VirtualHost>
    
    Code (markup):
    It safely and correctly in terms of seo.
     
    naskin, Dec 24, 2010 IP