<div dir="ltr"><div>Hi, thank you for great help, Aleksandar Lazic.</div><div>I tried it.<br></div><div><br></div><div>PHP script shows me "File not found." and outputs the following log:</div><div>2015/11/29 05:50:15 [error] 5048#0: *6 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 119.105.136.26, server: localhost, request: "GET /~user/index.php HTTP/1.1", upstream: "fastcgi://<a href="http://127.0.0.1:9000">127.0.0.1:9000</a>", host: "<a href="http://host.domain.com">host.domain.com</a>"</div><div><br></div><div>- I do not know how to fix it...</div><div><br></div><div>CGI script shows me "Error: No such CGI app - /home//public_html/~user/index.cgi may not exist or is not executable by this process." and outputs nothing to error.log.</div><div><br></div><div>- /home//public_html/~user/... I think this path is wrong and I tried to fix this path but I could not. /home/user/public_html/ should be correct path..</div><div><br></div><div class="gmail_extra"><div class="gmail_quote">2015-11-29 18:41 GMT+09:00 Aleksandar Lazic <span dir="ltr"><<a href="mailto:al-nginx@none.at" target="_blank">al-nginx@none.at</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Smart Goldman.<span class=""><br>
<br>
Am 29-11-2015 09:04, schrieb Smart Goldman:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello. I am new here.<br>
<br>
I try to enable PHP and CGI(Perl) on UserDir (/home/user/public_html)<br>
with nginx.<br>
But on my Chrome, PHP script is downloaded and CGI script shows me "404<br>
Not Found" page.<br>
Here's my configurations. What is wrong with my configurations?<br>
</blockquote>
<br></span>
Try to use nested locations.<br>
<br>
<a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#location" rel="noreferrer" target="_blank">http://nginx.org/en/docs/http/ngx_http_core_module.html#location</a><span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
OS: Linux 3.10.0 / CentOS 7 64bit<br>
nginx version: 1.8.0<br>
<br>
----------------------------------------------<br>
/etc/nginx/conf.d/default.conf:<br>
server {<br>
    listen       80;<br>
    server_name  localhost;<br>
    access_log  /var/log/nginx/access.log;<br>
    error_log   /var/log/nginx/error.log;<br>
<br>
    #charset koi8-r;<br>
    #access_log  /var/log/nginx/log/host.access.log  main;<br>
<br>
    location / {<br>
        root   /var/www/html;<br>
        index  index.html index.htm;<br>
    }<br>
<br>
    location ~ ^/~(.+?)(/.*)?$ {<br>
        alias /home/$1/public_html$2;<br>
        index  index.html index.htm;<br>
        autoindex on;<br>
</blockquote>
<br></span>
include my_php_config.conf;<br>
<br>
include my_cgi_config.conf;<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
    }<br>
<br>
    #error_page  404              /404.html;<br>
<br>
    # redirect server error pages to the static page /50x.html<br>
    #<br>
    error_page   500 502 503 504  /50x.html;<br>
    location = /50x.html {<br>
        root   /var/www/html;<br>
    }<br>
<br></span>
    # proxy the PHP scripts to Apache listening on <a href="http://127.0.0.1:80" rel="noreferrer" target="_blank">127.0.0.1:80</a> [1]<span class=""><br>
    #<br>
    #location ~ \.php$ {<br>
    #    proxy_pass   <a href="http://127.0.0.1" rel="noreferrer" target="_blank">http://127.0.0.1</a>;<br>
    #}<br>
<br>
    # pass the PHP scripts to FastCGI server listening on <a href="http://127.0.0.1:9000" rel="noreferrer" target="_blank">127.0.0.1:9000</a><br></span>
[2]<span class=""><br>
    #<br>
    #location ~ \.php$ {<br>
    #    root           html;<br></span>
    #    fastcgi_pass   <a href="http://127.0.0.1:9000" rel="noreferrer" target="_blank">127.0.0.1:9000</a> [2];<span class=""><br>
    #    fastcgi_index  index.php;<br>
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;<br>
    #    include        fastcgi_params;<br>
    #}<br>
<br>
    location ~ (^~)*\.php$ {<br>
        root           /var/www/html;<br></span>
        fastcgi_pass   <a href="http://127.0.0.1:9000" rel="noreferrer" target="_blank">127.0.0.1:9000</a> [2];<span class=""><br>
        fastcgi_index  index.php;<br>
        fastcgi_param  SCRIPT_FILENAME<br>
$document_root$fastcgi_script_name;<br>
        include        /etc/nginx/fastcgi_params;<br>
    }<br>
    location ~ (^~)*\.pl|cgi$ {<br>
        root           /var/www/html;<br></span>
        fastcgi_pass   <a href="http://127.0.0.1:8999" rel="noreferrer" target="_blank">127.0.0.1:8999</a> [3];<span class=""><br>
        fastcgi_index  index.cgi;<br>
        fastcgi_param  SCRIPT_FILENAME<br>
$document_root$fastcgi_script_name;<br>
        include        /etc/nginx/fastcgi_params;<br>
    }<br>
</span></blockquote>
<br>
This block into "my_php_config.conf"<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
    location ~ .*~.*\.php$ {<br>
        alias /home/$1/public_html$2;<br></span>
        fastcgi_pass   <a href="http://127.0.0.1:9000" rel="noreferrer" target="_blank">127.0.0.1:9000</a> [2];<span class=""><br>
        fastcgi_index  index.php;<br>
        fastcgi_param  SCRIPT_FILENAME<br>
$document_root$fastcgi_script_name;<br>
        include        /etc/nginx/fastcgi_params;<br>
    }<br>
</span></blockquote>
END<br>
<br>
This block into "my_cgi_config.conf"<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
    location ~ .*~.*\.pl|cgi$ {<br>
        alias /home/$1/public_html$2;<br></span>
        fastcgi_pass   <a href="http://127.0.0.1:8999" rel="noreferrer" target="_blank">127.0.0.1:8999</a> [3];<span class=""><br>
        fastcgi_index  index.cgi;<br>
        fastcgi_param  SCRIPT_FILENAME<br>
$document_root$fastcgi_script_name;<br>
        include        /etc/nginx/fastcgi_params;<br>
    }<br>
</span></blockquote>
<br>
END<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    # deny access to .htaccess files, if Apache's document root<br>
    # concurs with nginx's one<br>
</blockquote>
<br></span>
BR Aleks<br>
</blockquote></div><br></div></div>