Warning mkdir permission denied in

Никто не сможет ли со стороны изменить что либо?

Права 777 — меняй кто хочешь чего хочешь

то если на файлах и будет стоять 777 их же кроме меня никто не сможет изменить?

Считается использование прав 777 дурным тоном. Помимо пользователя, из под которого ты работаешь в системе есть множество других, от имени которых работают различные службы, неплохо задавать права таким образом, чтобы доступ к определенным файлам мог получить тот кому это нужно. Если речь идет о php файлах, то сама цифра 7 в правах на любой из позиций уже не верно, за исключением некоторых ситуfций.

Помимо пользователя, из под которого ты работаешь в системе есть множество других

так а как правильно если мне вот в данной ситуации нужно чтобы скрипт создавал директорию и файлы

что значит в системе есть множество других

созданные директории имеют владельца не root а www-data

Даже из этой темы видно что по крайней мере кроме рута есть еще один пользователь — www-data

вот я и сам не понял как это, на всех исполняющих файлах стоит владелец root

тот скрипт который выполняется кроном создает папку с владельцем root

I have this PHP script:

Which creates a folder for storing posts’ images. However I’m getting this error / warning:

and I can’t create the folder.

How can I fix this? My folder structure looks like this:

Some further information: if I comment this code, manually create the posts folder and then try to upload a file I get an error saying that the destination path is not writable.

Output of ls -l /opt/lampp/htdocs/www/my-site/ :

Output of ls -l /opt/lampp/htdocs/www/my-site/public :

Читайте также:  Keyboard перевод на русский язык с английского

I am trying to create a directory with PHP mkdir function but I get an error as follows: Warning: mkdir() [function.mkdir]: Permission denied in . . How to settle down the problem?

12 Answers 12

I know this is an old thread, but it needs a better answer. You shouldn’t need to set the permissions to 777, that is a security problem as it gives read and write access to the world. It may be that your apache user does not have read/write permissions on the directory.

Here’s what you do in Ubuntu

Make sure all files are owned by the Apache group and user. In Ubuntu it is the www-data group and user

chown -R www-data:www-data /path/to/webserver/www

Next enabled all members of the www-data group to read and write files

chmod -R g+rw /path/to/webserver/www

The php mkdir() function should now work without returning errors

Late answer for people who find this via google in the future. I ran into the same problem.

NOTE: I AM ON MAC OSX LION

What happens is that apache is being run as the user "_www" and doesn’t have permissions to edit any files. You’ll notice NO filesystem functions work via php.

Open a finder window and from the menu bar, choose Go > Go To Folder > /private/etc/apache2

now open httpd.conf

change the username:

Now restart apache by running this form terminal:

If it still doesn’t work, I happen to do the following before I did the above. Could be related.

Open terminal and run the following commands: (note, my webserver files are located at /Library/WebServer/www. Change according to your website location)

Читайте также:  Socket error 10061 connection refused ошибка

Don’t set permissions to 777 when using mkdir in PHP

Link only answers are not considered good practice on StackOverflow, but the advice that is given here should generally NOT be followed up.

I would like to revert to this great answer on a similar question. I quote:

Please stop suggesting to use 777. You’re making your file writeable by everyone, which pretty much means you lose all security that the permission system was designed for. If you suggest this, think about the consequences it may have on a poorly configured webserver: it would become incredibly easy to "hack" the website, by overwriting the files. So, don’t.

Rate this post

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *