X-post from StackOverflow
I've read countless forum posts about this but none of the answers seem to help my situation. Here's the log excerpt:
[proxy_fcgi:error] [pid XXXX] [client redacted] AH01071: Got error 'Unable to open primary script: /home/user-account/public_html/www/index.php (No such file or directory)'
I've verified manually that this file is readable through SSH; also, other non-php files can be accessed through the browser.
My directory structure is as follows:
/home/user-account /home/user-account/apps /home/user-account/apps/old /home/user-account/apps/current /home/user-account/public_html /home/user-account/public_html/old > symlink to > /home/user-account/apps/old /home/user-account/public_html/test > symlink to > /home/user-account/apps/current /home/user-account/public_html/www > symlink to > /home/user-account/apps/current
I have 2 subdomains on 'domain.com':
Therefore due to how cPanel/WHM/Apache writes out their virtualhosts (considering the ServerAlias directive), the resulting domain structure is:
old.domain.com www.old.domain.com (I ignore this) test.domain.com www.test.domain.com (I ignore this) domain.com (.htaccess redirects to www.domain.com) www.domain.com (This is the domain with the issue; also domain.com would be an issue if not for the redirect)
Up until now I've been developing my wordpress website under a real directory
/home/user-account/public_html/test. The site is in perfect working condition. Then I decided to go live. I moved the real folder to it's current location (
/home/user-account/apps/current) and symlinked
/home/user-account/public_html/test to it. I restarted Apache and verified the
test.domain.com site still operated as expected (testing out the symlink). Feeling confident in the symlink setup, I removed my original symlink of
/home/user-account/public_html/www (pointing to my old rails app at
/home/user-account/apps/old) and created a new one pointing to
/home/user-account/apps/current. This is when the issue started.
The only appreciable difference between the test subdomain and the main domain (with www aliased) is that the test subdomain's auto-generated directives point to the true aliased folder location (DocumentRoot/Directory/ScriptAlias all use
/home/user-account/public_html/test). I believe this was because I had used cPanel to create a subdomain which had to point to a directory within
/home/user-account/public_html. But the main domain's auto-generated directives all point to
/home/user-account/public_html instead of
However, apache 2.4 allows me to include custom virtualhost config options by placing my custom.conf files in the appropriate directories. So I don't need any of them for the test subdomain but I had to use them for the main domain; I know they're working because the error log (found at the top of this post) shows it's using the proper DocumentRoot. Here's an excerpt from the std custom.conf to show that in addition to setting the DocumentRoot I also override the other autogenerated directives explicitly:
DocumentRoot /home/user-account/public_html/www <IfModule mod_include.c> <Directory "/home/user-account/public_html/www"> SSILegacyExprParser On </Directory> </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ /home/user-account/public_html/www/cgi-bin/ </IfModule> <IfModule ssl_module> <Directory "/home/user-account/public_html/www/cgi-bin"> SSLOptions +StdEnvVars </Directory> </IfModule>
I haven't changed the file permissions from their original setup and I've already verified they're correct. Again,
test.domain.com was working as expected. It's only
(www.?)domain.com that isn't.
Other 'fixes' that did nothing:
- Rebuilding/restarting PHP-FPM (ineffective)
- SetHandler/ProxyOverride (SetHandler is automatically created for me by rebuildhttpdconf and I don't expect it's the issue as it's working for the test subdomain; ProxyOverride doesn't seem to do anything)
- Set up wordpress .htaccess (already in place and matches what is shown here. Again, test subdomain is working and it's an alias just like www is)
- EasyApache 4 with
- Apache 2.4.43
- PHP 7.3
- Apache 2.4.43
Whatever you consider, remember that there's practically no difference between the files in the test subdomain vs the main domain (.htaccess included); they're both aliased to the same directory. The only difference I can see is that test is a registered subdomain and therefore httpd.conf handles it slightly differently than the main domain. However I can't just add a 'www' subdomain through cPanel - it won't let me - probably because it aliases www anyway.
I've been clawing around trying to fix this and my public website has been down for 24+ hours so I would greatly appreciate any help you can provide!
I don't know if it's relevant (it didn't seem to affect my old rails app), but under WHM > Manage SSL Hosts, my main domain and www subdomain point to a document root of
/home/user-account/public_html, whereas my subdomains point to the correct respective directories.
I also tried setting the vhost on the main domain to use the test directory (same as the test subdomain) but it's giving me the same error. I don't think it's a permission/file issue.
I also created a test.php file in the
/public_html directory in order to test out a direct access. It still erred out and logged:
AH01071: Got error 'Unable to open primary script: /home/user-account/public_html/www/index.php (No such file or directory)', referer: https:// domain.com/test.php