After update to EA4 and cPanel/WHM 78, permission issues between sites and moving/copying files

zeropsi

Member
Mar 30, 2020
5
0
1
127.0.0.1
cPanel Access Level
Root Administrator
It looks like my last thread was deleted, so I will try and be more specific with this thread.

We recently upgraded our server to cPanel 78 and migrated from EA3 to EA4. Our server only has two sites on it, and prior to the upgrade we could use PHP scripts to copy files between the two sites using PHP's file_exists() and copy() functions.

We could use the file_exists() function to grab files from site1 and migrate them to site2 using code similar to this:

PHP:
$current_path = '/home/site1/public_html/uploads';
$new_path = '/home/site2/public_html/uploads';

if(file_exists($current_path.'/v2n62l6v.jpg')) {
    echo 'File exists: true' . "\n\n";
    copy($current_path.'/v2n62l6v.jpg', $new_path.'/2020/03/30/v2n62l6v.jpg');
} else {
    echo 'File exists: false' . "\n\n";
}
This code also creates new directories and sets the permissions to 0755.

After the upgrade, when we attempt to execute the script, we are greeted with this error:

Code:
File exists: true
Warning: copy(/home/site2/public_html/uploads/2020/03/30/v2n62l6v.jpg): failed to open stream: Permission denied in /home/site2/public_html/move.php on line 15
We are able to move the files if we set the permissions to the folders to 0777, but I would prefer to not have to change all of the folder permissions (there are 10s of thousands).

Any ideas on where to start or what settings may have changed during the upgrade to either EA or cPanel/WHM?

I am happy to provide any other information to help trouble shoot this issue.

Thanks so much for any/all help.
 
Last edited:

zeropsi

Member
Mar 30, 2020
5
0
1
127.0.0.1
cPanel Access Level
Root Administrator
I forgot to mention these items that may help trouble shoot:

Site is using:
  • PHP 5.5 (ea-php55)
  • DSO PHP Handler
  • CENTOS 6.10
  • cPanel v78.0.47
When I run ls -la at /home/site2/public_html/uploads I get this:

Code:
drwxr-xr-x 12 site2 site2 12288 Mar 30 13:39 ./
drwxr-x--- 15 site2 nobody  4096 Mar 31 13:44 ../
drwxr-xr-x 10 site2 site2  4096 Feb 21  2019 0/
drwxr-xr-x 12 site2 site2  4096 Feb 20  2019 1/
drwxr-xr-x 12 site2 site2  4096 Feb 20  2019 2/
drwxr-xr-x 12 site2 site2  4096 Feb 20  2019 3/
drwxr-xr-x 12 site2 site2  4096 Feb 20  2019 4/
drwxr-xr-x 12 site2 site2  4096 Feb 20  2019 5/
drwxr-xr-x 12 site2 site2  4096 Feb 20  2019 6/
drwxr-xr-x 12 site2 site2  4096 Feb 20  2019 7/
drwxr-xr-x 12 site2 site2  4096 Feb 20  2019 8/
drwxr-xr-x 12 site2 site2  4096 Feb 20  2019 9/
-rw-r--r--  1 site2 site2    25 Feb 20  2019 index.php
 
Last edited:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
Hello,
It looks like my last thread was deleted, so I will try and be more specific with this thread.
No, you just didn't wait for it to be moderated. All new users to the forums are moderated when they post for a time, to curb spam posts. This is noted when you submit the thread as well.


Is this the same PHP Handler/Configuration you had prior to the move?
 

zeropsi

Member
Mar 30, 2020
5
0
1
127.0.0.1
cPanel Access Level
Root Administrator
Hello,

No, you just didn't wait for it to be moderated. All new users to the forums are moderated when they post for a time, to curb spam posts. This is noted when you submit the thread as well.


Is this the same PHP Handler/Configuration you had prior to the move?
My apologies about that, I just saw that my posts were at 0, so I assumed.

I am not sure what the config was prior to the migration.

However, I have found that with changing the directories permissions to 0777, the script will execute as intended.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
However, I have found that with changing the directories permissions to 0777, the script will execute as intended.
Right, this is most likely the result of a configuration change. It'd be important to know what you were running previously. Is there a specific purpose for using DSO? Any issue with ruid2 + cgi or suPHP?
 

zeropsi

Member
Mar 30, 2020
5
0
1
127.0.0.1
cPanel Access Level
Root Administrator
Right, this is most likely the result of a configuration change. It'd be important to know what you were running previously. Is there a specific purpose for using DSO? Any issue with ruid2 + cgi or suPHP?
We had originally tried suPHP and that would not let us access the files from one account to the other. Changing the PHP handler to DSO did allow for us to access the files from site1 and then start to copy them to site2, once the permissions were changed to 0777. I am going to see if we can track down the previous set-up on account.
 

zeropsi

Member
Mar 30, 2020
5
0
1
127.0.0.1
cPanel Access Level
Root Administrator
Additionally, functions like move_uploaded_files are no longer working because of the permissioning issues. It appears that I need to keep all directories at 0777 in order for script based file and folder creation to work.