WHM: 72.0.10 on CentOS 7.5
Not sure what version of EA4 I'm on. It's known that
/usr/local/cpanel/scripts/easyapache --version
will return an error if you're running EA4. The changelog at
EasyApache 4 Change Log 2018 - EasyApache 4 - cPanel Documentation
shows a date of 2018-07-25, and /etc/cpanel/ea4/php.conf is dated 2018-07-26, so am assuming I'm on the latest release.
Having trouble serving php files from a custom document root for an account's primary domain, and am suspecting EA4 is the culprit. Apache seems to update, but any *.php content is not being served from the new location. *.html content, however, is properly returned from the new location.
Moving public_html out of the account root can be desired for several reasons, not the least of which is organizing multiple domains belonging to one account. You may wish to put all of the account's web content - even that of the primary domain - under sub-folders of, say "/home/myuser/web/"
Assumptions:
root SSH access to your cPanel server
Account Name -> "billy"
Domain -> "example.com"
(my apologies to the actual owner of example.com for use of this variable placeholder)
Current Doc Root -> /home/billy/public_html
Desired Doc Root -> /home/billy/web/example.com/public_html
It appears as if PHP is ignoring changes in /var/cpanel/userdata/billy/example.com and only looking for content in /home/billy/public_html
This post:
Change root directory for the main domain?
details the general procedure for changing a domain's document root. The steps are:
Edit /var/cpanel/userdata/billy/example.com
Update documentroot: /home/billy/public_html -> /home/billy/web/example/public_html
Update scriptalias path: /home/billy/public_html -> /home/billy/web/example/public_html
Make the same edits to /var/cpanel/userdata/billy/example.com_SSL
Prudently make a backup of the current Apache conf
cp /etc/apache2/conf/httpd.conf /etc/apache2/conf/httpd.conf.bak.$(date "+%F_%H-%M-%S")
Rebuild the Apache configuration
/scripts/rebuildhttpdconf
Restart Apache
service httpd restart
Once done, example.com's document root should now be /home/billy/web/example.com/public_html
Examining the revised httpd.conf does show the correct document root, i.e., /home/billy/web/example.com/public_html
However, after making the change, calling up example.com in a browser still appears to be serving content from /home/billy/public_html
If one tests this by removing /home/billy/public_html, the browser shows "No input file specified", showing this is not a browser caching issue. Once public_html is restored, the old content comes back. If one modifies /home/billy/public_html/index.php, that content is displayed instead.
Conclusion: PHP is looking in the wrong place for content.
This post:
No input file specified.
mentions the problem and talks about modifying the YAML for a sub-domain, but the link it refers to:
Configurations Values of PHP-FPM - Version 68 Documentation - cPanel Documentation
talks about a non-existant file /var/cpanel/ApachePHPFPM/system.yaml - this would be a global config anyway, and without access to variables specifying the domain in question (rather than just the account owner), such a global file wouldn't be very helpful unless *all* users followed the same folder structure.
There *is* a /var/cpanel/userdata/billy/example.com.php-fpm.yaml, and per the second post adding:
php_admin_value_doc_root: /home/billy/web/example.com/public_html
*seems* to work so far as generating the config files, but no combination of removing the main, SSL or php-fpm cache files, rebuilding the conf, or restarting the server seem to have any effect.
With the updated yaml, one can see the new path in example.cache, but when calling up the domain in a browser it still shows content from /home/billy/public_html, not /home/billy/web/example.com/public_html as expected
Running:
/usr/local/cpanel/scripts/php_fpm_config --rebuild --domain=example.com
and restarting Apache also has no effect.
So, how does one specify a custom doc root for serving php content these days?
For now, the klugde is to make sure /home/billy/public_html is devoid of content, and symlink the correct dir:
ln -s /home/billy/example.com/public_html /home/billy/public_html
but ultimately, that method is not the preferred long-term solution.
Any clues on how to fix this would be most appreciated.
Thanx!
Not sure what version of EA4 I'm on. It's known that
/usr/local/cpanel/scripts/easyapache --version
will return an error if you're running EA4. The changelog at
EasyApache 4 Change Log 2018 - EasyApache 4 - cPanel Documentation
shows a date of 2018-07-25, and /etc/cpanel/ea4/php.conf is dated 2018-07-26, so am assuming I'm on the latest release.
Having trouble serving php files from a custom document root for an account's primary domain, and am suspecting EA4 is the culprit. Apache seems to update, but any *.php content is not being served from the new location. *.html content, however, is properly returned from the new location.
Moving public_html out of the account root can be desired for several reasons, not the least of which is organizing multiple domains belonging to one account. You may wish to put all of the account's web content - even that of the primary domain - under sub-folders of, say "/home/myuser/web/"
Assumptions:
root SSH access to your cPanel server
Account Name -> "billy"
Domain -> "example.com"
(my apologies to the actual owner of example.com for use of this variable placeholder)
Current Doc Root -> /home/billy/public_html
Desired Doc Root -> /home/billy/web/example.com/public_html
It appears as if PHP is ignoring changes in /var/cpanel/userdata/billy/example.com and only looking for content in /home/billy/public_html
This post:
Change root directory for the main domain?
details the general procedure for changing a domain's document root. The steps are:
Edit /var/cpanel/userdata/billy/example.com
Update documentroot: /home/billy/public_html -> /home/billy/web/example/public_html
Update scriptalias path: /home/billy/public_html -> /home/billy/web/example/public_html
Make the same edits to /var/cpanel/userdata/billy/example.com_SSL
Prudently make a backup of the current Apache conf
cp /etc/apache2/conf/httpd.conf /etc/apache2/conf/httpd.conf.bak.$(date "+%F_%H-%M-%S")
Rebuild the Apache configuration
/scripts/rebuildhttpdconf
Restart Apache
service httpd restart
Once done, example.com's document root should now be /home/billy/web/example.com/public_html
Examining the revised httpd.conf does show the correct document root, i.e., /home/billy/web/example.com/public_html
However, after making the change, calling up example.com in a browser still appears to be serving content from /home/billy/public_html
If one tests this by removing /home/billy/public_html, the browser shows "No input file specified", showing this is not a browser caching issue. Once public_html is restored, the old content comes back. If one modifies /home/billy/public_html/index.php, that content is displayed instead.
Conclusion: PHP is looking in the wrong place for content.
This post:
No input file specified.
mentions the problem and talks about modifying the YAML for a sub-domain, but the link it refers to:
Configurations Values of PHP-FPM - Version 68 Documentation - cPanel Documentation
talks about a non-existant file /var/cpanel/ApachePHPFPM/system.yaml - this would be a global config anyway, and without access to variables specifying the domain in question (rather than just the account owner), such a global file wouldn't be very helpful unless *all* users followed the same folder structure.
There *is* a /var/cpanel/userdata/billy/example.com.php-fpm.yaml, and per the second post adding:
php_admin_value_doc_root: /home/billy/web/example.com/public_html
*seems* to work so far as generating the config files, but no combination of removing the main, SSL or php-fpm cache files, rebuilding the conf, or restarting the server seem to have any effect.
With the updated yaml, one can see the new path in example.cache, but when calling up the domain in a browser it still shows content from /home/billy/public_html, not /home/billy/web/example.com/public_html as expected
Running:
/usr/local/cpanel/scripts/php_fpm_config --rebuild --domain=example.com
and restarting Apache also has no effect.
So, how does one specify a custom doc root for serving php content these days?
For now, the klugde is to make sure /home/billy/public_html is devoid of content, and symlink the correct dir:
ln -s /home/billy/example.com/public_html /home/billy/public_html
but ultimately, that method is not the preferred long-term solution.
Any clues on how to fix this would be most appreciated.
Thanx!
Last edited by a moderator: