Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got some trouble while trying to install some applications on my linux system. It is said that the files in my /var/www/html/xxx directory, where I put them, is not writeable. The command chmod 777 xxx has been tried to make it work, but the error remains when I opened the applications again.

To be specific, I want to install phpFreeChat on my system, so I put those files in the /var/www/html/freechat directory, cd there and typed chmod 777 data/private, chmod 777 data/public on bash. Here's the result of list -al data:

drwxr-xr-x.  4 root root 4096  Jun 17 15:07 .
drwxr-xr-x. 13 root root 4096  Jun 17 15:22 ..
drwxrwxrwx.  2 root root 4096  Jun 17 15:07 private
drwxrwxrwx.  3 root root 4096  Jun 17 15:07 public

These all seemed all right to me, until I typed http://localhost/freechat in my browser. Here's the result:

phpFreeChat cannot be initialized, please correct these errors:

/var/www/html/freechat/src/../data/private is not writeable /var/www/html/freechat/src/../data/private/cache can't be created /var/www/html/freechat/src/../data/private/cache is not writeable /var/www/html/freechat/src/../data/private/cache is not readable cannot create /var/www/html/freechat/src/../data/public/themes/default cannot create /var/www/html/freechat/src/../data/public/themes/default /var/www/html/freechat/src/../data/private/chat can't be created /var/www/html/freechat/src/../data/private/chat is not writeable /var/www/html/freechat/src/../data/private/chat is not readable /var/www/html/freechat/src/../data/private/chat/s_d0ba868e1391b6c0d897996049a68ada can't be created /var/www/html/freechat/src/../data/private/chat/s_d0ba868e1391b6c0d897996049a68ada is not writeable /var/www/html/freechat/src/../data/private/chat/s_d0ba868e1391b6c0d897996049a68ada is not readable

I'm quite confused with this because this situation did not only happen in the installation of this application but all. Mistakes must be made by me, but what is it?

share|improve this question
    
Doing chmod 777 is wrong. I suggest you to look into mod_userdir and user directories. –  vtest Jun 18 '11 at 3:40
add comment

4 Answers

up vote 1 down vote accepted

This problem has been settled by command setenforce 0, which would shut down SELinux.

How silly I am! I never thought about this stuff.

Thanks Flimzy and njd anyway.

share|improve this answer
add comment

You need to do a recursive chmod, to affect all of the files and subdirectories contained within data/private and data/public:

chmod -R 777 /var/www/html/freechat/private
chmod -R 777 /var/www/html/freechat/public

Now, having said, that, you should NOT be using mode 777. Especially if anyone other than you has a login account on that server. 777 means world read-, write-, and executable. Essentially, any user on your system can read, write, delete, or otherwise mess with those files.

At minimum, you ought to change that to mode 774, which means that only the user and group (which are both root at the moment) can write the files, but any user can read them.

Ideally, you would also make the files all owned by the same non-root user that runs the freechat software, and only give that user/group read/write permission.

At minimum, change your mode to 770, so that only the root user and root group have acc

share|improve this answer
    
Thanks, but the error remains even if I use the recursive method to make it in mode 777. –  lastland Jun 17 '11 at 7:59
    
Them either the chmod command didn't work, because you ran it as a normal user, and not as root; or you need to ensure that the preceding directories (/var/www/html/freechat and so on back up to /) are at least searchable (execute flag) by whichever account is used for the httpd service. –  njd Jun 17 '11 at 9:09
    
There's a reason to believe that chmod command worked for those directories are indeed drwxrwxrwx, unless ls -al cheated me. :) –  lastland Jun 17 '11 at 9:50
    
And I've tried chown these directories to apache.apache, which is set by /etc/httpd/conf/httpd.conf. The result didn't change a least. –  lastland Jun 17 '11 at 9:52
add comment

If you look at the permissions on each directory:

ls -ld / /var /var/www /var/www/html /var/www/html/freechat

and note the first column, you should see lines beginning like this:

drwxr-xr-x  

At the the very least, there should be an x on the end of the first column: without that, the web server won't be able to reach the contents of the freechat directory.

So you may need to

chmod o+x /var/www/html

and even

chmod o+x /var/www
share|improve this answer
    
dr-xr-xr-x is the / directory and drwxr-xr-x are the others. No x missing in any directory. –  lastland Jun 17 '11 at 9:48
add comment

This might be necro but...

the proper way to do this with out killing SE is to do this

semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/freechat/data(/.*)'

restorecon -R /var/www/html/freechat/data

Go ahead, call me an SE nazi!

Quick explanation:

The first bit says "every thing starting with /var/www/html/freechat/data should have the default context 'httpd_sys_rw_content_t'"

The other says "set all contexts on the files/directories in httpd_sys_rw_content_t (recursively) to defaults (which were just changed)"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.