NGINX and php-cgi on Windows “No Input File Specified”

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm running php-cgi and NGINX. They are running in a folder, however their root directory is 2 directories out, and 2 in from there. When the root was html (default), they worked perfectly, however now php reports the "No Input File Specified" error. I've tried setting the directory to give full control to all programs, I already have full control, I've tried to see if php is looking in a different directory, tried changing the directories, hard coding the php variable, etc. I've followed about 5 different tutorials on how to fix this problem, but none have resolved it. There are no errors in the console and my fastcgi.conf is unchanged. php and NGINX are both definitely running and communicating, however php fails to get the file for some reason. When accessing any non-php file, NGINX successfully retrieves the file and my browser displays it. I have verified, using netstat, that the only thing listening on port 9100 is my php-cgi. And the only thing listening on port 8080 is NGINX. Both php and NGINX are configured to communicate correctly, and php-cgi is running via RunHiddenConsole.exe which is in the php directory.

Here is the directory tree, in a format similar to YAML:

EclipsePHP
    - Code
        - Blog
            - Source (NGINX/php root Location/Website Source Files)
    - NGINX
        - 1.9.11 (NGINX Executable Location)
            - php (php Executable Location)

And my nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    client_max_body_size 5G;
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        root   ../../Code/Blog/Source;
        client_max_body_size 5G;
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            index  index.php;
            try_files $uri $uri.html $uri/ @extensionless-php;
            index index.html index.htm index.php;
            client_max_body_size 5G;
        }

        error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #

        recursive_error_pages off;

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

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            client_max_body_size 5G;
            try_files      $uri =404;
            include        fastcgi.conf;
            include        fastcgi_params;
            fastcgi_pass   127.0.0.1:9100;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}

        location @extensionless-php {
             rewrite ^(.*)$ $1.php last;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

What could be the cause of this error and how can I resolve it so that I can view the php files properly in my browser? (I am using Eclipse PHP to edit the source, and the error occurs with and without Eclipse running.)

profilepic.png
manpreet 2 years ago

You define your root as a relative path, which is relative to the nginx configuration directory.

This is then passed to php-cgi, which probably does not care where nginx keeps its files. So cannot resolve ../../.

You should specify an absolute root.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.