|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
PHP as a Linux Service for FastCGI
I'm running Fedora Core 2 Linux and am trying to get SquirrelMail 1.4.3a running through the FastCGI servlet under Caucho Resin 3.0.8. It actually works, except for redirect pages, but I haven't worked on figuring that part out yet.
Anyway, from the command line I can bind PHP to a port using the "-b <address:port>" argument and it listens for FastCGI requests and processes them. I'd like to run PHP as a Linux service and as a user other than root (say, php). I'm not quite sure how to write an init script (though I've looked over a number of them sitting in /etc/init.d/). Any help to get me started would be most appreciated. Also, do you know whether the daemon PHP non-root user should be the same user that's running the Webserver (in this case, resin)? |
|
#2
|
|||
|
|||
|
RE: PHP as a Linux Service for FastCGI
Okay, I've pasted together the following init script by copying parts of others in the /etc/init.d/ directory. It nearly works, but here's the problem: the process doesn't run in the background, even though I call it using the daemon command defined in /etc/init.d/functions (is this script particular to Redhat & Fedora only?).
I can force it into the background by adding an & at the end of the daemon line, but: 1) none of the other scripts do this, and 2) it doesn't return with the [ OK ] confirmation that the others do. Maybe some folks can copy, run and edit this to get it to work the way I think it should. Or tell me where I'm going wrong: Code:
#!/bin/bash
#
# Startup script for the PHP FastCGI server.
#
# chkconfig: 345 85 15
# description: PHP is an HTML-embedded scripting language
# processname: php
# config: /etc/php.ini
# Source function library.
. /etc/rc.d/init.d/functions
case "$1" in
start)
echo -n "Starting php-fcgi: "
daemon --user resin php -b 8002 &
echo
;;
stop)
echo -n "Stopping php-fcgi: "
killproc php
echo
;;
status)
status php
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
By the way, I had to change the ownership of certain Squirrelmail configuration files to the resin user (retaining the original group), but doing so DID accomplish my goal of running the PHP process as non-root and still processing requests from the server. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Server Administration > PHP as a Linux Service for FastCGI |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|