hai,
I'm using php in linux environment. In my web application i need to create dynamic directory thru php. I used the following snippset,
<?php
mkdir('directoryname','0777');
?>
But i could not get the result. Since, when i run the web application in mozilla browser, it takes user as apache user not root user.but root user only can create the directory.
How i can change the apache user to root user when i run the web application?
or Is there any alternatives?
Help me.....The user you're referring to is the user that is running the apache server; without restarting the server, it's not possible to change the user (though you may be able to run exec(su) and gain superuser access, though that would still not be recommended).
The better alternative is to put all of the dynamic directories under a specific directory which is owned by the same group as the apache server is run under (probably apache, though not necessarily). Give this specific directory group write access (chmod 770 or 774 or 775) and you should be all set.One other note: the second parameter of mkdir is an octal, not a string. It should be:
mkdir('directory', 0777);
And of course you can always try chown though it may not work.
~Brett
I'm using php in linux environment. In my web application i need to create dynamic directory thru php. I used the following snippset,
<?php
mkdir('directoryname','0777');
?>
But i could not get the result. Since, when i run the web application in mozilla browser, it takes user as apache user not root user.but root user only can create the directory.
How i can change the apache user to root user when i run the web application?
or Is there any alternatives?
Help me.....The user you're referring to is the user that is running the apache server; without restarting the server, it's not possible to change the user (though you may be able to run exec(su) and gain superuser access, though that would still not be recommended).
The better alternative is to put all of the dynamic directories under a specific directory which is owned by the same group as the apache server is run under (probably apache, though not necessarily). Give this specific directory group write access (chmod 770 or 774 or 775) and you should be all set.One other note: the second parameter of mkdir is an octal, not a string. It should be:
mkdir('directory', 0777);
And of course you can always try chown though it may not work.
~Brett