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.

So I have a couple of problems on my server.

WordPress is unable to modify .htaccess, and the same files (exact same files) are running fine on another server.

Me and my friend also tried setting up an imageboard, and downloaded Kusuba X, which was working perfectly until I tried to make a board, and it simply says "Unable to create directory" which I think is done with mkdir();?

So I think there's something wrong with php or apache, don't know which one, but I'd like to fix it.

As I googled a little bit, I found http://stackoverflow.com/questions/4061224/php-mkdir-and-fopen-does-not-work-permissions-problem-umask-problem, ran ls -splad /home/myname/ and got

4 drwxr-xr-x 12 myname myname 4096 Dec 12 18:56 /home/myname//

So I readed

it would not work because the directory is owned by root (not apache), and even though it's grouped by apache, the directory isn't group-writeable so that doesn't cut it. In this scenario, you could simply add group write perms (chmod g+w /home/myname/), and you're good to go.

But it didn't work, so I continued on the text

Something else you might see is: 4 drw-r-xr-x 2 apache apache 4096 2010-07-22 20:54 /var/www/blah/mydomain.com/htdocs/ In this case, the ownership is ok, but the directory isn't writeable by its owner. You can fix this by adding write permission for the owner chmod u+w /var/www/blah/mydomain.com/htdocs.

But I was unable to fix it. So what should I do?

share|improve this question
Have you tried creating an empty .htaccess and changing its owner to www-data (the user under which Apache runs) (chown www-data .htaccess) and also give it write access (chmod u+w .htaccess)? –  Cristian Ciupitu Dec 12 '12 at 17:45
No, didn't even know that it's possible. But how does it relate to this, as I have existing files and working systems, except these two problems. @CristianCiupitu –  Christian Dec 12 '12 at 20:26
Are the systems 100% identical? Are you running the same distribution on them? Are you using the same Apache version? There's also of the course the option of giving Apache (www-data) the write permission to the directory containing that file, but why give it more than it needs? –  Cristian Ciupitu Dec 13 '12 at 0:16
I don't know the systems, because the other host is a popular webhost and my own server is hosted by my friend, and I control only it. How would I give apache the right to write? @CristianCiupitu –  Christian Dec 13 '12 at 6:08

1 Answer 1

The problems was that apache was running in it's own user, and couldn't write to files or delete them.

chown -R apache2user /home/myname/

wouldn't do the trick, as it would block my ftp user from editing the files.

So the solution was in apache2 config, actually envvars where I simply changed the username to my own.

share|improve this answer
So Apache is running under your user? You know this means that if someone breaks in, he/she will have access to all your files, right? –  Cristian Ciupitu Dec 13 '12 at 15:01
@CristianCiupitu I'd like someone brute force trough 25 character password. And when I have fail2ban I'd really like to see that happening. –  Christian Dec 13 '12 at 15:42
I was talking about the web server. The fact that you have a 25 character password doesn't matter if your PHP application (Wordpress) has a major security bug. –  Cristian Ciupitu Dec 13 '12 at 19:09
What is your FTP user? Also, are you really using FTP or is it SFTP (SSH File Transfer Protocol)? –  Cristian Ciupitu Dec 13 '12 at 19:15
If you run your webserver as your own user, why dont you use it for the sftp login too? Or is that ftp user handed over to a third party to do limited work on the project? Offtopic protip: for anything ssh-based and out on the internet, go publickey authentication only, after you made it work disable keyboard-interactive/password based login. –  rackandboneman Dec 14 '12 at 2:15

Your Answer


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.