![]() |
HowTo.DeployPHPWebAppUsingFastCGI HistoryHide minor edits - Show changes to markup October 28, 2009, at 05:01 PM
by -- lighttpd.conf has wrong event handler on DD-WRT
Added lines 448-456:
On DD-WRT it needs server.event-handler = "poll" in /opt/etc/lighttpd/lighttpd.conf The latest package writes a config without it and fails /opt/sbin/lighttpd -f /opt/etc/lighttpd/lighttpd.conf -D fdevent_linux_sysepoll.c.131: epoll_create failed (Function not implemented), try to set server.event-handler = "poll" or "select" October 17, 2008, at 08:05 PM
by -- Restore from spam
Changed lines 1-2 from:
Very nice site! <a href="http://training.cvc4.org/pharm1/14169/1.html">cheap viagra</a> to:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
October 17, 2008, at 10:49 AM
by -- wirryuyu
Changed lines 1-447 from:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
to:
Very nice site! <a href="http://training.cvc4.org/pharm1/14169/1.html">cheap viagra</a> October 12, 2008, at 12:03 PM
by -- spam revert
Changed lines 1-2 from:
Very nice site! [url=http://training.cvc4.org/pharm1/14164/2.html]cheap cialis[/url] to:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
October 12, 2008, at 11:00 AM
by -- toopiupw
Changed line 2 from:
<a href="http://training.cvc4.org/pharm1/14164/1.html">cheap viagra</a> to:
[url=http://training.cvc4.org/pharm1/14164/2.html]cheap cialis[/url] October 12, 2008, at 11:00 AM
by -- toopiupw
Changed lines 1-447 from:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
to:
Very nice site! <a href="http://training.cvc4.org/pharm1/14164/1.html">cheap viagra</a> October 10, 2008, at 09:54 AM
by -- removed spam
Changed lines 1-2 from:
Very nice site! <a href="http://training.cvc4.org/pharm1/14162/1.html">cheap viagra</a> to:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
October 10, 2008, at 09:24 AM
by -- eitopwwe
Changed lines 1-447 from:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
to:
Very nice site! <a href="http://training.cvc4.org/pharm1/14162/1.html">cheap viagra</a> October 10, 2008, at 09:17 AM
by -- Removed spam
Changed lines 1-2 from:
Very nice site! [url=http://training.cvc4.org/pharm1/14161/2.html]cheap cialis[/url] to:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
October 09, 2008, at 11:58 AM
by -- tieuyteo
Changed line 2 from:
<a href="http://training.cvc4.org/pharm1/14161/1.html">cheap viagra</a> to:
[url=http://training.cvc4.org/pharm1/14161/2.html]cheap cialis[/url] October 09, 2008, at 11:58 AM
by -- tieuyteo
Changed lines 1-447 from:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
to:
Very nice site! <a href="http://training.cvc4.org/pharm1/14161/1.html">cheap viagra</a> October 08, 2008, at 04:32 PM
by -- Remove Spam
Changed lines 1-447 from:
Very nice site! to:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
October 08, 2008, at 12:02 PM
by -- ietrrteu
Changed lines 1-2 from:
Very nice site! http://training.cvc4.org/pharm1/14160/4.html to:
Very nice site! October 08, 2008, at 12:02 PM
by -- wetituri
Changed line 2 from:
[LINK http://training.cvc4.org/pharm1/14160/3.html]cheap tramadol[/LINK] to:
http://training.cvc4.org/pharm1/14160/4.html October 08, 2008, at 12:02 PM
by -- pooryyrr
Changed line 2 from:
[url=http://training.cvc4.org/pharm1/14160/2.html]cheap cialis[/url] to:
[LINK http://training.cvc4.org/pharm1/14160/3.html]cheap tramadol[/LINK] October 08, 2008, at 12:02 PM
by -- rupipter
Changed line 2 from:
<a href="http://training.cvc4.org/pharm1/14160/1.html">cheap viagra</a> to:
[url=http://training.cvc4.org/pharm1/14160/2.html]cheap cialis[/url] October 08, 2008, at 12:02 PM
by -- eoeewuiy October 08, 2008, at 12:02 PM
by -- pyeeuyur
Changed lines 1-447 from:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Whenever you see Install PHP & php-fcgi packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi # ipkg install libstdc++ (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/test-php/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) Launch php-fcgi command (remember to add a trailing & to launch in background). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install lighttpd (:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install cherokee (:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.
Configure & launching the web servercherokeeWARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:)
Port 8082
IPv6 Off
Timeout 60
KeepAlive On
MaxKeepAliveRequests 500
ServerTokens Full
PidFile /home/mylogin/tmp/cherokee.pid
Icons /opt/etc/cherokee/icons.conf
MimeFile /opt/etc/cherokee/mime.types
MimeFile /opt/etc/cherokee/mime.compression.types
Include /opt/etc/cherokee/advanced.conf
Include /opt/etc/cherokee/mods-enabled
Documentroot /home/mylogin/test-php
DirectoryIndex index.html
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Or lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:)
server.port = 8081
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php"
server.errorlog = "/home/mylogin/test-php/error.log"
accesslog.filename = "/home/mylogin/test-php/access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
(:tableend:) The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less (:tableend:) Note: References:
Up and RunningLet other people know that you successfully use the above procedure to run PHP apps:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:)
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add
cgi.assign = ( ".pl" => "/opt/bin/perl",
".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
}
(:tableend:)
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:)
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay!
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=250
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"
## user and group to run PHP-FCGI
USERID=www
GROUPID=everyone
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The RobHam - March 2007 ''I am trying to set this up right now but can not get it working.
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' -- Please use the mailing list to report problems and ask for help. Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de as a lazy way to post photos online without creating thumbs. The performance is acceptable given the tiny footprint.
to:
Very nice site! <a href="http://training.cvc4.org/pharm1/14160/1.html">cheap viagra</a> September 07, 2008, at 04:25 PM
by -- Note about default server root and php files
Added lines 224-226:
Note: August 08, 2008, at 07:41 AM
by --
Changed lines 51-52 from:
to:
August 08, 2008, at 07:41 AM
by --
Changed lines 51-52 from:
Over at http://unslung.blogspot.com there is a guide to install Cherokee 0.7.2 on a slug. to:
August 08, 2008, at 07:36 AM
by -- cherokee webserver install
Added lines 51-52:
Over at http://unslung.blogspot.com there is a guide to install Cherokee 0.7.2 on a slug. July 12, 2008, at 03:39 PM
by --
Changed line 25 from:
Launch php-fcgi command. to:
Launch php-fcgi command (remember to add a trailing & to launch in background). April 24, 2008, at 04:45 PM
by -- php-fcgi lighttpd config
Added lines 201-202:
The current version of php-fcgi creates the fastcgi.server variables in /opt/etc/lighttpd/conf.d/10-php-fcgi.conf so if that file is included you will get a "Duplicate config variable in conditional" from lighty March 28, 2008, at 02:56 AM
by --
Added lines 59-72:
This is what I had to do to update from 0.5.6-3 to 0.6.1-2: Use the new cherokee.conf file
Use the new mime.types file
Use the new S80cherokee file
Edit /opt/etc/cherokee/cherokee.conf file
Possible changes
server!port = 8008 'use the correct port here
server!port_tls = 8008 'use the correct port here
vserver!default!directory_index = index.php,index.html 'use the correct file extensions here
'I use index.htm as the updates have overwritten the index.html file with a cherokee default one.
Jim March 27, 2008, at 05:52 PM
by -- cherokee 0.6.1
Changed lines 57-58 from:
to:
Configuration instruction for 0.6.1-1 at http://tech.groups.yahoo.com/group/nslu2-linux/message/21403. March 23, 2008, at 10:53 PM
by -- March 23, 2008, at 10:52 PM
by --
Changed lines 421-422 from:
as a lazy was to post photos online without creating thumbs. to:
as a lazy way to post photos online without creating thumbs. March 23, 2008, at 02:18 AM
by --
Changed line 424 from:
to:
\\ March 23, 2008, at 02:15 AM
by --
Changed lines 406-407 from:
to:
Changed lines 420-424 from:
I have added this php script: http://phpshow.panmental.de/ as a lazy was to post photos online without creating thumbs The performance is acceptable given the tiny footprint ~JBrown? 3-2008 to:
March 23, 2008, at 02:03 AM
by --
Added lines 406-424:
Certain Lighttpd versions (I'm using 1.4.18-3) have a bug when trying to access files >512kb it is documented here http://trac.lighttpd.net/trac/ticket/759 It basically says to add the following line to lighttpd.conf and restart the web server. server.network-backend = "write" I earlier tried running php with AppWeb? and Thttpd with no luck. Using Unslung 6.8 I installed Lighttpd/FCGI using the instructions above. The only change being that I moved the log files out of the webserver dir for security I have added this php script: http://phpshow.panmental.de/ as a lazy was to post photos online without creating thumbs The performance is acceptable given the tiny footprint ~JBrown? 3-2008 March 19, 2008, at 10:05 AM
by --
Added lines 55-57:
WARNING: the configuration has changed with Cherokee 0.6.0. Information below is outdated. February 10, 2008, at 11:54 PM
by -- please report problems to the mailing list
Changed line 394 from:
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected \\ to:
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected'' \\ Changed lines 399-400 from:
Patrick February 2008'' -- Please use the mailing list to report problems and ask for help. to:
Patrick February 2008 -- Please use the mailing list to report problems and ask for help. February 10, 2008, at 11:53 PM
by -- please report problems to the mailing list
Changed lines 394-398 from:
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected anyone can help me? i am really new at this and feel totally lost to:
i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected February 10, 2008, at 11:52 PM
by -- please report problems to the mailing list
Changed lines 391-393 from:
I am trying to set this up right now but can not get it working. to:
''I am trying to set this up right now but can not get it working. Changed lines 399-400 from:
Patrick February 2008 to:
Patrick February 2008'' -- Please use the mailing list to report problems and ask for help. February 10, 2008, at 10:00 AM
by -- asking for help
Added lines 393-400:
I am trying to set this up right now but can not get it working. i created the php-test page but when i then launch php-fcgi nothing happens anymore i need to ctrl-c to get back to my promt, just running info.php on the slug gives me this error: ./info.php: ./info.php: 1: Syntax error: "(" unexpected anyone can help me? i am really new at this and feel totally lost Patrick February 2008 December 01, 2007, at 08:17 AM
by -- Minor tweak for grammar in intro paragraph
Changed lines 1-2 from:
FastCGI is a protocol between web application and web server. Because it offers much better performance than CGI, it is often used to deploy PHP web application on lightweight web servers that do not have a built-in mod_php. to:
FastCGI is a protocol for interfacing between web applications and the web server. Because it offers much better performance than CGI, it is often used to deploy PHP web applications on lightweight web servers that do not have a built-in mod_php. November 10, 2007, at 01:32 PM
by --
Changed lines 263-264 from:
to:
November 10, 2007, at 12:36 PM
by --
Added lines 262-264:
August 13, 2007, at 06:45 PM
by -- Running the php-fcgi module in plane cgi mode with Lighttpd
Changed line 226 from:
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add to:
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add August 13, 2007, at 06:42 PM
by -- Running the php-fcgi module in plane cgi mode with Lighttpd
Changed lines 226-230 from:
to:
It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add Changed lines 230-237 from:
Extension php, php3, php4, php5 { Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
to:
cgi.assign = ( ".pl" => "/opt/bin/perl", ".php" => "/opt/bin/php-fcgi",
".cgi" => "/opt/bin/perl" )
Added lines 236-253:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) June 21, 2007, at 10:23 AM
by -- just confirming a usefull hint, beneath Rob\'s hint
Added lines 247-252:
Edit the configuration file: cherokee.conf in /opt/etc/cherokee so that the very end of the file reads: Include /opt/etc/cherokee/sites-enabled/default This finally got me from the 200 OK error to getting php files to run, yahay! June 12, 2007, at 07:19 PM
by -- PHP_FCGI_MAX_REQUESTS changed to 250, from experience a more appropriate value.
Changed line 171 from:
"socket" => "/home/mylogin/test-php/php-fcgi.sock", to:
"socket" => "/tmp/php-fcgi.sock", June 12, 2007, at 07:15 PM
by -- PHP_FCGI_MAX_REQUESTS changed to 250, from experience a more appropriate value.
Changed lines 298-299 from:
PHP_FCGI_MAX_REQUESTS=200 to:
PHP_FCGI_MAX_REQUESTS=250 March 05, 2007, at 08:12 PM
by -- Lighttpd using Externally spawned [=PHP-FCGI=]
Changed lines 298-299 from:
PHP_FCGI_MAX_REQUESTS=100 to:
PHP_FCGI_MAX_REQUESTS=200 March 04, 2007, at 11:00 PM
by -- Lighttpd using Externally spawned [=PHP-FCGI =]
Changed line 262 from:
"max-procs" => 1, to:
"max-procs" => 1 Changed lines 369-370 from:
The to:
The March 04, 2007, at 10:44 PM
by -- Lighttpd using Externally spawned [=PHP-FCGI =]
Changed lines 365-368 from:
The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of user/group to:
The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of USER/GROUP The March 04, 2007, at 09:39 PM
by -- Lighttpd using Externally spawned [=PHP-FCGI=]
Changed lines 307-309 from:
USERID=nobody GROUPID=nobody to:
USERID=www GROUPID=everyone Added lines 363-368:
Notes :- The PHP_FCGI_MAX_REQUESTS variable is deliberately set to a small value to improve server performance. Users may need to increase this a little but high values should be avoided. The spawned PHP-FCGI process should run with the same USER and GROUP as your web server (the use of user/group March 04, 2007, at 09:04 PM
by -- Lighttpd using Externally spawned [=PHP-FCGI=]
Changed lines 304-305 from:
ALLOWED_ENV="PATH USER" to:
ALLOWED_ENV="PATH SHELL USER" March 02, 2007, at 07:59 PM
by -- Lighttpd using Externally spawned [=PHP-FCGI=]
Deleted line 262:
"idle-timeout" => 120, March 02, 2007, at 07:51 PM
by -- Lighttpd using Externally spawned [=PHP-FCGI=]
Changed lines 299-300 from:
PHP_FCGI_MAX_REQUESTS=200 to:
PHP_FCGI_MAX_REQUESTS=100 Changed line 354 from:
sleep 2 to:
sleep 3 March 01, 2007, at 10:44 PM
by -- Lighttpd using Externally spawned [=PHP-FCGI=]
Changed line 171 from:
"socket" => "/home/mylogin/test-php/php-fastcgi.sock", to:
"socket" => "/home/mylogin/test-php/php-fcgi.sock", Changed lines 299-300 from:
PHP_FCGI_MAX_REQUESTS=1000 to:
PHP_FCGI_MAX_REQUESTS=200 Changed line 354 from:
sleep 1 to:
sleep 2 March 01, 2007, at 05:50 PM
by -- Lighttpd using Externally spawned [=PHP-FCGI=]
Changed line 171 from:
"socket" => "/home/mylogin/test-php/php-fastcgi.socket", to:
"socket" => "/home/mylogin/test-php/php-fastcgi.sock", Changed lines 245-367 from:
to:
Lighttpd with externally spawned PHP-FCGIThe current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program There are two steps needed to use externally spawned PHP-FCGI. Firstly the Lighttpd config file needs to be amended as follows :- (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"max-procs" => 1,
"idle-timeout" => 120,
)
)
)
(:tableend:) Next, a start up script is needed to externally spawn the PHP-FCGI processes. The following script is based on one supplied with Lighttpd Add the following script section to the file using a Linux text editor. (:table border=0 width=80% bgcolor=#eeffee:) (:cell:)
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/bin/spawn-fcgi"
## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/opt/bin/php-fcgi"
## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/opt/var/run/php-fcgi.pid"
## TCP port or socket to bind to
FCGISOCKET="/tmp/php-fcgi.sock"
# FCGIPORT="1026"
## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=1000
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.1.77"
## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH USER"
## user and group to run PHP-FCGI
USERID=nobody
GROUPID=nobody
################## no config below this line
if [ -z "$1" ] ; then
case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
case "$rc" in
start)
echo -n "Starting PHP-FCGI: "
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if [ -n "$FCGISOCKET" ]; then
EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
elif [ -n "$FCGIPORT" ]; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID -g $GROUPID"
else
echo "- ERROR - socket or port must be specified!"
exit 0
fi
E=
for i in $ALLOWED_ENV; do
eval "x=\$$i"
E="$E $i=$x"
done
env - $E $EX
echo ok
;;
stop)
if [ -n "`pidof php-fcgi`" ]; then
echo -n "Stopping PHP-FCGI: "
killall php-fcgi 2> /dev/null
echo ok
fi
;;
restart)
"$0" stop
sleep 1
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
(:tableend:) RobHam - March 2007 January 11, 2007, at 07:52 PM
by -- Added installation of libstdc++
Changed lines 10-11 from:
to:
January 11, 2007, at 03:20 PM
by --
Changed line 244 from:
to:
November 23, 2006, at 09:28 PM
by --
Changed line 244 from:
to:
November 23, 2006, at 12:38 PM
by --
Changed line 244 from:
to:
November 23, 2006, at 12:36 PM
by --
Added line 244:
May 10, 2006, at 05:21 PM
by --
Changed lines 226-227 from:
to:
Deleted lines 243-244:
I was glad I get php en mysql to work this way. But it still is very slow, although (much ?) quicker then under apache. May 10, 2006, at 05:20 PM
by --
Changed lines 226-228 from:
I had some trouble to get php-cfgi to work. First of all I mixed an older version of php (5.0.x) with php-fcgi and php-mysql (5.1.4.1) which causes php not accepting mysql code. The code of cherokee.conf above didn't work out for me. Thanks to Janne5011 I found out that I had to leave the original untouched and put the next code into /opt/etc/cherokee/sites-available in stead. to:
May 10, 2006, at 05:18 PM
by --
Added lines 225-244:
I had some trouble to get php-cfgi to work. First of all I mixed an older version of php (5.0.x) with php-fcgi and php-mysql (5.1.4.1) which causes php not accepting mysql code. The code of cherokee.conf above didn't work out for me. Thanks to Janne5011 I found out that I had to leave the original untouched and put the next code into /opt/etc/cherokee/sites-available in stead. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler fcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
}
}
}
(:tableend:) I was glad I get php en mysql to work this way. But it still is very slow, although (much ?) quicker then under apache. May 09, 2006, at 10:02 PM
by -- Note added regarding running php-fcgi with cherokee in plane cgi mode
Changed lines 167-176 from:
fastcgi.server = ( ".php" => ( "localhost" =>
(
"socket" => "/home/mylogin/test-php/php-fastcgi.socket",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
to:
fastcgi.server = ( ".php" => ( "localhost" =>
(
"socket" => "/home/mylogin/test-php/php-fastcgi.socket",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
Changed lines 176-178 from:
) to:
)
)
)
Changed lines 211-213 from:
to:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)
Extension php, php3, php4, php5 {
Handler phpcgi {
Interpreter /opt/bin/php-fcgi
}
}
(:tableend:) May 07, 2006, at 01:26 AM
by --
Added lines 212-213:
May 04, 2006, at 11:39 PM
by --
Changed line 211 from:
to:
May 04, 2006, at 11:39 PM
by --
Changed line 211 from:
to:
May 04, 2006, at 11:37 PM
by --
Changed line 211 from:
to:
May 04, 2006, at 11:37 PM
by -- added up&running list
Changed lines 204-211 from:
to:
April 14, 2006, at 03:37 PM
by --
Changed lines 3-4 from:
The example below is on unslung firmware and using optware packages. Whenever you see to:
The example below is on unslung firmware and using optware packages. Whenever you see Added lines 24-30:
Launch php-fcgi command. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/bin/php-fcgi (:tableend:) April 13, 2006, at 04:04 AM
by --
Changed lines 3-4 from:
The example below is on unslung firmware and using optware packages. to:
The example below is on unslung firmware and using optware packages. Whenever you see March 27, 2006, at 06:57 AM
by --
Changed lines 192-197 from:
(:tableend:) to:
(:tableend:) References:
March 27, 2006, at 04:36 AM
by -- php-fcgi in the feed now
Deleted lines 12-13:
Note, php-fcgi is currently waiting to be promoted. March 26, 2006, at 05:53 PM
by --
Changed line 6 from:
Install PHP & ```php-fcgi``` packagesto:
Install PHP & php-fcgi packagesMarch 26, 2006, at 07:14 AM
by --
Deleted line 86:
server.c:843: WARNING: Unable to set file descriptor limit to 16384 March 26, 2006, at 06:21 AM
by --
Changed line 70 from:
Handler fastcgi {
to:
Handler fcgi {
March 26, 2006, at 05:30 AM
by --
Changed line 182 from:
$ /opt/sbin/lighttpd -D -f ~/test-scgi/lighttpd-scgi.conf @] to:
$ /opt/sbin/lighttpd -D -f ~/test-php/lighttpd-php.conf @] March 26, 2006, at 05:29 AM
by --
Changed lines 6-8 from:
Install a web server with FastCGI supportInstall lighttpdto:
Install PHP & ```php-fcgi``` packagesChanged line 10 from:
to:
Changed lines 13-15 from:
Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) to:
Note, php-fcgi is currently waiting to be promoted. A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) Changed lines 20-23 from:
to:
$ cat ~/test-php/info.php@] (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> Deleted lines 25-26:
Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work. Changed lines 27-31 from:
Configure the web servercherokee(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) to:
Install a web server with FastCGI supportInstall lighttpd(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) Changed lines 33-34 from:
$ cat ~/test-php/cherokee-php.conf @] (:cellnr bgcolor=#eeeeee:) to:
(:tableend:) Or, install cherokee(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) Added lines 40-54:
(:tableend:) Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work. Configure & launching the web servercherokee(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) [@ Changed line 93 from:
Configure lighttpdto:
Or lighttpdChanged lines 178-181 from:
Install PHP packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) to:
Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) Changed line 182 from:
to:
$ /opt/sbin/lighttpd -D -f ~/test-scgi/lighttpd-scgi.conf @] Changed lines 184-185 from:
A PHP test pageto:
TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). Changed line 189 from:
(:cell bgcolor=#eeffee:) to:
(:cellnr bgcolor=#eeffee:) Changed lines 191-192 from:
$ cat ~/public_html/info.php@] (:cellnr bgcolor=#eeeeee:) to:
$ w3m -dump http://localhost:8081/info.php | less @] (:cellnr bgcolor=#eeffee:) Deleted lines 193-204:
<?php phpinfo(); ?> @] (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:cellnr bgcolor=#eeffee:) [@ March 26, 2006, at 05:23 AM
by --
Changed lines 1-2 from:
FastCGI is a protocol between web application and web server. Because it offers much much better performance than CGI, it is often used to deploy PHP web application on lightweight web servers that do not have a built-in mod_php. to:
FastCGI is a protocol between web application and web server. Because it offers much better performance than CGI, it is often used to deploy PHP web application on lightweight web servers that do not have a built-in mod_php. Changed lines 22-23 from:
Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work. to:
Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work. Added lines 34-47:
Port 8082 IPv6? Off Timeout 60 KeepAlive? On MaxKeepAliveRequests? 500 ServerTokens? Full PidFile? /home/mylogin/tmp/cherokee.pid Icons /opt/etc/cherokee/icons.conf MimeFile? /opt/etc/cherokee/mime.types MimeFile? /opt/etc/cherokee/mime.compression.types Include /opt/etc/cherokee/advanced.conf Include /opt/etc/cherokee/mods-enabled Documentroot /home/mylogin/test-php DirectoryIndex? index.html Changed lines 51-53 from:
Env PHP_FCGI_MAX_REQUESTS "5000"
Env PHP_FCGI_CHILDREN "5"
Interpreter "/opt/lib/cgi-bin/php5-fcgi -b 8002"
to:
Env PHP_FCGI_MAX_REQUESTS "4000"
Env PHP_FCGI_CHILDREN "4"
Interpreter "/opt/bin/php-fcgi -b 8002"
March 26, 2006, at 05:19 AM
by --
Changed line 27 from:
Configure lighttpdto:
cherokeeChanged line 31 from:
$ cat ~/test-scgi/lighttpd-scgi.conf @] to:
$ cat ~/test-php/cherokee-php.conf @] Added lines 34-64:
Extension php, php3, php4, php5 { Handler fastcgi {
Server localhost:8002 {
Env PHP_FCGI_MAX_REQUESTS "5000"
Env PHP_FCGI_CHILDREN "5"
Interpreter "/opt/lib/cgi-bin/php5-fcgi -b 8002"
}
}
}@] (:tableend:) Launch it. (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ /opt/sbin/cherokee -C ~/test-php/cherokee-php.conf (:cellnr bgcolor=#eeeeee:) server.c:843: WARNING: Unable to set file descriptor limit to 16384 Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled IPv6 disable, using poll, 1024 fds limit, 5 threads, 204 fds in each standard scheduling policy (:tableend:) Configure lighttpd(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ cat ~/test-php/lighttpd-php.conf (:cellnr bgcolor=#eeeeee:) [@ Deleted lines 142-143:
Or, configure cherokeeAdded lines 168-170:
(:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8082/info.php | less March 26, 2006, at 04:56 AM
by --
Changed lines 6-7 from:
Install a web server with FastCGI supportto:
Install a web server with FastCGI supportChanged lines 28-34 from:
Or, configure cherokeeInstall PHP packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) to:
(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) Changed lines 31-36 from:
(:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) to:
$ cat ~/test-scgi/lighttpd-scgi.conf @] (:cellnr bgcolor=#eeeeee:) Changed lines 34-39 from:
$ cat ~/public_html/info.php@] (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> to:
server.port = 8081 server.modules = ( "mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/home/mylogin/test-php" server.errorlog = "/home/mylogin/test-php/error.log" accesslog.filename = "/home/mylogin/test-php/access.log" index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" ) mimetype.assign = ( ".pdf" => "application/pdf", ".sig" => "application/pgp-signature", ".spl" => "application/futuresplash", ".class" => "application/octet-stream", ".ps" => "application/postscript", ".torrent" => "application/x-bittorrent", ".dvi" => "application/x-dvi", ".gz" => "application/x-gzip", ".pac" => "application/x-ns-proxy-autoconfig", ".swf" => "application/x-shockwave-flash", ".tar.gz" => "application/x-tgz", ".tgz" => "application/x-tgz", ".tar" => "application/x-tar", ".zip" => "application/zip", ".mp3" => "audio/mpeg", ".m3u" => "audio/x-mpegurl", ".wma" => "audio/x-ms-wma", ".wax" => "audio/x-ms-wax", ".ogg" => "application/ogg", ".wav" => "audio/x-wav", ".gif" => "image/gif", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".png" => "image/png", ".xbm" => "image/x-xbitmap", ".xpm" => "image/x-xpixmap", ".xwd" => "image/x-xwindowdump", ".css" => "text/css", ".html" => "text/html", ".htm" => "text/html", ".js" => "text/javascript", ".asc" => "text/plain", ".c" => "text/plain", ".cpp" => "text/plain", ".log" => "text/plain", ".conf" => "text/plain", ".text" => "text/plain", ".txt" => "text/plain", ".dtd" => "text/xml", ".xml" => "text/xml", ".mpeg" => "video/mpeg", ".mpg" => "video/mpeg", ".mov" => "video/quicktime", ".qt" => "video/quicktime", ".avi" => "video/x-msvideo", ".asf" => "video/x-ms-asf", ".asx" => "video/x-ms-asf", ".wmv" => "video/x-ms-wmv", ".bz2" => "application/x-bzip", ".tbz" => "application/x-bzip-compressed-tar", ".tar.bz2" => "application/x-bzip-compressed-tar" ) fastcgi.server = ( ".php" => ( "localhost" =>
(
"socket" => "/home/mylogin/test-php/php-fastcgi.socket",
"bin-path" => "/opt/bin/php-fcgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "4000"
)
)
)
)
@] Added lines 111-113:
Or, configure cherokeeChanged lines 115-139 from:
Testto:
Install PHP packages(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) # ipkg install php php-fcgi (:tableend:) A PHP test page(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) $ cat ~/public_html/info.php (:cellnr bgcolor=#eeeeee:) <?php phpinfo(); ?> (:tableend:) TestHere I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly). (:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) $ w3m -dump http://localhost:8081/info.php | less (:tableend:) March 26, 2006, at 02:48 AM
by --
Added line 45:
[@ March 26, 2006, at 02:47 AM
by --
Changed lines 40-41 from:
(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) to:
(:table border=0 width=80%:) (:cell bgcolor=#eeffee:) Changed lines 43-44 from:
$ cat ~/public_html/info.php to:
$ cat ~/public_html/info.php@] (:cellnr bgcolor=#eeeeee:) March 26, 2006, at 01:13 AM
by --
Changed line 12 from:
ipkg install lighttpd @] to:
Changed line 19 from:
ipkg install cherokee@] to:
Changed line 36 from:
ipkg install php php-fcgi @] to:
March 26, 2006, at 01:12 AM
by --
Changed lines 21-22 from:
Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work. to:
Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work. Changed lines 40-47 from:
to:
(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) $ cat ~/public_html/info.php <?php phpinfo(); ?> (:tableend:) March 26, 2006, at 01:04 AM
by --
Changed lines 6-7 from:
Install a web server with FastCGI supportto:
Install a web server with FastCGI supportChanged lines 32-36 from:
to:
(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) ipkg install php php-fcgi (:tableend:) March 26, 2006, at 01:03 AM
by --
Changed lines 21-22 from:
Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI? problems. Version earlier than this probably does not work. to:
Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work. March 26, 2006, at 01:01 AM
by --
Changed lines 21-22 from:
to:
March 26, 2006, at 12:54 AM
by --
Changed lines 12-13 from:
ipkg install lighttpd @] to:
ipkg install lighttpd @] Changed lines 19-20 from:
ipkg install cherokee @] to:
ipkg install cherokee@] March 26, 2006, at 12:54 AM
by --
Changed lines 9-10 from:
(:table border=0 width=80% bgcolor=#eeffee:)(:cell:) to:
(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) Changed lines 17-18 from:
(:table border=0 width=80% bgcolor=#eeffee:)(:cell:) to:
(:table border=0 width=80% bgcolor=#eeffee:) (:cell:) March 26, 2006, at 12:53 AM
by --
Changed lines 9-14 from:
to:
(:table border=0 width=80% bgcolor=#eeffee:)(:cell:) ipkg install lighttpd (:tableend:) Changed lines 16-21 from:
to:
(:table border=0 width=80% bgcolor=#eeffee:)(:cell:) ipkg install cherokee (:tableend:) March 26, 2006, at 12:46 AM
by -- initial version
Added lines 1-26:
FastCGI is a protocol between web application and web server. Because it offers much much better performance than CGI, it is often used to deploy PHP web application on lightweight web servers that do not have a built-in mod_php. The example below is on unslung firmware and using optware packages. Install a web server with FastCGI supportInstall lighttpdOr, install cherokeeConfigure the web serverConfigure lighttpdOr, configure cherokeeInstall PHP packagesA PHP test pageTest
view ·
edit ·
print ·
history ·
Last edited by frater.
Based on work by slugmanbashi, John804, drno, John1613, pembo, John1391, John1127, ByronT, John1300, John1308, John1446, John565, John1544, John631, thx1011, Viktor K, Platypen, Jason, Jim, BrianZhou, J Brown, JBrown, florent, fcarolo, patrick, jared hansen, case, RobHam, Rupert Plumridge, Marc, Crazyman, crazyman, rvanderh3, janne5011, Brian Zhou, and bzhou. Originally by bzhou. Page last modified on October 28, 2009, at 05:01 PM
|