PHP, Node.js & Python Configuration

How to Set Correct doc_root in cPanel PHP-FPM to Eliminate FastCGI Errors

By the Domain India teamPublished 9 min read
Knowledge base article
Contents (7 sections)

AH01071: Got error 'Primary script unknown' is Apache telling you that PHP-FPM was asked to run a PHP file it could not find. The page usually shows "File not found." or a 404 or 5xx error instead of your site. The cause is either a file or folder that isn't where the server expects it, or, on a server you run yourself, a PHP-FPM pool with a wrong or empty doc_root. This guide covers what you can check on shared hosting, and how to fix the pool on your own cPanel server.

Key takeaways

On Domain India shared hosting, PHP-FPM pools are created and managed by us, so you can't edit them. Check that the file exists in your domain's document root (cPanel › Domains shows it), that the folder name matches exactly, and that .htaccess has no leftover PHP handler lines from an old host. Read the path in Metrics › Errors. If everything is in place and the error continues, open a ticket. On your own cPanel server, find the empty doc_root in the generated pool file, fix the YAML override that caused it, and rebuild with cPanel's tools instead of editing the pool file by hand.

1. What "Primary script unknown" means

When a visitor requests a PHP page, Apache passes the request to a PHP-FPM pool, together with the full path of the script to run. PHP-FPM looks for that file. If the path points nowhere, or points outside the folder the pool is allowed to use, PHP-FPM answers "Primary script unknown" and Apache logs AH01071. A related message, AH01067: Failed to read FastCGI header, often appears when the pool fails in the middle of a request.

So the question is always: which path did PHP-FPM look for, and why isn't the file there?

2. On shared hosting: what you can check

On Domain India shared hosting, each domain's PHP-FPM pool is generated by the server and managed by us. You can't open or edit pool files, and the doc_root setting is not something you control. You can check everything around it, which is where most of these errors come from.

  1. Read the error line.
    In cPanel, open Metrics › Errors, load the failing page with ?t=test1 added to the URL, and find the matching AH01071 line. Note the path it shows.
  2. Check the document root.
    In cPanel, open Domains. Each domain shows its document root, such as public_html for the main domain or its own folder for an addon domain. Compare it with the path in the error line.
  3. Check the file exists.
    Open File Manager, go to that folder and confirm the file is there. Names are case-sensitive: Index.php is not index.php.
  4. Check recent moves.
    If you renamed or moved a site's folder, or changed an addon domain's document root, that is the most likely cause. Move the files back or tell support what you changed.
  5. Check .htaccess.
    Look for AddHandler, SetHandler or AddType lines for PHP that came from another host, and rewrite rules that send every request to a file that doesn't exist.
cPanel Domains page listing the main domain with its document root /public_html, the Force HTTPS Redirect switch, Manage and Create A New Domain buttons
cPanel Domains lists each domain with its document root.

The ?t= part matters on cPanel: our servers run nginx in front of Apache as a cache, and a cached page never reaches Apache, so it writes no log line.

Don't copy PHP handler lines from another host

Lines such as AddHandler application/x-httpd-php74 .php point Apache at a handler that doesn't exist here. On cPanel, choose your PHP version in MultiPHP Manager and let it manage the handler block in .htaccess. Also don't add php_value or php_flag lines: PHP doesn't run as an Apache module on our servers, so they give a 500 error.

3. Common causes on shared hosting and their fixes

What you findWhy it breaksWhat to do
The path in the error is an old folder nameThe site was moved or the folder renamedMove the files back, or open a ticket saying what changed
The file isn't in the document rootUploaded to the wrong folder, or deletedUpload it to the folder shown in cPanel › Domains
A rewrite rule sends all requests to index.php, but there is noneThe app's front controller is missingRestore the app's index.php from your backup or the app's download
An old AddHandler or SetHandler line for PHPIt points at a handler this server doesn't haveRemove it and set the version in MultiPHP Manager
The error started with no change on your sidePossibly a server-side pool issueOpen a ticket with the details in section 4

If files are missing after an accident, JetBackup in your control panel keeps weekly backups that you can restore from. See how to download a backup of your site.

On DirectAdmin, the same checks apply: the site's files live in domains/yourdomain.com/public_html, and DirectAdmin runs PHP through PHP-FPM too. For reading logs on both panels, see reviewing error logs in cPanel and DirectAdmin.

4. When to open a ticket

If the file is where it should be, the document root is right and .htaccess is clean, the pool itself may need regenerating, which only we can do on shared hosting. Open a ticket at /client/support/new when logged in, or /support/ticket, with:

  • the domain and the full URL that fails;
  • the date and time you last reproduced it;
  • the AH01071 line from Metrics › Errors;
  • anything you changed recently, such as a moved folder, a new PHP version or a restored backup.

Support is on 24/7 live chat, and tickets get a first response within 15 minutes.

5. On your own cPanel server: find the empty doc_root

This section applies only to a cPanel and WHM server where you have root access. A Domain India VPS is self-managed and comes without cPanel.

cPanel writes one pool file per domain under /opt/cpanel/ea-phpXX/root/etc/php-fpm.d/, generated from its own defaults plus any YAML overrides. If the doc_root value in that file is empty or wrong, PHP-FPM rejects scripts. Compare what cPanel thinks the document root is with what the pool contains (replace the user, domain and PHP version):

bash
grep -i documentroot /var/cpanel/userdata/exampleuser/example.com
grep -n doc_root /opt/cpanel/ea-php83/root/etc/php-fpm.d/example.com.conf

If the pool shows doc_root = "" or an old path, find the override that put it there:

bash
grep -rn doc_root /var/cpanel/ApachePHPFPM/ /var/cpanel/userdata/exampleuser/ 2>/dev/null

Look especially at the domain's own example.com.php-fpm.yaml in the user's userdata folder, and at any system-wide pool defaults or overrides under /var/cpanel/ApachePHPFPM/. A domain-level file takes precedence over system-wide settings.

6. On your own cPanel server: fix and rebuild

  1. Fix the source, not the output.
    Correct or remove the doc_root entry in the YAML file that set it, so that cPanel uses the domain's real document root. Check cPanel's PHP-FPM documentation for the exact key format your version expects.
  2. Keep the domain on PHP-FPM.
    Don't remove the _is_present line from a domain's .php-fpm.yaml; it marks the domain as using PHP-FPM.
  3. Rebuild the pool files.
    Run /scripts/php_fpm_config --rebuild.
  4. Restart PHP-FPM.
    Run /scripts/restartsrv_apache_php_fpm, then reload Apache.
  5. Check the result.
    Run the grep -n doc_root command again and confirm the path is right, then watch the log with tail -f /etc/apache2/logs/error_log while you load the site.
Never edit the generated pool file by hand

cPanel rewrites the files in php-fpm.d whenever it rebuilds pools, for example after an update, a PHP version change or a domain change. A manual edit there works until the next rebuild, then the error returns. Always change the YAML override and rebuild.

If the error continues after a clean rebuild, check the other usual causes on your own server: a document root folder that was deleted, an open_basedir value that excludes the site's folder, symlinks that Apache's SymLinksIfOwnerMatch refuses to follow, and conflicting settings in the SSL-specific configuration for the domain. As a last resort, switch the domain off PHP-FPM in WHM › MultiPHP Manager, rebuild, and switch it back on.

For PHP-FPM setup and pool sizing on your own cPanel server, see mastering PHP-FPM in cPanel.

7. Where Domain India fits

On our cPanel hosting, PHP-FPM pools are created and maintained for you, and you choose each domain's PHP version in MultiPHP Manager. If you want to manage PHP-FPM yourself, a VPS gives you root access; it is self-managed and you install the stack you want.

cPanel Starter
₹125/mo + GST
  • 25 GB NVMe SSD Storage
  • 50 GB Monthly Bandwidth
  • 1 Website
  • 10 Email Accounts
See plan details
VPS Starter
₹552.65/mo + GST
  • 1 vCPU
  • 2 GB DDR4 RAM
  • 64 GB NVMe SSD Storage
  • 2 TB Monthly Bandwidth
See plan details
What causes "Primary script unknown" in Apache?

PHP-FPM was asked to run a PHP file it could not find. Usually the file isn't in the domain's document root, a folder was moved or renamed, a rewrite rule points to a missing file, or on a self-managed server the PHP-FPM pool's doc_root is empty or wrong.

Can I edit my domain's PHP-FPM pool on Domain India shared hosting?

No. Pools are generated and managed by us for every domain. You can change the PHP version in MultiPHP Manager and PHP settings in MultiPHP INI Editor or .user.ini, and open a ticket if the pool itself needs attention.

How do I find my domain's document root in cPanel?

Open Domains in cPanel. Each domain is listed with its document root, such as public_html for the main domain or a separate folder for an addon domain.

Where do I see the AH01071 error?

In cPanel, open Metrics › Errors after reproducing the problem. Add a query string such as ?t=test1 to the URL so the request reaches Apache and is logged.

Can I fix it by adding php_value lines to .htaccess?

No. PHP doesn't run as an Apache module on our servers, so php_value and php_flag lines give a 500 error. Use MultiPHP INI Editor or .user.ini for PHP settings.

On my own cPanel server, can I just edit the pool .conf file?

You can, but cPanel overwrites it at the next rebuild. Fix the YAML override that set the wrong doc_root, then run /scripts/php_fpm_config --rebuild and restart PHP-FPM.

Ready to get your site running? Check your document root and error log, then open a support ticket with the details if the error continues. Running your own server? Compare VPS plans.

Still seeing Primary script unknown?

Send us the domain, the failing URL, the time and the error line, and we will check the PHP-FPM setup for your site.

Open a support ticket

Ready when you are

Get cPanel hosting from ₹125/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Fix "Primary Script Unknown" in PHP-FPM | Domain India