Ubuntu14 server file path: /home/megadmin/public_html/mytestsite.com/index.php

<?php chdir(dirname(__FILE__)); file_put_contents("working.txt","hello world"); ?> 

the problem is that if you run the file from the server console with megaadmin rights, the working.txt file is saved in the current folder: /home/megadmin/public_html/mytestsite.com , and if you open the file through a browser, it displays in the error logs:

PHP Warning: file_put_contents(working.txt): failed to open stream: Permission denied in /home/megadmin/public_html/mytestsite.com/index.php on line 5

What could be a mistake?

    1 answer 1

    probably the fact that the user under which the web server is running and the user under which you run the command are two different users

    • one
      Added the rights of the Apache, senks, something reworked today :) - valextt