Ставим Nginx
<span style="color: magenta;">cd</span> /usr/ports/www/nginx
<span style="color: magenta;">make</span> <span style="color: teal;">install</span> <span style="color: teal;">clean</span>
|
в конфигурации выбираем следующие пункты:
[X] HTTP_MODULE
[X] HTTP_PERL_MODULE
[X] HTTP_REWRITE_MODULE
[X] HTTP_STATUS_MODULE
Ставим php-5
<span style="color: magenta;">cd</span> /usr/ports/lang/php5
<span style="color: magenta;">make</span> <span style="color: teal;">install</span> <span style="color: teal;">clean</span>
|
в конфигурации выбираем нужные вам опции и обязательно:
[X] CLI Build CLI version
[X] CGI Build CGI version
[X] REDIRECT Enable force-cgi-redirect support (CGI only)
[X] DISCARD Enable discard-path support (CGI only)
[X] FASTCGI Enable fastcgi support (CGI only)
[X] PATHINFO Enable path-info-check support (CGI only)
Ставим spawn-fcgi
<span style="color: magenta;">cd</span> /usr/ports/www/spawn-fcgi
<span style="color: magenta;">make</span> <span style="color: teal;">install</span> <span style="color: teal;">clean</span>
|
Создаем
/usr/local/etc/rc.d/<span style="color: darkblue;"><strong>fastcgi</strong></span>
#!/bin/sh
#
# fastcgi for rc.d usage (c) 2008 Andrey A. Mihayloff
# $Id$
# PROVIDE: fastcgi
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
#
## Add the following line to /etc/rc.conf to enable PHP Fast-CGI:
#
# fastcgi_enable="YES"
#
. /etc/rc.subr
name="fastcgi"
rcvar=`set_rcvar`
load_rc_config $name
: ${fastcgi_enable="NO"}
: ${fastcgi_bin_path="/usr/local/bin/php-cgi"}
: ${fastcgi_user="www"}
: ${fastcgi_group="www"}
: ${fastcgi_children="32"}
: ${fastcgi_port="9000"}
# ${fastcgi_socket="/tmp/php-fastcgi.sock"}
: ${fastcgi_socket=""}
: ${fastcgi_env="SHELL PATH USER"}
#: ${fastcgi_max_requests="200"}
#: ${fastcgi_max_ram_increase="20"}
: ${fastcgi_max_requests="100"}
: ${fastcgi_max_ram_increase="15"}
: ${fastcgi_addr="127.0.0.1"}
: ${fastcgi_hostname="mindflow.su"}
pidfile="/tmp/fastcgi.pid"
procname="${fastcgi_bin_path}"
command_args="/usr/local/bin/spawn-fcgi > /dev/null -f ${fastcgi_bin_path}
-u ${fastcgi_user} -g ${fastcgi_group} -C ${fastcgi_children} -P ${pidfile}"
start_precmd=start_precmd
stop_postcmd=stop_postcmd
start_precmd()
{
PHP_FCGI_MAX_REQUESTS="${fastcgi_max_requests}"
PHP_FCGI_MAX_RAM_INCREASE="${fastcgi_max_ram_increase}"
FCGI_WEB_SERVER_ADDRS="${fastcgi_addr}"
HOSTNAME="${fastcgi_hostname}"
export PHP_FCGI_MAX_REQUESTS
export PHP_FCGI_MAX_RAM_INCREASE
export FCGI_WEB_SERVER_ADDRS
export HOSTNAME
allowed_env="${fastcgi_env} PHP_FCGI_MAX_REQUESTS
PHP_FCGI_MAX_RAM_INCREASE FCGI_WEB_SERVER_ADDRS HOSTNAME"
copy the allowed environment variables
E=""
for i in $allowed_env; do
eval "x=$$i"
E="$E $i=$x"
done
command="env - $E"
if [ -n "${fastcgi_socket}" ]; then
command_args="${command_args} -s ${fastcgi_socket}"
elif [ -n "${fastcgi_port}" ]; then
command_args="${command_args} -p ${fastcgi_port}"
else
echo "socket or port must be specified!"
exit
fi
}
stop_postcmd()
{
rm -f ${pidfile}
# eval "ipcs | awk '{ if ($5 == "${fastcgi_user}")
print "ipcrm -s "$2}' | /bin/sh"
}
run_rc_command "$1"
|
Добавляем в /etc/rc.conf
<span style="color: magenta;"> </span>
<span style="color: magenta;"> </span>
|
Создаем index.php
<span style="color: magenta;"> </span>
echo '<? phpinfo(); ?>' >
/usr/local/www/nginx/index.<span style="color: magenta;">php</span>
<span style="color: magenta;"> </span>
chown www:www
/usr/local/www/nginx/index.<span style="color: magenta;">php</span>
|
Отредактируем конфигурационный файл nginx:
/usr/local/etc/nginx/<span style="color: darkblue;"><strong>nginx.conf</strong></span>
<span style="color: teal;">user</span> nobody;
worker_processes <strong><span style="color: darkblue;">1</span></strong>;
events {
worker_connections <strong><span style="color: darkblue;">1024</span></strong>;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout <strong><span style="color: darkblue;">65</span></strong>;
server {
listen <strong><span style="color: darkblue;">80</span></strong>;
server_name <span style="color: teal;">localhost</span>;
location / {
root /usr/local/www/nginx;
index index.<span style="color: magenta;">php</span>;
}
error_page <strong><span style="color: darkblue;">500</span></strong> <strong><span style="color: darkblue;">502</span></strong> <strong><span style="color: darkblue;">503</span></strong> <strong><span style="color: darkblue;">504</span></strong> /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
location ~ .php$ {
fastcgi_pass <strong><span style="color: darkblue;">127</span></strong>.<strong><span style="color: darkblue;">0</span></strong>.<strong><span style="color: darkblue;">0</span></strong>.<strong><span style="color: darkblue;">1</span></strong>:<strong><span style="color: darkblue;">9000</span></strong>;
fastcgi_index index.<span style="color: magenta;">php</span>;
fastcgi_param SCRIPT_FILENAME
? /usr/local/www/nginx<span style="color: green;">$fastcgi_script_name</span>;
include fastcgi_params;
}
}
}
|
/usr/local/etc/rc.d/fastcgi<span style="color: magenta;"> start</span>
/usr/local/etc/rc.d/nginx <span style="color: magenta;">start</span>
|
Статья честно стащена с сайта Лисяры и сильно отредактирована, ибо устарела чутка
Ставим spawn-fcgi
<span style="color: magenta;">cd</span> /usr/ports/www/spawn-fcgi
<span style="color: magenta;">make</span> <span style="color: teal;">install</span> <span style="color: teal;">clean</span>
Похожие записи:
- Генерация SSL-сертификатов
- Храним конфиги серверов в SVN
- Увеличение скорости пересборки FreeBSD при помощи CCACHE
- read (subshell_pty…): No such file or directory
- Настройка ntpd на FreeBSD