PHP issue with folders outside domain


Basically I am running a site that has a picture gallery and other media stuff. I moved the picture gallery to another folder (created by adding a new user) that is outside the web domain folder. This way, I and others can add pictures without having them look at my other files.

However, here is the problem. The picture gallery uses the scandir() call which is supported under php5. I cannot figure out anywhere from Dreamhost’s panel to enable that user folder to support PHP5. I know CGI is not supported for these user folders, but PHP4 is supported so I assume PHp5 is too.

Does this seem right? I would hate to have to rewrite the PHP code back to supporting PHP4


I’m not sure what you are doing here. If your “gallery”" is run by scripts, have you placed these scripts in the directory that is “outside” the web domain folder? If so, how do you “add” images to the directory (in other words, how do you reach the “gallery” program?) Or, is the “gallery” just a collection of images? It makes a difference, as the *nix permissions on Dreamhost allow (by default) only one user to “own” a directory; without going through some machinations by creating “groups” and using unacceptably insecure permissions, other users will not be able to “share” access to the folder in any meaningful way - they will all have to login as a single user. Additionally, you’ll have “mess” with permission and symlinks, and “lions and tigers, and bears, Oh, my!” trying to serve stuff from such a directory to the web.

I could probably tell more if I knew what gallery program you are using, or if it is just an image collection, or other details as to how you are retrieving the images for web display. As it is, I can’t fathom what you are trying to do.

There seems to be a good deal of misunderstanding evidenced in these statements. Firstly, “users” on Dreamhost can either be given ftp only access, mail only access, MySQL access, or full “shell” access. You establish all this when you create the user from the web panel. You probably should review the Dreamhost Wiki information on users to get a better understanding of all this.

If you create a user from the Manage Users panel section, you can decide whether they have ftp only or full shell access via a radio button (you can change this by “editing” the user from the same Manage Users" screen at any time). CGI runs under suEXEC on Dreamhost, and therefore is tied to a given “user”, with whose permissions the CGI operates, but CGI is only relevant when discussing a directory that is used as, or within, a domain indicated as being “hosted” - and you identify which user CGI will run “as”, as well as which version of PHP will be used from the “Manage Domains” section of the panel. Outside that context, “CGI” has no meaning for a “folder”.

As for the PHP4/PHP5 and scandir(), you can “set” any domain (not user!) to use PHP4 or PHP5 at any time by using the Manage Domains screen in the Control Panel. Just click the “Edit” link to the right of the displayed domain name, modify the presented screen appropriately by selecting the radio button for the version of PHP your desire, and submitting the edited page. This is same way you can select/modify which user the CGI will run as for the domain.

In short, “CGI”, or “php version” is not determined by “folder”, but by the hosted domain (which, of course, is tied to a directory). Just like “all shell users are ftp users, but not all ftp users are shell users”, all domains are housed in a directory (folder), but not all "folders (directories) are “domains” - and PHP usage, and CGI operation is controlled by domain, not by “folder” (directory).

Did that help at all, are you you now even more confused? :wink:


i read your thing and i’m overly confused… so let me clarify again what I did.

Basically I wanted to setup another user so multiple people including myself can add pictures. I wrote a PHP script that basically layers a user interface over those directories (think of a gallery without using a SQL interface). So for instance, I created a user called “mypictures” and so now there is a folder in the homes directory called “mypictures”. It’s not in the my /home/mywebdomain folder which is where my webpage would point to by default if I go to

I created a submapping which whenever i go to “”, it would look in the /home/mypictures directory for the script I wrote (which is called index.php). The problem is my script uses the PHP5 function, and that error (from what I read regarding scandir) only occurs when PHP5 is not supported which shouldnt be the case here.

I have the “http://www.mywebdomain” set up to support PHP5 (the box is checked), but I have a feeling that only applies to that specific folder ("/homes/mywebdomain" and NOT “/homes/mypictures” despite it being mapped correctly)

Does that make things a little clearer? The worse case scenario is i can just move everything back under the “/homes/mywebdomain” folder and it’ll work OR i can rewrite the script to remove the scandir() call and use php4 to do what i need to do which would suck :frowning:

Any ideas or help in understanding this sutation would be very much appreciated. Thanks.

hmm, i just thought about it… maybe i should leave all the pictures in that directory, and move the index.php from the “mypictures” folder back to the main directory. And instead have my $dir be “…/…/…/mypictures/index.php” instead of “./mypictures/index.php”

i just hate trying to figure out how many “…/” i need to recurse up a directory

I think that is a good approach, and might solve the problem.

Please forgive me for being “confusing” in my last post - I wasn’t communicating very well. I was trying to point out that running the script which is “owned” by "user B"as “user A”, (which is your user due to DH’s use of suEXEC and is set by domain), from within a directory “owned” by “user B”, and manipulating files owned by “user B” might have some unexpected permissions ramifications.

It is an interesting problem, though I’m sure it is very frustrating. Let us know if running the script from the webdomain directory helps, ok? And if it doesn’t, I’d love to see the actual error message :wink:


As far as I know and as stated in the DH wiki here:

“Note also that PHP scripts in remapped sub-directories - within your own home directory - can only run with the server’s default PHP version, which is presently PHP 4.4.2. Software that requires PHP 5 cannot run in a remapped directory.”

So your approach of moving your index.php file may be the solution. HOWEVER, i believe that a simple ‘…/…/’ will NOT let you exit your web root directory.

So if your site atm is:

/home/YOU/ and your gallery resides here

I don’t think it would work. I may be wrong though.



“Note also that PHP scripts in remapped sub-directories - within your own home directory - can only run with the server’s default PHP version, which is presently PHP 4.4.2. Software that requires PHP 5 cannot run in a remapped directory.”[/quote]
Thank you for that! I don’t know how I missed that, but I obviously did, and I appreciate you pointing it out. Thanks again! :slight_smile: