Установка Веб сервера на основе Nginx HTTP Server + PHP5 (With fast-cgi And xcache) On Ubuntu Feisty Fawn
Код:
apt-get install php5-cli php5-cgi php5-xcache build-essential
далее добавлеем следующие строки в php.ini , в директории /etc/php5/cgi/
[xcache-common]
extension = xcache.so
[xcache.admin]
xcache.admin.user = "mOo"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = ""
[xcache]
; ini only settings, all the values here is default unless explained
; select low level shm/allocator scheme implemenation
xcache.shm_scheme = "mmap"
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows
xcache.size = 64M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count = 1
; just a hash hints, you can always store count(items) > slots
xcache.slots = 8K
; ttl of the cache item, 0=forever
xcache.ttl = 0
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval = 0
; same as aboves but for variable cache
xcache.var_size = 64M
xcache.var_count = 1
xcache.var_slots = 8K
; default ttl
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
; N/A for /dev/zero
xcache.readonly_protection = Off
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection
; 2 group of php won't share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path
xcache.mmap_path = "/dev/zero"
; leave it blank(disabled) or "/tmp/phpcore/"
; make sure it's writable by php (without checking open_basedir)
xcache.coredump_directory = ""
; per request settings
xcache.cacher = On
xcache.stat = On
xcache.optimizer = On
[xcache.coverager]
; per request settings
; enable coverage data collecting for xcache.coveragedump_directory and xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)
xcache.coverager = Off
; ini only settings
; make sure it's readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On
xcache.coveragedump_directory = ""
Теперь устанавливаем сам Nginx
Код:
sudo apt-get install nginx
затем запускаем редоктор и правим конфиг nginx
Код:
vim /etc/nginx/sites-available/default
раскоментируем следущие строки и добавим следующие
Код:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
fcgi будет слушать на порту 9000
Теперь нам будет нужет spawn-fcgi возмём его из lighttpd
Код:
wget http://www.lighttpd.net/download/lighttpd-1.4.19.tar.gz
Для нормальной компиляции lighttpd на убунту нам будет нужно так же установить следущие компоненты :
Код:
sudo apt-get install libpcre3-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libglib2.0-dev
sudo apt-get install libbz2-dev
затем переходим к распаковке и компиляции
lighttpd
Код:
tar -xvjf lighttpd-1.4.19.tar.bz2
После :
Код:
cp src/spawn-fcgi /usr/bin/spawn-fcgi
Создами файл
Код:
touch /usr/bin/php-fastcgi
Отредктируем его внеся следующие строки
Код:
vim /usr/bin/php-fastcgi
#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -f /usr/bin/php5-cgi
Так же нужно создать init скрипт
Код:
touch /etc/init.d/init-fastcgi
Отредактируем его и добавим эти строки
Код:
vim /etc/init.d/init-fastcgi
#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case "$1" in
start)
$PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php
RETVAL=$?
;;
restart)
killall -9 php
$PHP_SCRIPT
RETVAL=$?
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
Так же нужно выставить на него права
Код:
chmod 755 /etc/init.d/init-fastcgi
В мануале не указано , но права так же нужно выставить и на
Код:
chmod 755/usr/bin/php-fastcgi
Так , теперь вроде всё норм , стартуем
Код:
sudo /etc/init.d/init-fastcgi start
если всё сделано правельно , то после старта мы должны увидеть это
Код:
spawn-fcgi.c.197: child spawned successfully: PID: 14806
Проверим как всё работает
Код:
update-rc.d init-fastcgi defaults
Результат дожен быть такой
Adding system startup for /etc/init.d/init-fastcgi ...
/etc/rc0.d/K20init-fastcgi -> ../init.d/init-fastcgi
/etc/rc1.d/K20init-fastcgi -> ../init.d/init-fastcgi
/etc/rc6.d/K20init-fastcgi -> ../init.d/init-fastcgi
/etc/rc2.d/S20init-fastcgi -> ../init.d/init-fastcgi
/etc/rc3.d/S20init-fastcgi -> ../init.d/init-fastcgi
/etc/rc4.d/S20init-fastcgi -> ../init.d/init-fastcgi
/etc/rc5.d/S20init-fastcgi -> ../init.d/init-fastcgi
чёкнем php
Так всё норм !!!
создадим на сервера в папке nginx-default файл test.php
Рулим на сервер http://ваш_ip/test.php
Результат должен быть такой
источник http://www.howtoforge.com/nginx_php5_fast_cgi_xcache_ubuntu7 .04
(c)stopxaker.ru