How PHP changes the root directory of a Linux server to Www:www

Source: Internet
Author: User
Customer service through FTP upload files, all files by default is the ROOT user rights, resulting in PHP files can not read and write creation.

It is only possible to set up each file by Chown www:www.

Is there a way to operate through PHP?

Reply content:

Customer service through FTP upload files, all files by default is the ROOT user rights, resulting in PHP files can not read and write creation.

It is only possible to set up each file by Chown www:www.

Is there a way to operate through PHP?

You say: Their servers, they like to use this SFTP to pass files directly, and then cause the program can not create directory overwrite files and so on. This is inevitable, you can put them logged in SFTP users with Usermod-ag www [username] added to the WWW this group , the WWW users to join you to the file of the user's group inside, so that the WWW and the user is a group of files, This gives the file 664 permissions .
(I used this method to synchronize files locally with the syncthing and the Atom editor (under the Users group) and the Web server (Nginx group). But I chown the Web server to users.)

Yes, bool Chown (string $filename, mixed $user) can be changed. PHP seems to have chmod, but it is recommended to change on the server, chown-r www:www/path/

General folder permissions to a 755, the file to a 644. This can be done with the following instructions (specific folders to change themselves): chown -R nginx.nginx /usr/share/nginx/html/ && find /usr/share/nginx/html/ -type d -exec chmod 755 {} \; && find /usr/share/nginx/html/ -type f -exec chmod 644 {} \;
I'm writing it to BASHRC, I can't use it again next time:alias webroot='chown -R nginx.nginx /usr/share/nginx/html/ && find /usr/share/nginx/html/ -type d -exec chmod 755 {} \; && find /usr/share/nginx/html/ -type f -exec chmod 644 {} \;'

-----

Another server with the Sftp file, the user belongs to the Users group AAA, I pass the file before opening ssh, the file all permissions into the users of AAA, in the BASHRC write alias, also no trouble, pass it back again, or the top of the better, After all, you have to use the STFP, the root to give away to use is not too safe)

You can just chown-r the folder to 777 if you like.

FTP user set permissions no?

Do not use root login, win next pass, FTP tools can generally be changed, such as XFTP, you can change the folder and file permissions, and keep the subsequent pass in the same permissions

can use this function Boolchown (), but not too safe, it is best to change directly on the server, this also requires root permission to execute, the best FTP account is consistent with the user of the PHP process

The shell uses the Chown command, and has encountered such problems before, when configuring lamp.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.