Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2013
    Posts
    74
    Thanks
    19
    Thanked 1 Time in 1 Post

    How do I make directory outside of root?

    I want to make directories for users that are located outside the root of the site. These folders will contain files they end up uploading. But I'm realizing right now as I am trying to do it, that I don't know how to do it.

    The only way I know how to make directories is within the site itself.

    PHP Code:
    mkdir("new_folder"0775); 
    Can someone tell me how to make a directory above the root?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Use an absolute path or a relative path and move up above the public_html. If this file is currently located directly under public_html, you can get above there using ../.
    Privilege wise you may need to manually create a directory that's sibling to the public_html and assign the additional privileges. If you cannot create in the ~/ directory (assuming public_html is directly below ~), then I wouldn't suggest opening it up. I would suggest creating the adjacent one and adding the necessary permissions to it.

  • Users who have thanked Fou-Lu for this post:

    cgdtalent (01-09-2013)

  • #3
    New Coder
    Join Date
    Jan 2013
    Posts
    74
    Thanks
    19
    Thanked 1 Time in 1 Post
    I did the following to make a directory named "user1" and it didn't make the directory:

    PHP Code:
    $file_path "/var/www/vhosts/s15271400.onlinehome-server.com/httpdocs/users/user1";
    $result mkdir($file_path0777);
    if(
    $result) {
    echo 
    "Success";
    } else {
    echo 
    "Failure";

    I set the permissions on httpdocs and panusers wide open and it still didn't make the directory.

  • #4
    New Coder
    Join Date
    Jan 2013
    Posts
    74
    Thanks
    19
    Thanked 1 Time in 1 Post
    Initially I couldn't even make a directory within the root but then I went into the server and changed the permissions for the folder the site exists in, and now I can at least do that. But even with the file permissions set wide open on /httpdocs/ and httpdocs/users/ it still won't make a directory.
    Last edited by cgdtalent; 01-09-2013 at 02:21 AM.

  • #5
    New Coder
    Join Date
    Jan 2013
    Posts
    74
    Thanks
    19
    Thanked 1 Time in 1 Post
    I got it to finally work. I had to set the open_basedir to allow or include the directory I was creating the folder within. I'm not sure if this is a good thing to do but it worked. But here is the setting before on open_basedir:

    {DOCROOT}/:/tmp/

    And here it is now:

    /var/www/vhosts/s15271400.onlinehome-server.com/httpdocs/:{DOCROOT}/:/tmp/


    Does anyone who knows about servers think this is ok?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Is the httpdocs the parent of public_html, or is it the directory in use for serving the http docs out of?
    The use should be fine. The purpose of this directive is to force PHP to only open files in specific locations in the filesystem tree. This appears to be tight enough IMO (although I don't know what the {DOCROOT} is); the ones to really watch for are / and . since both of these can be heavily exploited (baring permissions of course).
    Another problem I often see with this is the umask as well. Seems to me that you're okay on yours though.

  • Users who have thanked Fou-Lu for this post:

    cgdtalent (01-09-2013)

  • #7
    New Coder
    Join Date
    Jan 2013
    Posts
    74
    Thanks
    19
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Fou-Lu View Post
    Is the httpdocs the parent of public_html, or is it the directory in use for serving the http docs out of?
    The use should be fine. The purpose of this directive is to force PHP to only open files in specific locations in the filesystem tree. This appears to be tight enough IMO (although I don't know what the {DOCROOT} is); the ones to really watch for are / and . since both of these can be heavily exploited (baring permissions of course).
    Another problem I often see with this is the umask as well. Seems to me that you're okay on yours though.
    the directory httpdocs is above the root of the site and is outside of it. Here would be a view of the server at its highest level:

    - httpdocs
    - site ------> html files in this directory
    - private
    - cgi-bin

    So maybe the site should have been put in the httpdocs folder, but it wasn't. It was placed outside of it. I don't know enough about servers to know if this is ok, but I'm hoping it is.


  •  

    Posting Permissions

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