---
title: "liunx下apache服务器出现Permission denied"
author: "栀子花_开"
date: "2014-03-19T08:52:39Z"
tags: []
categories: ["数据库"]
slug: "liunx-apache-permission-denied"
draft: false
lastmod: "2014-03-19T08:52:39Z"
id: 2033105
url: "https://kaysa.iteye.com/blog/2033105"
---

上传文件的时，服务器报错Permission denied：权限不够。

 

登陆服务器察看该文件夹权限：

 

ls -l

drwx-w--w- 1 root root 0 Mar 7 19:35 testfile //查看文件拥有者为root，用户组为 root ！

 

**由于用的是apache服务，所以要把文件的用户组权限设置为：rwx(rw-)，用户组设置为apache。完成分2步：**

 

1.先设置权限(设置用户组权限为读写执行-rwx)：

 

chmod -R 755 testfile

查看结果-&gt;&gt;ls -l:

drwxrwx-w- 1 root root 0 Mar 7 19:35 testfile //查看文件

 

2.修改文件的用户组：

 

方法1：chown root:apache testfile

方法2：chgrp apache testfile

 

查看结果-&gt;&gt;ls -l:

drwxrwx-w- 1 root apache 0 Mar 7 19:35 testfile 

 

ok，重启服务：/etc/init.d/httpd reload