我们已经把我们的网站移到了一个新的服务器(Ubuntu 12.04 LTS)上,这个服务器是我用ISPConfig 3build立的。
一切工作正常,但PHP试图写入新的日志文件到现有的日志文件时,给了我一个“无法打开stream:权限被拒绝” – 警告。
我非常不安全,因为我还不熟悉Linux。 目前,我的网站上的所有文件和文件夹都拥有“client1”组的所有者“web1”。 日志目录的权限与以前相同(在旧主机上)。
我知道,Apache(和PHP?)作为自己的用户“www-data”运行,所以基本上,我必须告诉我的日志文件和文件夹,这个用户可以读/写?
在研究的同时,我碰到了这个文章,谈到为文件所有者(web1)和apache用户(www-data)创build一个共同组。
我也发现了如下的说明:
//Create new group $ sudo addgroup webdev //Change the group of your web directory: $ sudo chgrp -R webdev /var/www/ $ sudo chmod -R g+rw /var/www/ //Set the guid bit on all folders in your web directory: $ sudo find /var/www -type d -exec chmod +s {} \; //Add Apache to the webdev group: $ sudo usermod -a -G webdev www-data //Add your user to the webdev group: $ sudo usermod -a -G webdev <user_name>
但是我还没有尝试过,因为我不确定是什么
$ sudo find /var/www -type d -exec chmod +s {} \;
确实。 这是否正确的方法来解决我的问题?
不要试图淡化,只是把事情弄糟。
sudo - run this command as a super user find - look for something... /var/www - ...in the /var/www directory... -type d - ...that is a directory... -exec chmod +s - ...and executes a chmod (change mode) +s (set the user bit) ... {} - ...for every directory you find... \; - and end the command.
现在上面列出的命令看起来很好,如果这是你想要做的。 与Apache和其他人创build一个共同的组。 希望有所帮助