Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Ok all my files and folders are set as owner of vsftpd:nogroup. FTP program can upload and create and do everything. But when I use the PHP command mkdir, I get a Permission Denied even though the folder its creating it in is set to chmod 777. IF i set the base folder to user www-data and group www-data, PHP mkdir will work. However, I can't use FTP to delete or upload to that folder.

/uploads is base folder.

I use PHP mkdir to create a directory in there:

if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $_REQUEST['clientID'] . '/video/')) {
    @mkdir($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $_REQUEST['clientID'] . '/video/', 0777);
}

If /uploads is vsftpd:nogroup then PHP mkdir will give a Permission Denied error.

If /uploads is www-data:www-data then PHP mkdir WILL work, but I cant continue to FTP anything in that folder that was just created.

If /uploads is vsftpd:www-data then PHP mkdir will give a Permission Denied error.

How can I create a directory with PHP and still be able to access it via FTP?

share|improve this question

migrated from stackoverflow.com Nov 7 '11 at 10:33

This question came from our site for professional and enthusiast programmers.

1  
Put the WWW user and the FTP user in a group and give that group ownership of the directory. This is not a programming question, it's a UNIX/system administration question. –  Dan Grossman Aug 1 '11 at 2:51
1  
possible duplicate of FTP and Apache permission issues –  quanta Nov 7 '11 at 10:35

1 Answer 1

This should add your user to the www-data group. As long as files created by www-data are made with a group write you should be able to modify or delete them

sudo adduser vsftpd www-data

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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