Permissions set to 777 and file still not writeable

I guess Apache runs as a different user/group than the user/group owning the file. In which case, the file itself needs to be 0777.

public only needs to be 0777 if you plan on adding files to the folder using PHP. Even if the folder itself is not 0777, if the file is and the folder has at least 5 for the user (read/execute), you should be able to write to the file.

In the end, your file tree should look like this:

public_html
    public
        file.txt  0777

Naturally, you won't be able to change those permissions using PHP, but you can do so from your FTP client.

If it still isn't working, PHP might be running in safe mode or you might be using an extension such as PHP Suhosin. You might get better result changing the owner of the file to the same user/group that is running the script.

To get the user/group id of the executing user, you may use the following:

<?php
echo getmyuid().':'.getmygid(); //ex:. 0:0
?>

Then, you may use chown (in the terminal) to change the owner of the file:

> chown 0:0 file.txt

In opencart i faced this error after installing vqmod and giving all necessary permissions.

after researching a bit, found it.

"MODS CACHE PATH NOT WRITEABLE" is actually refering to vqmod folder itself and not the cache folder.

sudo chmod -R 777 vqmod 

in your root directory.....