0

I'm running this script:

$dir = 'images';
if (!file_exists($dir) ) {
    mkdir ($dir, 0644);
}

It returns this error:

Warning: mkdir(): Permission denied in /opt/bitnami/apache2/htdocs/file.php on line xx.

Apperently i do not have the rights to create the folder. I found the following:

  • htdocs has chmod set to 755
  • The owner of htdocs is daemon (lrwxrwxrwx 1 daemon daemon 27 Aug 1 12:16 htdocs -> /opt/bitnami/apache2/htdocs)
  • I created a file with php while temp. using chmod 777 and then used this script: https://stackoverflow.com/a/7771686/1139465 to figure out the owner, that was daemon (Array ( [name] => daemon [passwd] => x [uid] => 1 [gid] => 1 [gecos] => daemon [dir] => /usr/sbin [shell] => /bin/sh ) done)

I have an intallation of the Bitnami LAMP solution.

Community
  • 1
  • 1
  • Check the owner of /opt/bitnami/apache2/htdocs, not the symlink. – Devon Bessemer Aug 02 '15 at 14:55
  • Hi specify whole path not just final directory and check permission $dir = 'images'; – volkinc Aug 02 '15 at 14:57
  • @devon that was the problem. I changed ownership of the symlink. I did ls -l /opt/bitnami/apache2/ to find out that the owner was actually different then expected. The command sudo chown -R username:username /opt/bitnami/apache2/htdocs change it. Now the code does work. – athingortwo Aug 02 '15 at 15:59
  • @volkinc sorry, was not that clear, i tried both (full and short path), but indeed the full url in combinatino with Devon's solution did work. – athingortwo Aug 02 '15 at 16:00

0 Answers0