apache如何设置php权限

藏色散人
Libérer: 2023-03-05 21:28:02
original
4421 人浏览过

apache设置php权限的方法:1、授予0777文件本身的权限;2、将所有权更改为Apache用户“www-data”并授予所有者写入权限;3、将用户添加到“www-data”组,然后分组写权限即可。

apache如何设置php权限

推荐:《PHP视频教程

具体问题:

如何给Apache写入主目录的权限?

我的服务器在/ var/www/html我在/var/www/html/fileio_test/io_test.php中有一个php脚本

Copier après la connexion

当我尝试运行这个脚本时,我得到了

Warning: fopen(/home/djameson/test.txt): failed to open stream: Permission denied in   /var/www/html/fileio_test/io_test.php on line 7
Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/html/fileio_test/io_test.php on line 8
Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/html/fileio_test/io_test.php on line 9
Copier après la connexion

如何让Apache写入我的主目录?服务器在Fedora 20上运行。

解决办法:

由于您的文件位于主目录中,我建议使用以下方法之一。

授予0777文件本身的权限。

chmod 0777 /home/djameson/test.txt
Copier après la connexion

将所有权更改为Apache用户www-data并授予所有者写入权限。

Sudo chown www-data:www-data /home/djameson/test.txt
chmod 0744 /home/djameson/test.txt
Copier après la connexion

将您的用户添加到www-data组或反之亦然将www-data用户添加到您的组。然后分组写权限。

Sudo usermod -a -G www-data djameson
chmod 0764 /home/djameson/test.txt
Copier après la connexion

注意:我假设Apache用户名和组名分别是www-data和www-data。您必须相应地更改服务器Apache用户名/组名称。

以上是apache如何设置php权限的详细内容。更多信息请关注PHP中文网其他相关文章!

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!