Welcome! Log In Create A New Profile

Advanced

fastcgi location in conf and spawn-fcgi (FreeBSD)

Posted by Beeblebrox 
fastcgi location in conf and spawn-fcgi (FreeBSD)
August 06, 2013 04:21PM
Hello, My system is FreeBSD-Stable (9.2) amd64, nginx 1.5.2.. I am migrating from lighttpd and have 2 questions:

1. I have read several places (http://wiki.nginx.org/FcgiExample) that fastcgi must be started separately. However, my system has two startup scripts available in /usr/local/etc/rc.d: php-fpm and spawn-fcgi. Lighttpd was able to use spawn-fcgi but nginx is not able? What is the difference between these 2 and which one should I use (and how startup of nginx will spawn)? Unfortunately both services failto start when called (service foo onestart), but I would ike to know which one to try and debug instead of rolling the dice.

2. I have several sub-pages I want to serve and use "location" to specify the sub-folders (from what I have read in the manual/example docs). I can't seem to get the cgi location correct, so here's my partial config:

http {
include mime.types;
include fastcgi_params;
default_type application/octet-stream;
index index.html index.htm index.php;

server {
listen 127.0.0.1:80;
server_name mysys;
root /data/http;

# 1 location works
location /pub/ {
autoindex on;
}

# 2 location fails
location /sitebar/ {
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param PATH_INFO $fastcgi_script_name;
} }

If I have 5-6 more sub-folders under root, what would be the best syntax for this - something like above or the opposite like:

location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param PATH_INFO $fastcgi_script_name;

location /folder1/ {
}
location /folder2/ {
}
}

Thanks & Regards.
fastcgi location in conf and spawn-fcgi (FreeBSD)
August 07, 2013 10:04AM
I have some progress and corrections:

* I better understand some of the diferences between php-fpm and spawn-fcgi. spawn-fcgi was a left-over startup script from the older php version it seems. I am now using php-fpm with unix sockets and it's working.
* php-fpm must be -pre-started (unlike spawn-gcgi) together with nginx in order to serve php pages.
I get a lot of error output though, if anyone knows what this is all about>> Starting php_fpm.
[07-Aug-2013 16:52:30] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20121212/apc.so' - Cannot open "/usr/local/lib/php/20121212/apc.so" in Unknown on line 0
[07-Aug-2013 16:52:30] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20121212/curl.so' - Cannot open "/usr/local/lib/php/20121212/curl.so" in Unknown on line 0...

Re my Q2: If you have already defined SCRIPT_FILENAME & PATH_INFO in the nginx/fastcgi_params file, the nginx.conf file becomes very simple. Setting these under each /location becomes unnecessary, as they are already included.
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
given that directory structure is /data/http/folder1, /data/http/folder2, /data/http/folder3, etc.. the config is now:

server {
listen 127.0.0.1:80;
server_name myserver;
root /data/http;
index index.html index.htm index.php;
fastcgi_index index.php;
include fastcgi_params;

location /pub/ {
autoindex on;
}

location /sitebar {
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}

location /nm/ {
fastcgi_pass unix:/var/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $fastcgi_path_info/nmadmin/$fastcgi_script_name;
}

location /sgw {
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}

So now my question is modified as:
* Is it necessary to specify the fastcgi_pass in each location, or is it possible to define this elsewhere globally (not all sub-addresses use php)?
* location /nm does not seem to work as its index.php is one folder lower in $document_root/nm/nmadmin. I don't think my modification to SCRİPT_FILENAME is correct in that example.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 304
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready