Код: Выделить всё
# wget http://www.sysoev.ru/nginx/nginx-0.8.54.tar.gz
# tar -zxf nginx-0.8.54.tar.gz
# cd nginx-0.8.54
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz
# tar -zxf pcre-8.12.tar.gz
# yum install zlib-devel
# ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-pcre=pcre-8.12
# make
# make install
# cd ..
Код: Выделить всё
# yum install mysql-devel libpng-devel libjpeg-devel freetype-devel libmcrypt-devel libmcrypt openssl-devel libxml2-devel compat-libcom_err krb5-devel krb5-libs libidn-devel libtool-ltdl-devel -y
# wget http://www.php.net/get/php-5.3.5.tar.gz/from/uk.php.net/mirror
# tar -zxf php-5.3.5.tar.gz
# cd php-5.3.5
# ./configure --with-libdir=lib64 --libdir=/usr/lib64 --prefix=/usr/local/nginx/php --with-config-file-path=/usr/local/nginx/php --disable-short-tags --disable-ipv6 --disable-all --with-zlib --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-gettext --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --enable-session --with-mcrypt --with-mysql --enable-pdo --with-pdo-mysql --enable-sockets --enable-xml --enable-libxml --enable-zip --with-iconv --with-curl --with-mysqli --enable-simplexml --enable-json --enable-hash --enable-dom --enable-filter
# make
# make install
Код: Выделить всё
# wget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.bz2
# tar xvjf spawn-fcgi-1.6.3.tar.bz2
# cd spawn-fcgi-1.6.3/
# ./configure
# make
# make install
spawn-php.sh
Код: Выделить всё
#!/bin/bash
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/usr/local/bin/spawn-fcgi"
## ABSOLUTE path to the PHP binary
FCGIPROGRAM="/usr/local/nginx/php/bin/php-cgi"
## TCP port to which to bind on localhost
FCGIPORT="53217"
## number of PHP children to spawn
PHP_FCGI_CHILDREN=10
## 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.2"
# allowed environment variables, separated by spaces
ALLOWED_ENV="ORACLE_HOME PATH USER"
## if this script is run as root, switch to the following user
USERID=www
GROUPID=www
################## no config below this line
if test x$PHP_FCGI_CHILDREN = x; then
PHP_FCGI_CHILDREN=5
fi
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if test x$UID = x0; then
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN"
else
EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN"
fi
# copy the allowed environment variables
E=
for i in $ALLOWED_ENV; do
E="$E $i=${!i}"
done
# clean the environment and set up a new one
env - $E $EX
Код: Выделить всё
# groupadd -r www
# useradd -r -M -g www www
# passwd www
Создаем файл /etc/init.d/nginx следующего содержания
Код: Выделить всё
#!/bin/sh
# nginx - this script starts and stops the nginx daemin
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/nginx.conf
# pidfile: /var/run/nginx.pid
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/nginx"
prog=$(basename $nginx)
[ -e /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
echo -n $"Starting $prog: "
daemon $nginx -c /usr/local/nginx/nginx.conf
/usr/local/nginx/spawn-php.sh
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
killall -9 php-cgi
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
fdr_status() {
status $prog
}
case "$1" in
start|stop|restart|reload)
$1
;;
force-reload)
force_reload
;;
status)
fdr_status
;;
condrestart|try-restart)
[ ! -f $lockfile ] || restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
exit 2
esac
Подключаем PHP в конфиге Nginx
Код: Выделить всё
...
location ~ \.php$ {
root /www/myhost.ru;
fastcgi_pass 127.0.0.1:53217;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/myhost.ru/$fastcgi_script_name;
include fastcgi_params;
}
...
Код: Выделить всё
service nginx start
Код: Выделить всё
# wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.zip
# unzip eaccelerator-0.9.6.1.zip
# cd eaccelerator-0.9.6.1
# export PHP_PREFIX="/usr/local/nginx/php"
# $PHP_PREFIX/bin/phpize
# ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
# make
# make install
# mkdir /tmp/eaccelerator
# chmod 0777 /tmp/eaccelerator
Создаем файл /usr/local/nginx/php/php.ini и вставляем в него следующее:
Код: Выделить всё
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
Код: Выделить всё
service nginx restart
в nginx.conf в блок html вставляем
Код: Выделить всё
server_tokens off;
fastcgi_hide_header X-Powered-By;
add_header X-Powered-By "PHP";
-- добавлено 02 фев 2011, 02:15 --
добавил опции --enable-hash --enable-dom --enable-filter при сборке php - нужны для установки Drupal7