I have been setting up a new web server to replace an aging one and I am having some problems with relative paths that work on the existing server. The existing server is Centos 6 with php 5.6, however the new server is Centos 7 with the same php version. I should also mention that both servers run WHM/cPanel with a single user (solo) licence.
I have several folders one level above the public_html
folder that contain some include files and also some php files that are run from cron jobs. I put these here as there is never any need for them in the public_html
folder.
// Example folder structure
-includes
-cjobs
-public_html
-includes
-css
-js
index.php
On the existing server, the following works ok on a file in the cjobs
folder
include "../public_html/includes/mail_include.php";
, however on the new server it fails. I have ended up using include_once (dirname(__FILE__) . "/../includes/mail_include.php");
and also had to relocate the cjobs
folder into the public_html
folder. Note that full paths do work ok, so /home/username/includes/mail_include.php
does always work, but I don't want to hard code the paths.
I feel that there may be some small configuration setting in php that I have not changed, but I just have not been able to figure out why I need to include the files this way. It means I need to modify thousands of files just so they will work on the new server which is proving to be a real pain.
Any advice is appreciated.