Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   *nix системы (https://forum.antichat.xyz/forumdisplay.php?f=124)
-   -   Nginx HTTP Server + PHP5 (With fast-cgi And xcache) On Ubuntu Feisty Fawn (https://forum.antichat.xyz/showthread.php?t=90359)

Belfigor 04.11.2008 06:46

Nginx HTTP Server + PHP5 (With fast-cgi And xcache) On Ubuntu Feisty Fawn
 
Установка Веб сервера на основе 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
Код:

cd lighttpd-1.4.19
Код:

./configure
Код:

make
После :

Код:

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
Код:

ps ax | grep php
Так всё норм !!! :)


создадим на сервера в папке nginx-default файл test.php



Код:

<?php

phpinfo();

?>

Рулим на сервер http://ваш_ip/test.php



Результат должен быть такой

http://keep4u.ru/imgs/b/081104/cf/cf...26e265e6d5.jpg



источник http://www.howtoforge.com/nginx_php5_fast_cgi_xcache_ubuntu7 .04


(c)stopxaker.ru

Ky3bMu4 04.11.2008 16:46

1) Зачем lighttpd собирать из сорцев, если он в репозитарии есть ?
2) В php.ini нужно open_basedir подправить, чтоб php-cgi скрипты видел(проверено на собственном опыте)

Belfigor 04.11.2008 21:30

Цитата:

Сообщение от Ky3bMu4
1) Зачем lighttpd собирать из сорцев, если он в репозитарии есть ?
2) В php.ini нужно open_basedir подправить, чтоб php-cgi скрипты видел(проверено на собственном опыте)

А мне нравиться из сорцов собирать :) тем более можно сразу последнею версию с офсайта скачать .


Время: 18:49