I use mkdir($folder_path, 0755) in localhost(MAMP) it works, but after I move to VPS I use LAMP it failed.

the direction path is /var/www/html/assets/images/ the images folder info:
Owner: root
Group: root
Octal: 755
foldervar, www, html, assets both same


Apache Version Apache/2.2.15 (CentOS)
Server Administrator root@localhost
User/Group apache(48)/48

safe_mode Local Value Off Master Value Off

I try to let user through upload file and create folder through below function
$folder_path = '/var/www/html/backstage/assets/images/0'; if ( mkdir($folder_path, 0755) ) { ...move_uploaded_file();}

How to solve it?

(Should I change anything about permission on linux use command line?) Any suggestion will be appreciated, this is my first time build server..

closed as off-topic by MadHatter, Ladadadada, Ward, Jenny D, mdpc Jul 15 '14 at 20:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – MadHatter, Ladadadada, Ward, Jenny D, mdpc
If this question can be reworded to fit the rules in the help center, please edit the question.


Your permission set is incorrect. Assuming all the /var/www/html is used by and for apache, you need to change it so it's owned by apache.

sudo chown apache:apache -R /var/www/html

That will make html folder and everything under it owned by apache and with group as apache.

Also, I would recommend to take time to read up on what Owner/Group/Other and their permissions mean. As your usage of root:root shows lack of core mechanics of Linux OS. Here is one such article: http://linuxcommand.org/lts0070.php

  • Thanks it works!! so should I add a user administrator /var/www/html/ , and let him upload folder and also set php user as him? – user1775888 Jul 14 '14 at 10:20
  • 1
    Simplest way is to add the administrator's user to the group. And add group's write permission. chmod g+w -R /path/to/folder – Grumpy Jul 15 '14 at 3:34

you have to check which user runs apache. This should never be root! Normally its apache, nobody or www-data. when you know, which user runs apache, you have to change permissions that this specific user can read (and execute and/or write, if needed) the files.

Then it probably will run like in your localhost enviroment

  • I said in question... User apache Group apache – user1775888 Jul 14 '14 at 9:54

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