Welcome! Log In Create A New Profile

Advanced

Re: PHP and CGI on UserDir

Smart Goldman
December 02, 2015 08:06AM
Hi Francis,

2015-12-02 5:50 GMT+09:00 Francis Daly <francis@daoine.org>:
> On Wed, Dec 02, 2015 at 01:52:06AM +0900, Smart Goldman wrote:
>> 2015-11-29 20:10 GMT+09:00 Francis Daly <francis@daoine.org>:
>> > On Sun, Nov 29, 2015 at 05:04:50PM +0900, Smart Goldman wrote:
>
> Hi there,
>
>> location ~ ^/~(.+?)(/.*)?\.(php)$ {
>> alias /home/$1/public_html$2.$3;
>> fastcgi_pass 127.0.0.1:9000;
>> fastcgi_index index.php;
>
> Delete that line - it does nothing useful here. (It does no harm, other
> than being a distraction.)
>
>> fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
>
> Change that line to be just
>
> fastcgi_param SCRIPT_FILENAME $document_root;
>
> "alias" is a bit funny. In this context, it means that $document_root
> corresponds to the file on the filesystem that you want the fastcgi
> server to process.
>
> I'm a bit surprised that the current version works -- perhaps your php
> config does not have
>
> cgi.fix_pathinfo=0

This value is commented out.
$ grep cgi.fix_pathinfo php.ini
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for
CGI. PHP's
;cgi.fix_pathinfo=1
I've never edited php.ini.

> and so takes more than one guess at the file to process.
>
>> include /etc/nginx/fastcgi_params;
>> }
>>
>> location ~ ^/~(.+?)(/.*)?\.(pl|cgi)$ {
>> alias /home/$1/public_html$2.$3;
>> fastcgi_pass 127.0.0.1:8999;
>> fastcgi_index index.cgi;
>
> Delete.
>
>> fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
>
> Change to remove $fastcgi_script_name, just like the previous case.
>
> Here, most likely php is not involved, and your fastcgi server just tries
> to process SCRIPT_FILENAME, which does not name a real file right now.
>
>> include /etc/nginx/fastcgi_params;
>> }
>
>> After that, I restarted nginx. Looks like PHP (/~user/index.php) finally
>> works!
>> But CGI (/~user/index.cgi) says "Error: No such CGI app -
>> /home/user/public_html/index.cgi/~user/index.cgi may not exist or is not
>> executable by this process." though I don't know why.
>
> I think that the explanations are above, along with the one necessary fix
> (for cgi/pl) and the one strongly suggested fix (for php).
>
> Good luck with it,

Great!! Both of CGI and PHP finally works!!
I made configuration file by copying from configuration file which I found
from somewhere and I did not understand what fastcgi_param means.
Thanks so much for your help!

I put successful configuration here again for future use.

/etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;

location / {
root /var/www/html;
index index.html index.htm;
}

location ~ ^/~(.+?)(/.*)?\.(php)$ {
alias /home/$1/public_html$2.$3;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root;
include /etc/nginx/fastcgi_params;
}

location ~ ^/~(.+?)(/.*)?\.(pl|cgi)$ {
alias /home/$1/public_html$2.$3;
fastcgi_pass 127.0.0.1:8999;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root;
include /etc/nginx/fastcgi_params;
}

location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
index index.html index.htm;
autoindex on;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

location ~ \.php$ {
root /var/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~ \.pl|cgi$ {
root /var/www/html;
fastcgi_pass 127.0.0.1:8999;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

PHP and CGI on UserDir

Smart Goldman November 29, 2015 03:06AM

Re: PHP and CGI on UserDir

Anoop Alias November 29, 2015 03:30AM

Re: PHP and CGI on UserDir

Smart Goldman November 29, 2015 04:14AM

Re: PHP and CGI on UserDir

Aleksandar Lazic November 29, 2015 04:42AM

Re: PHP and CGI on UserDir

Smart Goldman November 29, 2015 06:04AM

Re: PHP and CGI on UserDir

Aleksandar Lazic November 30, 2015 11:48AM

Re: PHP and CGI on UserDir

Francis Daly November 29, 2015 06:12AM

Re: PHP and CGI on UserDir

Smart Goldman December 01, 2015 11:54AM

Re: PHP and CGI on UserDir

Francis Daly December 01, 2015 03:52PM

Re: PHP and CGI on UserDir

Smart Goldman December 02, 2015 08:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 293
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready