• Hi,

    I am using W3 Total Cache with Amazon cloudfront.

    After set up w3 Total Cache, it gives a mistake: “File and directory creation tests failed

    Could not create file in /var/www/vhosts/christine.ee/httpdocs/wp-content/cache/test_dir using file_put_contents.
    Could not create file in /var/www/vhosts/christine.ee/httpdocs/wp-content/cache/test_dir using fputs.”

    Could you please tell me what to do to make it work properly?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I am having this problem as well. Did you figure this out?

    I am having this problem as well with W3 Total Cache.

    I am too having this problem and unable to fix it either.

    We have had the same problem. The problem exists because we use an NFS share for some of our websites. The code of the W3 Total Cache plugin attempts to do an flock on the filesystem, but in our case, no lock daemon exists. This causes the code to hang and a non-responsive dashboard is the result.

    A fix is to remove the flock’s from the code. In wp-content/plugins/w3-total-cache/lib/W3/Setup.php, starting at line 455, change

    private function _test_create_file_fputs($test_file) {
            $fp = @fopen($test_file, 'w');
    
            if (!$fp)
                return false;
            if (@flock($fp, LOCK_EX)) {
                @fputs($fp, $test_file);
                @fclose($fp);
                @flock($fp, LOCK_UN);
                @unlink($test_file);
                return true;
            } else {
                return false;
            }
        }

    to

    private function _test_create_file_fputs($test_file) {
            $fp = @fopen($test_file, 'w');
    
            if (!$fp)
                return false;
                @fputs($fp, $test_file);
                @fclose($fp);
                @unlink($test_file);
                return true;
        }

    which essentially is the same as

    private function _test_create_file_fputs($test_file) {
            $fp = @fopen($test_file, 'w');
    
            if (!$fp)
                return false;
                return true;
        }

    This removes the flock and all is good again.

    Using WP 3.5.1 and W3 Total Cache 0.9.2.8.

    mmcn

    (@mmcn)

    i ve done the samething as it shown above but i doesnt work for my site.

    have any other idea to solve the problem?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘file and directory tests failed’ is closed to new replies.