1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 File/directory permissions checklist

Discussion in 'Troubleshooting and Problems' started by Rudy, Jul 18, 2015.

  1. Rudy

    Rudy Well-Known Member

    I've moved a forum from one server to another (different OS and configuration), and am having the usual file permissions issues with avatars and attachments. I have root, so I can change anything as needed. I'm getting the permission denied messages in the XF server error log. Everything looks right, so that's why I'm pulling out what little hair I have left!

    1) Directories are all set at 0777.

    2) Directories are owned by my server user (as opposed to the web server user, aka 'nobody').

    3) PHP settings...could I be missing something there? I do have PHP set to allow uploads. I did notice that the PHP parameter upload_tmp_dir is unset, so I fixed that but I still get the problem. Any other PHP settings I should look for?

    4) Could it be something in .htaccess preventing the file upload? (Although I don't think that's it.)

    I can post more info as needed. OS is CentOS 7, web server is Apache 2.4.6, PHP is latest stable version (5.6.8).

    ErrorException: copy(/var/www/......./internal_data/attachments/0/333-b62fd8aa3cd577ff23a4290a595391a0.data): failed to open stream: Permission denied - library/XenForo/Helper/File.php:253
  2. Brogan

    Brogan XenForo Moderator Staff Member

    I presume so but to confirm, did you chmod recursively?
  3. Rudy

    Rudy Well-Known Member

    Correct--I did it both on /data and /internal_data .
  4. Mike

    Mike XenForo Developer Staff Member

    You may want to check the permissions on the file listed in the error specifically to confirm that. Based on what I think you're saying, you should confirm that they're 0666 (or 0777).

    If they are, that error is probably pointing to something else. Specifically, I would guess SELinux. That would generally need to be tuned for your specific needs (though I can't say I've heard of what tuning would be necessary for something like XF; I'm not aware of anyone using it).
  5. Rudy

    Rudy Well-Known Member

    After I ran chmod/chown, I did verify all files were 0666 or 0777. My thinking at the moment is that something is not happening correctly from when the files are uploaded to a temporary file, to when they are copied to the XF data directories.

    The hunt continues...
  6. Rudy

    Rudy Well-Known Member

    This evening, I tried installing a clean XF in a new private directory, and hit the same error--the installer balked on the permissions when checking the two directories. Then, I tried using "setenforce 0" on the command line, and now I can get past the directory permission and install XF.

    So naturally, one problem leads to another. I now get this message: "The uploaded file is too large for the server to process." Right.

    Earlier, I fixed an error in PHP--the temporary directory and temp upload directories were not set up properly, but I have fixed those with 0777 permissions and have tried different user/group names (including apache), but there was no change in this newest error. As for PHP file upload settings, everything is suitably large, including the four parameters Jake Bunce calls out here:

    The File Too large for the server

    Comparing phpinfo() between the old server (where the forum worked perfectly) and the new, I have the PHP "core" values all matching, if not larger than the old server. Unless I am missing a PHP parameter, the only thing left might be an Apache upload permission, perhaps? I did find one directive, LimitRequestBody, which seemed relevant, but adding it to the appropriate .conf file and restarting httpd made no difference. Note that Apache is not loading mod_security, but I did try uncommenting the lines in htaccess anyway, with no effect.

    This error, by the way, does not trigger an entry in the XenForo server error log.
  7. Mike

    Mike XenForo Developer Staff Member

    That error would generally point to the max_upload_filesize setting in php.ini. What's that value set to and how big is the file you're uploading?
  8. Rudy

    Rudy Well-Known Member

    I have max_upload_filesize at 12M (12MB), and the test files are 120KB or less.

    For troubleshooting, all of the relevant settings in php.ini are far larger than I normally use (max_execution_time, memory_limit, post_max_size, upload_max_filesize), larger even than on the old server where I had the same forum running two months ago, where it worked perfectly. If I put the phpinfo() pages side by side, old server and new, the settings are nearly identical.

    Digging through the Apache logs, I find this:

    "PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0, referer: http://......"

    So, it still goes back to some issue with temporary files.

Share This Page