Laravel部署报错:No input file specified问题求助
Hey there, let's work through this frustrating "No input file specified" error you're facing with your Laravel site on cPanel. This is a super common deployment hiccup, but we can nail it down with a few targeted checks:
Double-check your document root path
Head back to cPanel's Domains section, edit your main domain, and confirm the document root is pointing directly to your Laravel project'spublicfolder. For example, if your Laravel code lives in/home/yourusername/laravel-project, the path should be/home/yourusername/laravel-project/public—it's easy to miss the final/publicpart, which will break everything.Verify file permissions and existence
Use cPanel's File Manager to make sure:- The
public/index.phpfile exists (it's the entry point for Laravel) - File permissions for
index.phpare set to644 - Folder permissions for
publicand all parent directories are755
Misconfigured permissions often cause this error, especially if you uploaded files via FTP with incorrect defaults.
- The
Tweak your public/.htaccess file
Laravel's default.htaccessmight need a small adjustment for cPanel environments. Open the file inpublic/and ensure it looks like this (pay attention to the Rewrite rules):<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Send Requests To Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>If you had custom RewriteBase settings from your subdomain test, remove them—
RewriteBase /is usually all you need here.Confirm PHP version and extensions
Laravel has strict PHP version requirements (e.g., Laravel 10 needs PHP 8.1+). Go to cPanel's "Select PHP Version" tool to:- Pick a PHP version that matches your Laravel project's requirements
- Enable required extensions like
mbstring,openssl,PDO, andfileinfo
Clear Laravel's cache
Old cache files can hold onto outdated path references. If you have SSH access to your server, run these commands from your project root:php artisan cache:clear php artisan config:clear php artisan route:clearIf you don't have SSH, manually delete all files in
storage/framework/cache,storage/framework/sessions, andstorage/framework/viewsusing File Manager.Check server error logs
If none of the above works, pull up cPanel's "Error Log" tool. It will show specific details about why the input file isn't being found—this is often the fastest way to pinpoint edge cases like misconfigured virtual hosts or missing server modules.
内容的提问来源于stack exchange,提问作者Burgi

