I have setup a little Ubuntu Server for developing some web apps.

I have a little script that uses mkdir() to create a directory, but i am getting a permission denied, its a simple command


The error that im getting is

[Tue Jun 21 22:27:25.079075 2016] [:error] [pid 21150] [client] PHP Warning:  mkdir(): Permission denied in .........

Im also getting permission denied for a few other commands like ftp_get()

When i check the phpinfo() the upload_tmp_dir is set to no value.

I am not very good at server admin so any help would be greatly appreciated.

I setup the server from a tutorial, then setup my virtual host from another tutorial.

Thanks Guys :)


Make sure Apache has permissions to write to directory where you are trying to create a new directory.

F.e. if your script is calling mkdir('/var/www/subdir/newdir'), run the following:

  1. Give apache ownership: sudo chown www-data:www-data /var/www/subdir
  2. Make directory writable: sudo chmod 770 /var/www/subdir

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.