None of the owners (99 99) FTP is called by php functions?
I have a script (Joomla) that creates files and directories on the server. The problem is that it creates them under the owner 99 99 (nobody) and after I cannot delete or change them using FTP without the help of the server admin.
I think this move_uploaded_file
is a php function.
Is there any solution to this issue by WHM or server admin? Can I change the default owner to ftp?
source to share
What happens is, the HTTP server is started by a user named "nobody" and your FTP user is different. When the upload occurs, the HTTP server creates a file under its username, and your FTP user does not have permission to write (or delete) these files.
The easiest way to fix this (but not very secure) is to add both users to the same group and change the file permissions so that users of the same group can read / write those files.
Your administrator should take care of this, but you will need to call chmod () to change the permissions of your uploaded files.
Explaining it better:
The linux / unix file permissions consist of user (u), group (g) and others (o) permissions. Here I will only cover three types of file permissions, which are read (r), write (w) and execute (x). So, you have something like this:
-rw-rw---x 1 jweyrich staff 12288 Oct 24 00:22 avatar.png
- The first rw is the permission (read / write) of the USER that owns the file (jweyrich).
- The second rw is the permission (read / write) of the GROUP, which owns the file (personnel).
- At the end of the -x there are OTHERS users' (execute) permissions.
Your PHP scripts act as "nobody" (and let's say "nobody"), so every file created from your PHP will be owned by the user "nobody" (and his group). A user can be part of one or more groups.
To solve the permission issue, your FTP user and "nobody" must be in the common group , let's say the administrator puts your user in "nobody". When they are in the same group, your PHP script should grant "rw" (read / write) permissions to members of the "nobody" group. For this:
chmod("path_to_your_file", 0770);
0770 is equivalent to "u + rwx, g + rwx, o-rwx" which I explain here:
- u + rwx = for user (owner who is "nobody") gives read / write / execute permissions.
- u + rwx = for group (also "nobody"), give read / write / execute permissions
- o-rxw = for others, remove read / write / execute permissions
After that, your FTP user, who is now part of the "nobody" group, will read // write access to the uploaded files and therefore can delete files as well. It will look like this:
-rwxrwx--- 1 nobody nobody 12288 Oct 24 00:22 avatar.png
This is not a perfect introduction to unix file permissions, but I hope it helps.
source to share
The user who is running PHP is nobody
set by the system administrator. There is nothing you can do about it.
You can try chown () to change the owner of the file if you know the FTP user ID. You are generally not allowed to do this from PHP.
Depending on the group situation on the server, it may be that if you use chmod
to change file permissions after uploading the file, the FTP account can access the file:
Try first:
chmod($uploaded_file, 0660); // owner+group read+write
If that doesn't work, try this:
chmod($uploaded_file, 0666); // global read+write
one of them is to make the file available to the FTP account.
0666
severely discouraged because other users on the server can write your files, but in some configurations this is the only way to succeed.
source to share