PHP/Apache Can't Write To Anything

I've been encountering an issue on a client site for the past couple of weeks where they can't upload files to a directory outside of the web root.

After looking in the error logs, it looks like PHP is spitting out errors saying the upload directory is not writable. This directory happens to be outside of the web root but there are no open_basedir restrictions on the server.

I have a test script that executes the following code:

$path = '/var/www/vhosts/testdir';
$writable = is_writable($path) ? 'is writable' : 'is not writable';

echo "$path $writable";

When I run the script from the command line with php test.php the directory is writable. However, when I access the page from the browser, it is not writable.

Both the web root directory and testdir belong to the same user and group and have 755 permissions set. I've tried setting the owner of both dirs to apache to no avail.

When I set the permissions for the upload directory to 777 it works, but obviously I don't want all my files to be readable and executable to everyone.

Distro is CentOS 6.7.

Am I missing something obvious here?

0
задан 2 September 2016 в 17:13
2 ответа

Ваша проблема почти наверняка в SELinux. Файлы и каталоги за пределами «веб-корня» вряд ли будут иметь правильный контекст SELinux, например. httpd_sys_content_t.

Вам нужно будет изменить контекст SELinux для файлов / каталогов, в которые вы хотите иметь возможность записи.

0
ответ дан 24 November 2019 в 05:51
[११50०574।] Httpd चलाउने प्रयोगकर्ता वा समूहसँग लेखन पहुँच हुनुपर्दछ। पीएचपीले यसलाई httpd बाट प्राप्त गर्दछ।
0
ответ дан 24 November 2019 в 05:51

Теги

Похожие вопросы