Find the answer to your Linux question:
Results 1 to 3 of 3
Hi All Plz help me i am new to php scripting I want to get document root from httpd conf file and also from conf.d have some custom setting for ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    7

    Unhappy I want to get DocumentRoot from apache conf

    Hi All

    Plz help me i am new to php scripting

    I want to get document root from httpd conf file and also from conf.d have some custom setting for the ower domain.i m using php and built in php function dont work becz my script run out side the documentroot,Actually i m check for apache world writeable directories.i have many server and i need automatically to get documentroot from conf file plz advise ASAP,any sample code will help.

    one more thing how to use sed for the following.

    i have "/var/www/html"

    i want to replace double quotas with single quote the above directive is in a file called test.txt .Plz ans ASAP

    THx ALI

  2. #2
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    for DocumentRoot:
    awk '/^DocumentRoot/ {print $2}' default-server.conf

    for quotation mark replacement:
    cat test.txt | tr '"' "'"

    or with sed
    cat test.txt | sed "s/\"/'/g"

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    7

    Exclamation

    Thats what i did so if anyone need in future is this
    Thx to all i have found solution on another forum.
    $var=shell_exec('grep ^DocumentRoot /etc/httpd/conf/httpd.conf|cut -d" " -f2| uniq');
    $var=str_replace('"', "", $var);
    $var = trim($var);
    $root_dir_path = $var;

    Just one last problem working is now fine output looks great

    a warning

    PHP Warning: readdir(): supplied argument is not a valid Directory resource in /home/syed/write.php on line 141
    /var/www/html/


    Array
    (
    [0] => HTTP__/var/www/html/phpBB3/cache/.htaccess
    [1] => HTTP__/var/www/html/phpBB3/cache/ctpl_admin_install_footer.html.php
    [2] => HTTP__/var/www/html/phpBB3/cache/ctpl_admin_install_header.html.php
    }

    Any idea why still i have warning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...