简体   繁体   中英

PHP5 - PHP.ini Causing No Access to Fwrite?

I recently set up my first VPS, and fully self configured PHP, Apache and all that good stuff, but when I tried importing one of my projects that deals with fwrite in it, when I try to do an fwrite, it will not throw an error, but it does not write. The only things I have tried so far was to chmod 777 the folder main folder of the project. This did not fix the issue. Is there anything in the php.ini default set to disallow fwrite? I am able to fopen and fread perfectly fine.

Try putting this at the top of your PHP page.

error_reporting(E_ALL);
ini_set('display_errors', '1');

More than likely you'll find that you have a permission denied message. If not, post the message here (If OP is still around).

A quick fix, perhaps not the most secure option, could be to log in via SSH as super user, run chmod -R 0777 [home directory]

For [home directory] just put the base folder that your files are being served from (www, home, public_html, etc...).

If you find that this works, I'd strongly recommend that you narrow the permissions; at least down to 0755.

The reason why this may work when your previous chmod did not, is that you're trying from SU vs regular user. On my install logging in as root did not grant me the permissions necessary to execute chmod correctly, but did after doing a sudo su . Go figure...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM