Home  >  Article  >  Backend Development  >  centos7 - The file generated by executing the command in centos php cli mode has root user permissions, which will cause the web page to be unable to read this file.

centos7 - The file generated by executing the command in centos php cli mode has root user permissions, which will cause the web page to be unable to read this file.

WBOY
WBOYOriginal
2016-12-05 13:44:292581browse

The file generated by executing the command in centos php cli mode has root user permissions, which will cause the web page to be unable to read the file. It will be saved later. Have any experts in the group encountered this problem? How to execute the command in php cli Permission issuescentos7 - The file generated by executing the command in centos php cli mode has root user permissions, which will cause the web page to be unable to read this file.

Reply content:

The file generated by executing the command in centos php cli mode has root user permissions, which will cause the web page to be unable to read the file. It will be saved later. Have any experts in the group encountered this problem? How to execute the command in php cli Permission issuescentos7 - The file generated by executing the command in centos php cli mode has root user permissions, which will cause the web page to be unable to read this file.

You should not use root to run a business script. You can choose to use the same user as nginx / php-fpm / apache httpd, or a user in the same user group to run the file

For some reasons (to be honest, I can’t find many reasons why root is required to run), you must use root. You can use sudo -u [user name]to temporarily switch users to run under root, or in the file After generation, use chown to modify the file ownership (chgrp, chmod, etc.)

Finally, if you run the program through crontab, you can also specify the user

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn