![]() |
|
Guide Fix Primary Script Unknown PHP Errors in aaPanel - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: aaPanel (https://adminsforum.com/Forum-aapanel) +---- Forum: aaPanel Guides & Tutorials (https://adminsforum.com/Forum-aapanel-guides-tutorials) +----- Forum: aaPanel PHP & Extensions Guides (https://adminsforum.com/Forum-aapanel-php-extensions-guides) +----- Thread: Guide Fix Primary Script Unknown PHP Errors in aaPanel (/Thread-guide-fix-primary-script-unknown-php-errors-in-aapanel) |
Fix Primary Script Unknown PHP Errors in aaPanel - DEV - 10-15-2026 If a PHP page returns “File not found” and the Nginx error log says “Primary script unknown,” investigate the script path sent to PHP-FPM. Restarting PHP or raising memory limits does not correct a wrong filename. This guide follows the request from the website's document root to PHP-FPM. We reproduced a deliberate filename mismatch on a private aaPanel lab endpoint and verified recovery by correcting only that path. Other causes still need evidence from your own logs. Original AdminsForum lab evidence, presented as a formatted transcript rather than a screenshot. 1. Separate this error from other 404 responses A missing static image, an application route that does not exist and a PHP script-path error can all produce 404. The status alone cannot distinguish them. Record the exact request path, time and timezone, then check the matching error entry. In aaPanel open Website → PHP Project, locate the affected site and use Log → Error log. Check the access log for the same request. Labels may differ by panel version. Our lab site's files are: Code: /www/wwwlogs/adminslab.com.error.log
/www/wwwlogs/adminslab.com.logCode: tail -n 100 /www/wwwlogs/example.com.error.log2. Identify which PHP handler received the request Our failing error entry included: Code: FastCGI sent in stderr: "Primary script unknown"
while reading response header from upstreamThis message shows that the FastCGI handler responded with a script problem. A connection-refused or missing-socket error points to a different investigation. Do not assume a working command-line PHP binary proves the website uses that same PHP version. 3. Compare the public document root with the deployed files Open the site's directory settings and inspect the configured website root and, where applicable, its running directory. Then locate the application's intended public entry point in File Manager. For an illustrative deployment: Code: Application directory: /www/wwwroot/example.com/app
Public web directory: /www/wwwroot/example.com/app/public
Public entry point: /www/wwwroot/example.com/app/public/index.phpCheck for a moved deployment, wrong folder name, filename case mismatch, missing release or a broken symlink. Linux filenames are case-sensitive. A file you can see in one directory does not prove PHP-FPM is being told to execute that same file. 4. Trace the filename passed to PHP-FPM In a conventional Nginx root-based PHP setup, a configuration may construct the path like this: Code: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;Do not paste an extra SCRIPT_FILENAME directive on top of the panel's existing PHP include. Find the authoritative setting first. Changing a shared include can affect other websites, so back it up and understand its scope before editing anything. 5. What our isolated test proved The experiment used Nginx 1.30.5 and the installed PHP 8.5-FPM service. A separate Nginx instance listened only on loopback and accepted one exact test path. It did not alter the real website's routing.
This was a filename-mapping experiment, not a full application repair. It does not prove that your deployment has identical permissions, routing or filesystem restrictions. 6. If the path looks correct, check access and restrictions
7. Apply the smallest justified correction Back up the affected website configuration and record the current directory settings. Correct the demonstrated mismatch in the intended site scope. If an application deployment is incomplete, restore the missing release or entry point from the correct source rather than inventing a new index.php. Validate the complete Nginx configuration before applying a configuration change. If validation fails, restore the backup and investigate the reported line. Do not disable path checks or security controls as a generic repair. 8. Verify both execution and exposure Request one safe PHP page and confirm its expected content, not just status 200. Check that the error log has no new matching entry. Test an ordinary application route and a static asset, then confirm private application files remain inaccessible through the website. Remove any temporary diagnostic file you created. Avoid leaving phpinfo pages online. Keep the original configuration backup and record which path changed so you can roll back if another route breaks. Related guides Locate website logs in aaPanel Investigate PHP HTTP 500 errors Review file permissions and ownership Technical references Nginx FastCGI parameter documentation How Nginx processes requests |