I have been trying to create a new directory under unix with a PHP script which uses the mkdir function but have been unable to do what I need. Only by changing the permissions (chmod) of the target directory to 777 can I create the directory. However, changing the directory permissions to 777 is something that I want to avoid.

What I would like to do is this:
1. Create a new directory in my home (root) directory which currently has its permissions set to 755. Since my site is with an IP and it is they who have chosen the 755 permissions I would like to leave these home directory permissions as they are; i.e. 755. After creation of the new directory I will be able to access it at: /home/newDir .
2. The PHP script which executes the mkdir function should reside in path: /home/phpScripts

I would naturally appreciate any help anyone could give.

Thanks,

George

    .
    you can always use the exec() and command() functions. they communicate directly with the shell. example:

    exec("su;$password;cd $path;mkdir $mkDir;exit");

    or something like that. you can also do chmod, chgrp, chown, and stuff... just like you would in a normal shell. Hope that helps you out.

    not sure if su can work that way, cause i've never tried it, but its a shot in the dark...

      22 days later

      su is permited only from tty
      mkdir() is same as exec(mkdir)

      you need to give apache w access to the directory in witch you would create the $dir but be aware that anybody using your server has w access to it. apache usualy runs as nobody or apache, you can chown -R nobody directory, but be carefull

        Write a Reply...