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

So I was wondering, what steps should we take to make sure PHP daemons are safe?

One of the things that I read about was assigning the daemon to run as a user with limited priveleges? But how can we do that in UNIX?

I am guessing using the useradd function but how do we make sure that user ADDED has limited privileges?

Also what other steps should we do for security when it comes to PHP daemons?

EDIT: I am using Centos 5.5 (Linux)

share|improve this question

migrated from stackoverflow.com Dec 13 '11 at 19:30

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

11  
Your question title is simply brilliant. –  BoltClock Dec 13 '11 at 19:25
    
telling us which distro/os you are using would help us help you. –  stew Dec 13 '11 at 19:39
3  
You need to think this question through a bit -- there's a lot of missing information/details. You don't define what you mean by "safe" -- Safe from what? Being exploited by a remote user? (Write secure code!), Safe from crashing?(Write something to monitor/restart it). You also don't define what you mean by a "php daemon" -- PHP is a language, so are we talking about a daemon written in PHP? (why would you do that?) A web server daemon that executes PHP code? (Read the webserver manual and secure it properly). Something else? –  voretaq7 Dec 13 '11 at 21:16
    
@voretaq7 This is the answer. To Pota: Do code audits on the OS, the webserver and the scripts. Check if the code is safe in the way you defined "safe". –  mailq Dec 13 '11 at 22:28

1 Answer 1

External Mandatory Access Control is the answer.

mod_apparmor is a great solution that will allow control over individual program installations and keep a security flaw in one app from trouncing all over the other. For example, you can keep a poorly written PHP script from writing files when you never expected it to. It will keep a security flaw in WordPress from allowing access to a MediaWiki install on the same machine.

Also, you can wrap Apache itself with a suitable AppArmor profile. It's really fantastic stuff. :)

If you're talking PHP daemons that are run directly instead of through Apache, then treat them like a any other daemon with AppArmor.

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.