Document Root Not Website Root
I want to use PHP in my website; but run into a snag, the recommended
method of calling an include is:
<?php include($_SERVER["DOCUMENT_ROOT"]."/inc/css-gateway.inc"); ?>
when I try
<?php ECHO $_SERVER["DOCUMENT_ROOT"]; ?> the document root is shown as
/usr/local/apache/htdocs/
However the website root is at:
/mnt/home/www/canadian-dream.com/www
How do I redirect $_SERVER["DOCUMENT_ROOT"] to the my website root? Is
there a global variable that can be used? I do not wish to rewrite a lot
of pages if I were to change web host in the future.
from the error logs
[Sat Oct 25 06:32:51 2003] [error] PHP Warning:
main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open stream:
No such file or directory in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
[Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
'/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
(include_path='.:/usr/local/lib/php') in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Document Root
I'm just having a little problem, and i'm wondering whats wrong with it. i coded an document shown below: <? include('$DOCUMENT_ROOT/header.php'); ?> and it leads me to this problem, i don't know why? Warning: Failed opening '$DOCUMENT_ROOT/header.php' for inclusion (include_path='') in d:wwwdigitalricesomethingindex.php on line 2
PHP Works Only In Document Root
All php files in document root work fine. While php files in sub-directories of document root shows the php source like a text file. I have looked for help and also FAQ. Did I miss anything during the installation. I have installed both apache and php on Linux many times before actually figuring out that all my php files generate html only in document root.
Document Root/include Path Problem
My site is/will be housed on a 3rd party host. I do not have control of the server variables. Neither $DOCUMENT_ROOT or include_path are pointed anyplace I can use Does anyone know what I can do do get the server path to my main directory(short of hard coding it).
Server And Document Root Settings In Apache
I'm not sure if I'm even asking the right question, but my website (not hosted by me) used codes like include $_SERVER["DOCUMENT_ROOT"] . "/include/header.php";. Per a forum member's suggestion, I ran an echo on that command, and it gives a folder tree three folders deep... So, online, it points to the correct page, but I'm trying to set up Apache (I used WAMP) to get a beta test site on my own computer. So, the above command doesn't work. I ran searches for "document_root" and "php5/pear" (a directory in the error messages I get) to see if I could find a path setting in either Apache or PHP config files with no success. Does anyone know how to set up either my Apache or PHP config so I can define what $_SERVER and DOCUMENT_ROOT are pointing to when they're on my localhost without making them not work when I upload them to my web host?
IIS ISAPI PHP Problem With Pages In The Website Root (defaulting To C:WINNTSYSTEM32)
I've come across a rather strange, and very anoying problem. On /some/ PHP sites that we're developing on 2 different servers, files that are in the root of the website are unable to load files using relative paths (they need to be given the full "C:Inetpubwwwrootwebsitewwwfolderfile.txt" rather then "folder/file.txt"). However includes with relative paths still seem to work. When getcwd() is called it returns "C:WINNTsystem32" and trying to read the current dir prints out the contents of system32. If pages are even one folder up from the root (eg in folder/page.php) then getcwd reports the correct folder and relative paths work again. Also in CGI mode, and on a few other ISAPI php websites defined in IIS, the paths from the root works fine. The PHP version we're using is 4.3.1 and 4.3.2. Is there some reason why some sites have this root problem, while others don't? I've looked through the different site's config, and there's no difference I can find
Root Access
If I want to add a column in a existing table in a php script, do I have to have root access?
Logging In As Root. Possible With Php Or Not??
I want to log as root from php. I am using Exec() function. I have tried the following code: =========================== Passthru("whoami"); Exec("su root"); Exec("password"); Passthru("whoami"); =========================== Both the Passthru("whoami") returns apache. Where am I going wrong? Or is it not possible with php??
Crontab Outside Web Root
I am trying to get a PHP script running on the crontab where the PHP document is located outside of the web root, this presents a problem because PHP is installed as an Apache module and I dont have access to re-install on this server. I have searched endlessly for ideas about how to get this running but all I am running into is the usual suspects: CGI Install Call Like a Command Line: Fetch wget lynx The last three all use http:// protocol as far as I have figured out. So does anyone know of any other software I can use to call from the crontab to run this script.
The Root Folder
I've a web site in the address http://mySite.com in the root, I've a file index.html I've some subfiolders insid root/sub1/sub2 I like to add an html file (or php) index.html that call the index.html of the root (in order to protect) Now I've created 2 different index.html because I use relative path to design the root (../index.html and ../../index.html) I like to have the same file in all folders,but I don't know how to call the root folder.
Site Root?
I'm a freelance web designer and I've begun to use PHP extensively for my clients' websites. A problem I run into is the consistent use of "/" for the site root. My server thinks that that refers to public_html/, meaning I can't test a site with "/" used to recognize the site root if I'm, say, one directory deep. How can I have a specific website recognize its own base folder as the site root? I imagine that in PHP, without touching Apache config files, there's a way to set a new site root, I just don't know how.
Execute As Root
Is there a way to execute commands as root using sudo? If yes, how to use it, if no, how can I get around.
Access To Mp3 Files Below Web Root
I want to place some mp3 files below the web root directory to keep people from accessing these files. however i want certain php scripts to be able to use them (ie for a flash movie that plays mp3 files)whats the best way to accomplish this?
Goto Root Directory
does anyone know how to goto the root dir on a LINUX server. I mean like go to parent directory of public_html. i want store a really secure file there and then use the iinclude function to get it when i need it. is this even possible. are there limitations for using the "../" command in include functions? i've obviously tried something like include("../../../home/mydir/my_secure_script.php"); //doesnt work
Calling Include Outside Root
so I want to keep my mySQL connection file and my constants file (variables) outside the webroot in '/inetpub/includes/' with the root being '/inetpub/wwwroot/'. I should be able to call this with. PHP Code:
Opening Docs Outside Of The Www Root
I'm trying to find a way to make links with php that will open up files I have stored outside of my web root (i.e., when someone clicks on the link, php opens up a PDF file that is outside of the public folders). I've been scouring the PHP manual to find a command that will do this easily but most of them are more in depth than I need.
Finding Nth Root Of X Quickly?
what is a quick way of finding the nth root of a large number? My program checks a bunch of numbers to find their square root, cube root, 4th root etc. but I think I could make it faster. I've tried using pow($number,(1/2)); but the numbers I'm using are way to big (hundreds of digits) so I tried the same thing with bcpow() but it would only return 1 when I tried to use (1/2) as the exponent. Why is that?
Php-cli No Mysql Module For Non-root
So far I've been unable to find anything that addresses this one... Basically, if I am logged in as root and issue a "php -m", mysql is in the list of installed modules. If I log in or su to a normal user and do the same then mysql is *not* in the list and I cannot use mysql_connect (or any other mysql function)... Any ideas on why this is or how to fix it? Notes: # php -v PHP 4.3.3 (cgi-fcgi) (built: Nov 4 2003 14:05:47) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies Module list as root: bcmath,bz2,calendar,ctype,dba,dbase,ftp,gd,gmp,ima p,mysql,openssl,overload,pcre, posix,session,shmop,sockets,standard,sysvsem,sysvs hm,tokenizer,xml,yp,zlib Module list as non-root: bcmath,bz2,calendar,ctype,dba,dbase,ftp,gd,gmp,ima p,openssl,overload,pcre,posix, session,shmop,sockets,standard,sysvsem,sysvshm,tok enizer,xml,yp,zlib
Setting Password For Root
I'm just starting PHP and MySQL - and really like the book by Welling and Thomsom. I've installed MySQL on my WinXP desktop, along with Apache and PHP. I have not figured out how to set a password for the root account. I've been able to set up a user account for myself, with a password, but not the root account. I understand this is not ideal. I've tried setting the password in My.ini but it doesn't seem to work. I must be doing something wrong.
Accessing Files Outside Of The Web Root
Anyone got any pointers for a script and/or advice for accessing files that are outwith the root directory. I am using Apache on WIN2K Server (a box which is also running IIS on port 81). I want user to be able to select a file and have a script verify their security clearance level (although I have this part worked out already) and then to supply a relative url from the web page they are on - out of the web root - to the file in question. I have been toying with the 'realpath' function but to no avail thus far. I have tried using the path: ../../../files/{filename} where the path to the web root (from the page in question) is ../../../ on my notebook (running WINXP Pro and same version Apache and PHP this works fine) but on the production server it cannot find the path outwith the server root.
Root Of Folder App Files
While I know putting a app into a folder was chiseled out of fine scottish granite and carried upto the top of ben nevis by php newbies many years ago - I dont think a folder is the best way to do it . The fact a script is in a folder means certain instant problems if you want to do certain things with . Assuming a script doesnt have index.php and all the script files have a filename prefix like phpgb_ then theres no chance of them clashing with anything else and theres no real reason to continue using a folder for the main script files . While the script will have a app folder for various things - does it make any sense not to use the root because of a single solitary file called index.php . phpgb_index.php is what I use and the method hasnt brought up a single problem of any shape or description . Gas lighting was once what everybody thought was the best way of doing it until that darn new fangled electricity came along .
Smarty Installation In Root
I would like to install Smarty in a directory placed in my root. Could you please give me intructions of how I am going to do it?
Locating Root Directory
I posted earlier about finding a directory path from another directory. I tried to find the root directory of the site using the following variable: $_SERVER['DOCUMENT_ROOT']; Which I was then going to search to find the appropriate directory. However doc root is not defined on the server i'm using. So my question is this, is there another way to find the root directory and if not how can I set the document root variable? what do I need to change in the server configuration?
PHP Files Only Run In Root Directory?
I've installed a php forum script under a directory named 'forum', the script ran with no problems untill about a week ago, but now I get the following error: 'You don't have permission to access /forum/index.php on this server.' Its has nothing to do with CMOD, I've tried that. Worst still it's not just the forum it's any PHP file thats under a directory. The thing is, I can run a PHP file from the root directory, but for some reason can't run the same file under another directory. eg www.mywebsite/testfile.php --- will work fine www.mywebsite/newdirectory/testfile.php --- causes permission error Could it be a .htaccess problem? Heres my error log report: Options ExecCGI is off in this directory: /home/mywebsite/public_html/forum/index.php P.S The forum script dosn't use CGI?
Read A File Below Root
How can I include a file from below the Root dir, other than using: include "../../filename.inc.php";
Php Initializes Extensions As Root
I'm having a problem, i've designed an php extension, that uses shared memory iteraction. Altought, Php is initializing the extension as root, leaving the shared memory with wrong permissions, as is created as root process. Is there any way to initialize extensions, not as root?
Running Exec As Root?
exec('/sbin/ifdown eth0'); does not work, due to needing to be run as root. I need to have this work on a closed network environment.
Site Root Directory?
I've posted this onto alt.php earlier and stumped all involved. I didn't cross post for the usual reasons Anyone here got any ideas? -------------------------------------- I am simply attempting to find my sites root directory so I can then step up into a folder in which I will have my INCLUDE code. This will allow me to easily refer to my INCLUDE code without messing about. Now, This code... It simply attempts to put a file into the root of my server space, and recall it. It doesn't work. The file write doesn't error and the file read fails without error. Most importantly the file is nowhere to be seen! <Added when sent to the domain provider> -------------------------------------- I am worried the file is dropping into a space not allocated to my account and that this could cause you/I some problems if it were to overwrite an important file.
Running System() As Root User
Is there a way that I can run the system() command as a root user. Need to restart network services on a server via php.
Define Root Directory For Images
I want to have a root directory from which the images on different pages shall be displayed. I define it here: define('image_root', '/web/d2/w/mydomain/mydomain.com/images/'); Then I try to pass this path to the image: $imageurl = image_root . $myrow['image']; echo "<div id=left><img src='$imageurl' border=1></div>";But it doesn't work... Any ideas?
Requiring File From Root While In Sub-domain
I'm trying to include a file from my root directory but I can't figure out how to. The file that is requiring is in sub.domain.com and the file to be required is in domain.com. How would I go about including it?
Display Image Above Root Directory
Is it possible to display an image that is above the root directory using php? for example if i have an image in /home/user/uploads/test.jpg and lets say my root directory for my site is /home/user/public_html/ is it possible to display test.jpg on /home/user/public_html/index.html ? i am trying to create a secure file upload script and i think not having the file be directly accessed by the public is one of the main steps.
.tmp Files Being Placed In The Root Directory By The 100's, Want It To Stop
Hi folks, I have a bit of a problem, perhaps one of you knows what is going on. According to the sys admin at my ISP, something from my site (which is entirely php) is saving 100's of tiny files with the extension .tmp into the root directory on the server where my site is located. He doesn't know very much about PHP and neither do I (this is the first site I've ever produced using it) so neither of us knows what could be causing it, there is one other site hosted on that server that is running PHP and it is doing the same thing, although the lion's share of temporary files are coming from my site. I have a copy of the php.ini file that he emailed to me this morning, if it would help to post it please let me know and I will do so. We are not sure what is going on, but we would like to know if there is some way to make it stop (or at the very least, to get these files to destroy themselves once they're no longer usefull) Also: I would like to thank SilkySmooth for his mail script, I used it awhile back and it got the job done. Thanks so much!
Access Denied For User: 'root@localhost'
Warning: MySQL Connection Failed: Access denied for user: 'root@localhost' (Using password: NO) in /www/apache/domains/www usually this error occurs when i've wrong password, i'm sure i haven't. other strange thing is that it says root@localhost... should it? this crap happened after my webhost company upgraded their servers... the code must be fine!!! i think so at least... before it worked... i checked the password, host, and username are fine...
Problem With Locating Image Directory From Root
All i want to do is change my following method that works fine, so that it checks from the root directory. This is what i originally have and works fine: $file_name = 'products/'.$pId.'s.jpg' if (file_exists($file_name)) $test = true; else $file_name = 'template/noimage.gif' I tried changing the following line but it does not locate the image: $file_name = '../products/'.$pId.'s.jpg' The folder 'products' and 'template' are in the root directory. ie. root/products...
Php Control Panel -setuid/root Permission
I'm currently developing a web based control panel that allows users to change e-mail paswords, create subdomains etc. which is to be expected to run for more than 1000-2000 domains in a short time. Both versions of php (apache module and cgi versions) that I'm using are used for the panel. (OS RedHat Linux) Everyting seemed ok up to the point where I tried to do things that required root permissions (for ex. "useradd" command) I've been searching on the web since 3-4 days but it seems that nobody has found a good, working solution for this problem (even on this forum. For ex: 1) I call cgi php from web page with <form action=add_user.php> 2) try to add a user from cgi php like exec("adduser test_user") the cgi php doesn't work because useradd command needs root permissions ! Most of the time it is indicated that using chmod 4755 or chmod u+s filename will allow cgi php to gain root permissions but it doesn't work. Also posix_setuid() doesn't work as expected because Apache runs as nobody. The only working solution seems to run cgi php from cron, but that way some features of the control panel i'm coding will not be as dynamic as I wanted.
Root For Including Www Link In A Form With Drop Down
I have everything working except what should be a simple issue I think, but I continue to miss it. My links end up in the root of my website: e.g. http://www.fitzssite.com/ www.devshed.com instead of simply www.devshed.com or http://www.devshed.com How do I point to a "blank address area" (don't know what to cal this...) for my links? Here is my code: PHP Code:
Subdomains Retaining The Logos From The Root Domain
$_SERVER['DOCUMENT_ROOT'] returns the root path for the subdomain, which is different than the root path for the primary domain. Is there a global variable to get the path for the root domain? What's the best way to handle this when you want to keep use the logo for the root domain?
I Can Upload Files Anywhere Except My Remote Root Folder
Im working on a project with PHP that allows users to upload pictures to my server and then reference them. After going through some uploading tutorials I have the uploading part working Except! I cant upload folders to my remote root folder. I need to allow the users to upload somewhere inside the root folder so they can reference the pictures in code after. Just to clarify the uploading works perfectly if I put the uploads folder anywhere on my computer except the sites remote root folder (or anywhere inside the root folder) I also beleive I am giving the folder all of the proper permissions because I am giving the uploads folder in my root directory (the one that doesnt work) the same permissions as the one outside the root (the one that works) Code:
Root Level Access With Multiple Domains
I've created a PHP testing environment on my PC using IIS. The default web root directory is C:Inetpubwwwroot. Every domain that I test sits underneath it, like: C:InetpubwwwrootSite1 C:InetpubwwwrootSite2 etc... The problem that I'm having is that in my PHP code, sometimes I would like to include files by referencing them at the root level, i.e. include(‘/somefile.php’). This of course works on the production Apache web server, however, on my local installation the ‘/’ refers to the ‘wwwroot’ directory instead of the domain (or folder). Is there a way to configure IIS to look at each folder as the root? ....
Executing System Files Deep In The Root Tree
I am running on an linux box with ensim webppliance. Ensim is really cool because it has a hold folder of files that perform different tasks that you would normally do from the interface. My problem is, i don't want to do them by hand, i want one of my PHP scripts to executre them and return the results. Now, there are a few problems, like you have to be root to run these scripts, cus they are in /usr/local/bin. I tried shell_exec, and exec, but I can't seem to figure out how to do this correctly.
OpenSSL New Trusted Root Certificate PHP/HTML Integration
I want to set up my website to use my OpenSSL generated root certificate - and I intend on being a real certificate authority to clients. Once the root certificate is installed the SSL certificate for the hostname issued from that CA is accepted without warning by most browsers at standard settings....
PhpMYAdmin #1045 - Access Denied For User: 'root@localhost'
I have set my config file for a password with Mysql and phpMyadmin but when i try to load the phpMyAdmin page i get this error. ################# Error MySQL said: #1045 - Access denied for user: 'root@localhost' (Using password: YES) ################### I have set a password and want it to ask me for one but dont know how to go about it. If i dont set any password I can enter phpMyadmin no problem but soon as I change the configuration to have a password it wont let me in and wont ask for a password to authorize me. Is there a step im missing or somewhere I can read to learn how to get this working with the password.
Database Connection Problem In Included File On Root Directory
I have a file called tophtml.php that connects to the database. It's in the root directory of the site. It works perfect in the root directory. But if I call it in a sub directory. (e.g. require("../tophtml.php") or require("C:websitesdogrealm ophtml.php")) I get errors saying it can't connect to the database.
|