WallyJ's avatar

"No input file specified" on NGINX server in production

Symptoms:

Moved a dev Laravel site from a LAMP dev server to a run in a subdirectory on an NGINX web server on the web.

Now getting "No input file specified" in text on a white page.

I googled the issue and most answers deal with Homestead.yaml files. This is not the case for me. No homestead on dev or prod.

Ideas?

I'm sure it's a setting, and probably an NGINX issue.

By the way, a WordPress site is installed in the root of the site, and it runs fine. Just the subdirectory with the Laravel app gives me the error.

0 likes
9 replies
siangboon's avatar

is the document root or .htaccess set correctly?

Sinnbeck's avatar

Can you show your site config in nginx?

Also be careful putting it in subdirectory. That will expose your env file to the web

PS. Actually it is LNMP. A is for apache :)

WallyJ's avatar

I don't know anything about Nginx, and where to show the document root, or what I would change in the .htaccess file.

@sinnbeck , I don't know where to find a site config in nginx, and I said my dev server was LAMP, but my production is Nginx (LNMP)

Also, again, the main site is working fine. Only the subdirectory is giving me an error.

Sinnbeck's avatar

Do you have admin rights (sudo) to the server or is it shared?

WallyJ's avatar

EDITED: Also, this is my .htaccess file:


# BEGIN WordPress
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType text/html "access plus 5 minutes"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresDefault "access plus 6 hours"
</IfModule>
<ifModule mod_headers.c>
Header set X-Endurance-Cache-Level "2"
</ifModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~docuclub/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~docuclub/index.php [L]
</IfModule>
# END WordPress

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
   php_flag display_errors Off
   php_value max_execution_time 120
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 260M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
   php_value upload_max_filesize 256M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 120
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 260M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
   php_value upload_max_filesize 256M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
WallyJ's avatar

It's a VPS. So I believe I have admin rights to a certain degree.

Also, as a side note, when you go to the subdomain (which points to the subfolder), it redirects to immediately login, which works. I see app.domain.com/login in the browser URL, but still get the error.

appsol's avatar

Your .htaccess may have no impact here, depending on how the host has the server set up. Ngionx can act as a static cache proxy for Apache or it can act as a HTTP server in it's own right. You need to find your Nginx config file, which will be in JSON format, perhaps your hosts knowlege base can help? The file will look something like this:

server {
    listen 80 default_server;

    root /var/www/html/foo/public;

    index index.php index.html index.htm;

    server_name foo.com www.foo.com;

    charset utf-8;

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }

    location ~* \.(eot|otf|ttf|woff|woff2)$ {
        add_header Access-Control-Allow-Origin *;
    }

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    error_page 404 /index.php;
}

I suspect the issue may be that the public directory in Laravel is not the server root but is actually /public, see line above:

root /var/www/html/foo/public;

If this is not set correctly then Nginx will look for an entry file (index.php) in the root of Laravel, which is not where it is found.

WallyJ's avatar
WallyJ
OP
Best Answer
Level 3

Actually, I found the issue in my .htaccess.

The "RewriteBase" line was from an old hosting company with a different subfolder structure. Also the "RewriteRule" line with the directory listed needed to be updated as well. Thanks all!

Please or to participate in this conversation.