When trying custom htaccess I get proxy_fcgi:error AH01071: Got error 'Primary script unknown'

mik3ca

New member
Joined
May 31, 2026
Messages
9
I have a big problem.
Everytime I try to access my php file through mod_rewrite rules, I don't get the expected result, and apache error_log reports:

Code:
[Tue Jun 09 02:15:24.855786 2026] [proxy_fcgi:error] [pid 5122:tid 5580] [remote ip-addr:port] AH01071: Got error 'Primary script unknown'

In the past I had cPanel and apache installed with PHP as an integrated module to apache (no PHP-FPM).
Now it seems like apache wants to go through some proxy and CGI to call php scripts.

Is there away through directadmin to do away with PHP-FPM and go back to the integrated module? I believe the module name is libphp.so and php would compile this at installation time. Then it would help me do away with proxy.
 
Hello,

I believe you might better update your mod_rewrite rules. You might even share them here and probably other users will help you to modify them.
 
I attempted some troubleshooting and still get the same result. What I did was make a brand new web directory set user and group to match those in SuexecUserGroup in my virtual hosts as follows:

Code:
mkdir /web
echo '<?php phpinfo(); ?>' > /web/a.php
echo 'a' > /web/a.htm
chown admin:admin -R /web
chown admin:admin /web/a.php
chown admin:admin /web/a.htm

Then I updated /usr/local/directadmin/custombuild/custom/ap2/conf/extra/httpd-vhosts.conf to the following minus comments:

Code:
Include /etc/httpd/conf/ips.conf

<VirtualHost |IP|:|PORT_80||LINKEDIP|>
    AddHandler "proxy:unix:/run/php-fpm/php82-1004.sock|fcgi://localhost" .inc .php .phtml
    ServerAdmin webmaster@localhost
    DocumentRoot /web
    ServerName |IP|
    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    CustomLog /var/log/httpd/access_log combined
    ErrorLog /var/log/httpd/error_log
    SuexecUserGroup admin admin
</VirtualHost>

<VirtualHost |IP|:|PORT_443||LINKEDIPSSL|>
    AddHandler "proxy:unix:/run/php-fpm/php82-1004.sock|fcgi://localhost" .inc .php .phtml
    ServerAdmin webmaster@localhost
    DocumentRoot /ccweb/clubcatcher.com
    ServerName |IP|
    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    CustomLog /var/log/httpd/access_log combined
    ErrorLog /var/log/httpd/error_log
    SSLEngine on
    SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt.combined
    SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key
    SuexecUserGroup admin admin
</VirtualHost>

Then I confirmed this file exists: /run/php-fpm/php82-1004.sock with:
Code:
ls /run/php-fpm/php82-1004.sock

Then to save the changes I executed:
Code:
da build rewrite_confs

and for good measure, to make sure the server is up....
Code:
httpd -k restart

I attempt to access the following URLS where ipaddr is the public server IP address:
Code:
http://ipaddr/a.htm
https://ipaddr/a.htm
http://ipaddr/a.php
https://ipaddr/a.php

The first two URLs return the expected result of 'a' (the contents of a.htm)
But the second two URLs return the same issue. The HTTP code to the browser is 404 and the same error being logged is what's in the title.

So I ruled out my custom script to my website is NOT the issue.

How do I fix this.
 
Who is the owner of the socket /run/php-fpm/php82-1004.sock?
Who is the id 1004 owner? Why do you have PHP-FPM sockets under /run/php-fpm/ ? DirectAdmin do not store PHP-FPM sockets in the folder.
Why the document root is different for HTTP and HTTPs?
 
Who is the owner of the socket /run/php-fpm/php82-1004.sock?
Who is the id 1004 owner? Why do you have PHP-FPM sockets under /run/php-fpm/ ? DirectAdmin do not store PHP-FPM sockets in the folder.
Why the document root is different for HTTP and HTTPs?
Ok, I did overlook the document root and forgot to update them both to /web but I still get the same result with respect to php files.

root:access owns that file but I should look into changing that.

the /run/php-fpm/ I believe was created as a result of installing a view versions of PHP using the directadmin build utility (da build php) from ssh.

Am I building PHP incorrectly when trying to make it compatible with both Apache and DirectAdmin?
 
I made somewhat progress through deep digging. but not good enough.

I had to find the php-fpm config file to learn it was actually listening on a different socket filename so whatever httpd-vhost.conf came with my directadmin at installation time wasn't right.

So now I use this code after da built it. (note ip means the actual IP address of the server)

Code:
Include /etc/httpd/conf/ips.conf

<VirtualHost ip:80>
ProxyErrorOverride on
    AddHandler "proxy:unix:/usr/local/php80/sockets/admin.sock|fcgi://localhost" .inc .php .phtml
    ServerAdmin webmaster@localhost
    DocumentRoot /web
    ServerName ip
    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    CustomLog /var/log/httpd/access_log combined
    ErrorLog /var/log/httpd/error_log
    SuexecUserGroup admin admin
</VirtualHost>

<VirtualHost ip:443>
ProxyErrorOverride on
    AddHandler "proxy:unix:/usr/local/php80/sockets/admin.sock|fcgi://localhost" .inc .php .phtml
    ServerAdmin webmaster@localhost
    DocumentRoot /web
    ServerName ip
    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    CustomLog /var/log/httpd/access_log combined
    ErrorLog /var/log/httpd/error_log
    SSLEngine on
    SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt.combined
    SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key
    SuexecUserGroup admin admin
</VirtualHost>

So now I get a bit more meaningful error behind the scenes:

Code:
[date] [proxy_fcgi:error] [ids] [my-remote-ip] AH01071: Got error 'PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(/web/a.php) is not within the allowed path(s): (/home/admin/:/tmp/:/var/tmp/:/opt/alt/php80/usr/share/pear/:/dev/urandom:/usr/local/php80/lib/:/usr/local/php80/lib/:/usr/local/php82/lib/:/usr/local/php83/lib/:/usr/local/php84/lib/:/usr/local/php56/lib/:/usr/local/lib/php/) in Unknown on line 0PHP message: PHP Warning:  Unknown: Failed to open stream: Operation not permitted in Unknown on line 0Unable to open primary script: /web/a.php (Operation not permitted)

And yes, I'm trying a folder (/web) which is outside the typical /home location.
How do I configure all PHP versions to allow such outside folders?

And is it safe to merge several PHP versions 8 and above to one config file through symbolic links so I don't have to manually change the config to each one or will PHP complain? I have 4 installed.
 
Back
Top