Обсуждение статьи тематического каталога: Настройка связки Nginx, PHP и Spawn-fcgi (nginx cgi fastcgi php freebsd)Ссылка на текст статьи: http://www.opennet.me/base/net/nginx_php_spawn_fcgi.txt.html
Буду рад почитать, сравнить с тем как сделано у нас, возможно родятся какие-то интересные предложения или улучшения. Еще бы рассмотреть в такой статье memcached!
А если вместо spawn-fcgi использовать php-fpm? (http://php-fpm.anight.org/) Просто у меня что-то больно нестабильно работало со spawn-fcgi от Lighthttpd...
Лучше использовать такой скрипт запуска Spawn:#!/bin/sh
# Define these fcgiphp_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
fcgiphp_enable=${fcgiphp_enable-"NO"}
fcgiphp_flags=${fcgiphp_flags-"-s /tmp/php-fcgi.sock -u www -g www"}. /etc/rc.subr
name="fcgiphp"
rcvar=`set_rcvar`
command="/usr/local/bin/spawn-fcgi"
fcgi_server="/usr/local/bin/php-cgi"
fcgi_server_short="php-cgi"load_rc_config $name
start_cmd="echo \"Starting ${name}.\"; ${command} -f ${fcgi_server} ${fcgiphp_flags}"
stop_cmd="echo \"Stopping ${name}.\"; while [ 1 ]; do killall ${fcgi_server_short} || break; done"run_rc_command "$1"
А в конфиге nginx'a сделать так:location ~ \.php$ {
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx$fastcgi_script_name;
include fastcgi_params;
}
на выполнение команды /usr/local/etc/rc.d/spawn-php.sh фришка постоянно отвечает command not found.. помогите разобраться.. делаю все точь в точь по мануалу
Да у меня такая же проблема , хотя тоже делаю всё по мануалу !!/usr/local/etc/rc.d/spawn-php.sh command not found
Помогите пожалуйста !!
> слегка подправим /usr/local/etc/rc.d/spawn-php.sh
>
> #!/usr/local/bin/bashВозможно проблема в этом заголовке, то ли вы его не прописали, то ли прописали да не правильно. Попробуйте поставить
#!/bin/bash
точно в файле /usr/local/etc/rc.d/spawn-php.sh изменить с
#!/bin/bash
на
#!/usr/local/bin/bash
как написал аффтар)
что в лоб что полбу , один фиг command not found , уже все перелопатил ! :(((
>command not foundнадо простаканить bash :)
привет у меня проблема с nginx,nginx скачивает php файлы.у меня сервер под cent OS 6.3. я использую webmin.вот это config файл :
#user nginx nginx;
user apache;
worker_processes 3;
worker_rlimit_nofile 8192;error_log /var/log/nginx/error_log info;
events {
worker_connections 2048;
use epoll;
}http {
include /etc/nginx/mime.types;
default_type application/octet-stream;log_format main
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';log_format apache
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent"';access_log /var/log/nginx/access_log apache; # buffer=32k;
client_header_timeout 10;
client_body_timeout 10;
send_timeout 30;
keepalive_timeout 40 20;connection_pool_size 256; # 8192;
client_header_buffer_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
## Compression ##
gzip on;
gzip_comp_level 4;
gzip_min_length 1100;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; # text/plain
gzip_buffers 16 8k;output_buffers 8 32k;
## Performance ##
sendfile off; # on;
tcp_nopush on;
tcp_nodelay on;
postpone_output 0; # 1460;
## Security ##
# server {
# server_name _;
# return 444;
# }
server_tokens off;
ignore_invalid_headers on;
server_name_in_redirect off;limit_zone myzone $binary_remote_addr 10m;
proxy_cache_path /dev/shm/cache levels=1:2 keys_zone=pcache:500m max_size=550m inactive=600m;
proxy_temp_path /dev/shm/tmp;upstream backpool_g {
server ww.my_site_name.com:80 max_fails=0;
}server {
limit_conn myzone 10;listen 8088;
server_name default;client_max_body_size 3m;
# Only allow
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 444;
}location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}## Proxy setup
proxy_ignore_headers Expires;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
proxy_hide_header Set-Cookie;proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 5;
proxy_send_timeout 10;
proxy_read_timeout 15;
proxy_redirect off;
proxy_cache_use_stale error timeout updating;# proxy_cache_key "$scheme$proxy_host$request_uri$slangu";
proxy_cache_min_uses 1;
proxy_cache_valid 200 301 302 5m;
# proxy_cache_valid 404 1m;
#
root /home/my_site_name/public_html;
index index.php index.html index.htm;# don't cache but all proxy cmsadmin files
# location /cmsadmin {
# client_max_body_size 16m;
# proxy_pass http://backpool_g;
# proxy_redirect off;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# }# cache for a while jpg,png,etc..
#
location ~* \./(jpg|png|gif|css|js|swf|flv|ico)$ {
expires 30d;
}location / {
try_files $uri $uri/ @handler;
expires 30d;
}# this will catch everything that is not acctually a file but is not ending with php i say cache it and serve it hot
location @handler {proxy_pass http://backpool_g;
proxy_cache pcache;
}
location ~ ^/(index|psql)\.php {# rewrite ^/articleid/(.*)$ /article.php?id=$1;
# rewrite ^/newsid/(.*)$ /index.php?newsid=$1;# if ($http_cookie ~* "lang=(.*)" ) {
# set $slangu $1;
# }
proxy_pass http://backpool_g;
proxy_cache pcache;}
location ~ \.php$ {if (!-e $request_filename) {
rewrite / /index.php last;
}proxy_pass http://backpool_g;
# proxy_pass http://localhost:82;
}
}
# server {
# listen 127.0.0.1;
# server_name localhost;# access_log /var/log/nginx/localhost.access_log main;
# error_log /var/log/nginx/localhost.error_log info;# root /var/www/localhost/htdocs;
# }# SSL example
#server {
# listen 127.0.0.1:443;
# server_name localhost;# ssl on;
# ssl_certificate /etc/ssl/nginx/nginx.pem;
# ssl_certificate_key /etc/ssl/nginx/nginx.key;# access_log /var/log/nginx/localhost.ssl_access_log main;
# error_log /var/log/nginx/localhost.ssl_error_log info;# root /var/www/localhost/htdocs;
#}
server_names_hash_bucket_size 128;
server {
server_name my_site_name.com www.my_site_name.com;
listen 192.168.1.34;
root /home/my_site_name/public_html;
access_log /var/log/virtualmin/my_site_name.com_access_log;
error_log /var/log/virtualmin/my_site_name.com_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/my_site_name/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/my_site_name/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
location = \.php$ {
try_files $uri =404;
fastcgi_pass localhost:9000;
root /home/my_site_name/public_html/;
}
}
}
help me plz
привет у меня проблема с nginx,nginx скачивает php файлы.у меня сервер под cent OS 6.3. я использую webmin.вот это config файл :
#user nginx nginx;
user apache;
worker_processes 3;
worker_rlimit_nofile 8192;error_log /var/log/nginx/error_log info;
events {
worker_connections 2048;
use epoll;
}http {
include /etc/nginx/mime.types;
default_type application/octet-stream;log_format main
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';log_format apache
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent"';access_log /var/log/nginx/access_log apache; # buffer=32k;
client_header_timeout 10;
client_body_timeout 10;
send_timeout 30;
keepalive_timeout 40 20;connection_pool_size 256; # 8192;
client_header_buffer_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
## Compression ##
gzip on;
gzip_comp_level 4;
gzip_min_length 1100;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; # text/plain
gzip_buffers 16 8k;output_buffers 8 32k;
## Performance ##
sendfile off; # on;
tcp_nopush on;
tcp_nodelay on;
postpone_output 0; # 1460;
## Security ##
# server {
# server_name _;
# return 444;
# }
server_tokens off;
ignore_invalid_headers on;
server_name_in_redirect off;limit_zone myzone $binary_remote_addr 10m;
proxy_cache_path /dev/shm/cache levels=1:2 keys_zone=pcache:500m max_size=550m inactive=600m;
proxy_temp_path /dev/shm/tmp;upstream backpool_g {
server ww.my_site_name.com:80 max_fails=0;
}server {
limit_conn myzone 10;listen 8088;
server_name default;client_max_body_size 3m;
# Only allow
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 444;
}location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}## Proxy setup
proxy_ignore_headers Expires;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
proxy_hide_header Set-Cookie;proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 5;
proxy_send_timeout 10;
proxy_read_timeout 15;
proxy_redirect off;
proxy_cache_use_stale error timeout updating;# proxy_cache_key "$scheme$proxy_host$request_uri$slangu";
proxy_cache_min_uses 1;
proxy_cache_valid 200 301 302 5m;
# proxy_cache_valid 404 1m;
#
root /home/my_site_name/public_html;
index index.php index.html index.htm;# don't cache but all proxy cmsadmin files
# location /cmsadmin {
# client_max_body_size 16m;
# proxy_pass http://backpool_g;
# proxy_redirect off;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# }# cache for a while jpg,png,etc..
#
location ~* \./(jpg|png|gif|css|js|swf|flv|ico)$ {
expires 30d;
}location / {
try_files $uri $uri/ @handler;
expires 30d;
}# this will catch everything that is not acctually a file but is not ending with php i say cache it and serve it hot
location @handler {proxy_pass http://backpool_g;
proxy_cache pcache;
}
location ~ ^/(index|psql)\.php {# rewrite ^/articleid/(.*)$ /article.php?id=$1;
# rewrite ^/newsid/(.*)$ /index.php?newsid=$1;# if ($http_cookie ~* "lang=(.*)" ) {
# set $slangu $1;
# }
proxy_pass http://backpool_g;
proxy_cache pcache;}
location ~ \.php$ {if (!-e $request_filename) {
rewrite / /index.php last;
}proxy_pass http://backpool_g;
# proxy_pass http://localhost:82;
}
}
# server {
# listen 127.0.0.1;
# server_name localhost;# access_log /var/log/nginx/localhost.access_log main;
# error_log /var/log/nginx/localhost.error_log info;# root /var/www/localhost/htdocs;
# }# SSL example
#server {
# listen 127.0.0.1:443;
# server_name localhost;# ssl on;
# ssl_certificate /etc/ssl/nginx/nginx.pem;
# ssl_certificate_key /etc/ssl/nginx/nginx.key;# access_log /var/log/nginx/localhost.ssl_access_log main;
# error_log /var/log/nginx/localhost.ssl_error_log info;# root /var/www/localhost/htdocs;
#}
server_names_hash_bucket_size 128;
server {
server_name my_site_name.com www.my_site_name.com;
listen 192.168.1.34;
root /home/my_site_name/public_html;
access_log /var/log/virtualmin/my_site_name.com_access_log;
error_log /var/log/virtualmin/my_site_name.com_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/my_site_name/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/my_site_name/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
location = \.php$ {
try_files $uri =404;
fastcgi_pass localhost:9000;
root /home/my_site_name/public_html/;
}
}
}
help me plz