Server Administration
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesServer Administration

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old November 1st, 2004, 12:20 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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)?

Reply With Quote
  #2  
Old November 1st, 2004, 07:29 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesServer Administration > PHP as a Linux Service for FastCGI


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway