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.

When I create a file by exec() or other php functions, permissions is 600 and for folders is 700.

How can I change it without chmod() or other like functions to 644 and folders to 755.

Server detail:

  • server os: ubuntu 10.04
  • suphp installed
  • PHP Version 5.3.2-1ubuntu4.14
  • SERVER_SOFTWARE: apache
share|improve this question

2 Answers 2

up vote 1 down vote accepted

The permissions files are created with are specified with umask on Unix. There is a php function to alter this; see here for the php function.

To change the permissions that Apache has, see this

share|improve this answer
    
i need to change default parmissions in server configuration. –  Hamid Tanhaei Feb 26 '12 at 20:13
    
I'll edit my post to have the apache info in for you: –  webtoe Feb 26 '12 at 20:17
    
Good answer. I wouldn't chang ethe global umask of the Apache user though, just change with PHP before you need to create a file or directory with it. –  Yanick Girouard Feb 26 '12 at 20:28
    
I concur with @Yanick. Altering the actual init script has two problems. 1.) Altering the init.d scripts will be a nuisance to maintain as apt-get may update the init.d scripts if they alter in future (and systemd doesn't use init.d scripts). 2.) With PHP it is more obvious from your code what you are doing and can be easily documented inline. –  webtoe Feb 26 '12 at 22:32

There is a bug in the Apache mod_dav module in 10.04 (2.2.14 apache2) so that all files are created with the wrong permissions.

You can either: - install apache 2.2.15 - I am thinking about that but I've no clue how to do that without breaking everything else! - Upgrade to 10.10 - setup a crontab script to change the permissions

I've done the last one there. But looking for help on doing the first one.

See related bug https://bugs.launchpad.net/ubuntu/+s...e2/+bug/540747

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.