yah, i'm a huge fan of cherokee. nginx is another great webserver. The thing that really makes cherokee unique though is the cheroke-admin webui. Theres nothing like it. It really makes setting up the webserver as easy as, say, setting up your router.
It's one of the fastest webservers i've seen for static content.
Another tip, for php, you should look into php-fpm
I don't really use the new version much (the newer versions can be compiled standalone)
I tend to go for the patch versions. It's partly because it's what i've been using for so long, and partly because it "feels" faster to me. Anyways, php-fpm adds a process manager to php. It's really slick stuff and it really makes php-cgi fly. I've been using it with nginx for quite some time.
anyways, it's a patch against php. The best thing to do, if you want to use php-fpm with all the same php settings you CURRENTLY have is to do this:
if you've got php installed, and you're using cherokee, set up a test.php page in your webroot with this
Code:
<?php phpinfo(); ?>
save it as test.php, then visit the page.
it should look something like this (your version may differ)
see the block that says "Configure Options"
That's the commands used to compile that version of php. Now all you need to do is download your php source code (you can get a different version but i wouldn't stil to the same major version, for example if you have 5.2.5 don't switch to 5.3.0 but you could go with 5.2.11)
download the source from here:
http://php.net/downloads.php
then get the proper php-fpm patch here:
http://php-fpm.org/downloads/
and the suhosin patch if you feel you need it (you can get away with not using it if you don't want it, it's a security feature)
http://www.hardened-php.net/hardening_patch.14.html
gather the php sources and the php-fpm patch (and the suhosin patch if you want it) in the same directory, let's call it /usr/local/src
let's say you want to go with 5.2.11. untar the source like so
Code:
tar xzfv php-5.2.11.tar.bz2
then, to apply the php-fpm patch, run this command
Code:
gzip -cd php-5.2.11-fpm-0.5.13.diff.gz | patch -d php-5.2.11/ -p1
you can use the same type of a command if you wish to apply the suhosin patch if you want it
Code:
gzip -cd suhosin-patch-5.2.11-0.9.7.patch.gz | patch -d php-5.2.11 -p1
if you did these steps right, you should see stuff like this:
Code:
(Creating file main/suhosin_logo.h...)
Patching file main/suhosin_logo.h using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -Nura php-5.2.11/main/suhosin_patch.c suhosin-patch-5.2.11-0.9.7/main/suhosin_patch.c
|--- php-5.2.11/main/suhosin_patch.c 1970-01-01 01:00:00.000000000 +0100
|+++ suhosin-patch-5.2.11-0.9.7/main/suhosin_patch.c 2009-09-18 13:34:07.000000000 +0200
--------------------------
(Creating file main/suhosin_patch.c...)
Patching file main/suhosin_patch.c using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -Nura php-5.2.11/main/suhosin_patch.h suhosin-patch-5.2.11-0.9.7/main/suhosin_patch.h
|--- php-5.2.11/main/suhosin_patch.h 1970-01-01 01:00:00.000000000 +0100
|+++ suhosin-patch-5.2.11-0.9.7/main/suhosin_patch.h 2009-09-18 13:34:07.000000000 +0200
--------------------------
(Creating file main/suhosin_patch.h...)
Patching file main/suhosin_patch.h using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -Nura php-5.2.11/main/suhosin_patch.m4 suhosin-patch-5.2.11-0.9.7/main/suhosin_patch.m4
|--- php-5.2.11/main/suhosin_patch.m4 1970-01-01 01:00:00.000000000 +0100
|+++ suhosin-patch-5.2.11-0.9.7/main/suhosin_patch.m4 2009-09-18 13:34:07.000000000 +0200
--------------------------
(Creating file main/suhosin_patch.m4...)
Patching file main/suhosin_patch.m4 using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -Nura php-5.2.11/sapi/apache/mod_php5.c suhosin-patch-5.2.11-0.9.7/sapi/apache/mod_php5.c
|--- php-5.2.11/sapi/apache/mod_php5.c 2008-12-31 12:17:49.000000000 +0100
|+++ suhosin-patch-5.2.11-0.9.7/sapi/apache/mod_php5.c 2009-09-18 13:34:07.000000000 +0200
--------------------------
Patching file sapi/apache/mod_php5.c using Plan A...
Hunk #1 succeeded at 951.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -Nura php-5.2.11/sapi/apache2filter/sapi_apache2.c suhosin-patch-5.2.11-0.9.7/sapi/apache2filter/sapi_apache2.c
|--- php-5.2.11/sapi/apache2filter/sapi_apache2.c 2008-12-31 12:17:49.000000000 +0100
|+++ suhosin-patch-5.2.11-0.9.7/sapi/apache2filter/sapi_apache2.c 2009-09-18 13:34:07.000000000 +0200
--------------------------
Patching file sapi/apache2filter/sapi_apache2.c using Plan A...
Hunk #1 succeeded at 566.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -Nura php-5.2.11/sapi/apache2handler/sapi_apache2.c suhosin-patch-5.2.11-0.9.7/sapi/apache2handler/sapi_apache2.c
|--- php-5.2.11/sapi/apache2handler/sapi_apache2.c 2008-12-31 12:17:49.000000000 +0100
|+++ suhosin-patch-5.2.11-0.9.7/sapi/apache2handler/sapi_apache2.c 2009-09-18 13:34:07.000000000 +0200
--------------------------
Patching file sapi/apache2handler/sapi_apache2.c using Plan A...
Hunk #1 succeeded at 370.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -Nura php-5.2.11/sapi/cgi/cgi_main.c suhosin-patch-5.2.11-0.9.7/sapi/cgi/cgi_main.c
|--- php-5.2.11/sapi/cgi/cgi_main.c 2009-06-09 15:29:39.000000000 +0200
|+++ suhosin-patch-5.2.11-0.9.7/sapi/cgi/cgi_main.c 2009-09-18 13:34:07.000000000 +0200
--------------------------
Patching file sapi/cgi/cgi_main.c using Plan A...
Hunk #1 succeeded at 1918 (offset 117 lines).
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -Nura php-5.2.11/sapi/cli/php_cli.c suhosin-patch-5.2.11-0.9.7/sapi/cli/php_cli.c
|--- php-5.2.11/sapi/cli/php_cli.c 2009-07-23 16:54:04.000000000 +0200
|+++ suhosin-patch-5.2.11-0.9.7/sapi/cli/php_cli.c 2009-09-18 13:34:07.000000000 +0200
--------------------------
Patching file sapi/cli/php_cli.c using Plan A...
Hunk #1 succeeded at 801.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -Nura php-5.2.11/win32/build/config.w32 suhosin-patch-5.2.11-0.9.7/win32/build/config.w32
|--- php-5.2.11/win32/build/config.w32 2009-03-13 15:39:08.000000000 +0100
|+++ suhosin-patch-5.2.11-0.9.7/win32/build/config.w32 2009-09-18 13:34:07.000000000 +0200
--------------------------
Patching file win32/build/config.w32 using Plan A...
Hunk #1 succeeded at 305.
Hunk #2 succeeded at 354.
done
without errors.
now, you should have your php sources fully patched. now all that is left to do is to take the "Configure Command" from your test-php page and add a single '--enable-fpm' to it
for example, mine looked like this before:
Code:
[Select]
'./configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--enable-fastcgi' '--with-regex=php' '--with-zend-vm=CALL' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd7.2'
and afterwards, looks like this:
Code:
[Select]
'./configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--enable-fastcgi' '--with-regex=php' '--with-zend-vm=CALL' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd7.2' '--enable-fpm'NOTE *!*!*!*!*!* Do not just copy mine, it will NOT WORK if you aren't on freebsd. your best bet, if you don't know how to configure, is to take the settings from the php test page from whatever php package your distro offers
run your new configure command inside the newly patched php directory (which should be something like /usr/local/src/php-5.2.11/ if you originally were in /usr/local/src)
now, so long as you have all the build dependencies for php, you shouldnt' run into any errors. If you DO, they are most likely common sense errors or stuff that can be solved on google. Otherwise, report them here and i'll see if i can help. anyways, if the configure passes, you just can just
Code:
make
make installwhich will install your new php, and the fpm stuff.
now, php-fpm has a pretty simple xml style config. by default, it installed to /usr/local/etc/php-fpm.conf
edit line 63 and 66 removing <-- ---> and adding in whatever user you use to run your web server. on ubuntu this is www-data, on freebsd it's www
on other systems, it may be something else
anyways, the lines should look something like this:
Code:
Unix user of processes
<value name="user">www</value>
Unix group of processes
<value name="group">www</value>
this should be the only edits you NEED to make in order to run php-fpm
now, if you're on a system when uses init.d based scripts, you can make one with the following code
Code:
#! /bin/sh
php_fpm_BIN=/usr/local/bin/php-cgi
php_fpm_CONF=/usr/local/etc/php-fpm.conf
php_fpm_PID=/usr/local/logs/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"
wait_for_pid () {
try=0
while test $try -lt 35 ; do
case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;
'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac
echo -n .
try=`expr $try + 1`
sleep 1
done
}
case "$1" in
start)
echo -n "Starting php_fpm "
$php_fpm_BIN --fpm $php_opts
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
fi
wait_for_pid created $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Shutting down php_fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -TERM `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
quit)
echo -n "Gracefully shutting down php_fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -QUIT `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reload service php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -USR2 `cat $php_fpm_PID`
echo " done"
;;
logrotate)
echo -n "Re-opening php-fpm log file "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -USR1 `cat $php_fpm_PID`
echo " done"
;;
*)
echo "Usage: $0 {start|stop|quit|restart|reload|logrotate}"
exit 1
;;
esac
or if you are on a system which used rc.d scripts, you can use this code
Code:
#!/bin/sh
# PROVIDE: phpfpm
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable php-fpm:
#
#phpfpm_enable="YES"
#
#
. /etc/rc.subr
name=phpfpm
rcvar=`set_rcvar`
command="/usr/local/sbin/php-fpm"
command_args=""
pidfile=/usr/local/logs/php-fpm.pid
required_files=/usr/local/etc/php-fpm.conf
# set defaults
phpfpm_enable=${phpfpm_enable:-"NO"}
start_cmd="phpfpm_start"
stop_cmd="phpfpm_stop"
restart_cmd="phpfpm_restart"
phpfpm_start()
{
if [ -f ${pidfile} ]
then
echo "php-fpm already running!"
exit 1;
fi
echo "Starting php-fpm server..."
/usr/local/bin/php-cgi --fpm
}
phpfpm_stop()
{
if [ ! -f ${pidfile} ]
then
echo "${name} is not running or pidfile not found!";
exit 1;
fi
echo "stopping ${name}..."
kill -SIGQUIT `cat ${pidfile}`
}
phpfpm_restart()
{
if [ ! -f ${pidfile} ]
then
echo "${name} is not running or pidfile not found!";
exit 1;
fi
echo "sending SIGUSR2 to php-fpm master"
kill -SIGUSR2 `cat ${pidfile}`
}
load_rc_config ${name}
run_rc_command "$1"
then simply making sure php-fpm is started, and changing the cherokee socket to match the one in your /usr/local/etc/php-fpm file (or vise versa)
shoudl be all you need
the thing that is so great about php-fpm is that...it totally handles spawning new php processes and killing old ones, which is something that is normally not able to be done by php, and requires outside help. it's amazingly quick, and you can even do stuff like run multiple versions of php by using different php-fpm users and changing the config file location. It's really quite amazing. I actually run my php-fpm on a unix socket, which isn't much different, just look for
Code:
<value name="listen_address">127.0.0.1:9000</value>
and change it so where ever you want the socket. I tend to make a dir in /var/run and make it owned by my web user
Code:
<value name="listen_address">/var/run/php-fpm/php.socket</value>
then change the cherokee interpreter to simply use the socket address instead