Reputation: 77
I have a server, which has a user called user
.
I am executing PHP commands in a directory with shell_exec
, and executing "whoami" through shell_exec returns user.
I also install a wordpress installation with wp-cli
commands with installing plugins, everything works fine.
However, when I try to execute the following command:
wp starter-templates import 59760 --yes --reset 2>&1
The error output is:
File generated at /home/server/wp/testwp/wp-content/uploads/astra-sites/astra-sites-backup-22-Aug-2023-08-10-54.json
sh: 1: : Permission denied
When I try to call this command in my local environment (in which everything works fine), the output is as follows:
File generated at /Users/user1/Sites/wp/wp-content/uploads/astra-sites/astra-sites-backup-22-Aug-2023-07-56-55.json
Reseting Posts..
Deleted - Post ID 1808 - attachment - Banner
Deleted - Post ID 12 - attachment - Logo-96×19
Deleted - Post ID 145 - attachment - Service-1-min
Deleted - Post ID 146 - attachment - Service-1-min (1)
Deleted - Post ID 149 - attachment - Service-2-min
...
When I look at phpinfo()
and openbasedir
settings at the server, I can see that PHP is allowed to access the directories, which is actually true since plugins and base wp installation install just fine.
When I look at the permissions for the generated .json file in the server, the permissions are:
-rw-r--r-- 1 user user 61 Aug 22 19:05 astra-sites-backup-22-Aug-2023-07-05-07.json
Which suggests that the user
user have read and write properties and is the owner of the file.
When I look at the contents of the json file, it seems that it is empty. From my understanding, the wp starter-templates import 59760 --yes --reset 2>&1
command tries to write to that json file, however, it keeps giving permission error and the command fails.
From my local environment test, the .json file shouldn't be empty. However, in the server environment it is empty. Hence I believe the issue is write permissions.
Why does it keep giving permission error though?
Upvotes: 1
Views: 358