站长资讯网
最全最丰富的资讯网站

php操作文件提示没有权限怎么办

php操作文件提示没有权限怎么办

问题描述:

在本地使用PHP脚本操作文件可以成功,但是放到服务器上就不行。

查看apache日志:

#cd /var/log/httpd #tac error_log

显示:

cannot create directory '_TEST1': Permission denied

解决方法:

1、查看apache配置的用户和用户组

#vi /etc/httpd/conf/httpd.conf
# # If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch. # # User/Group: The name (or #number) of the user/group to run httpd as. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services. # User  apache Group apache

可以看到User和Group 都是 apache。

2、修改你要操作的文件夹用户和权限,将用户改为和apache配置一样,将权限修改为755

#chown -R apache:apache your_folder #chmod -R 755 your_folder

3、关闭SELINUX

#vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq! #保存退出 #setenforce 0 #使配置立即生效

赞(0)
分享到: 更多 (0)

网站地图   沪ICP备18035694号-2    沪公网安备31011702889846号