I am trying to run a script which creates pages and saves them to the server but am getting a permission error on one of the files that is in the public_html directory.
So 2 pages are created in the "pages" directory which is chmod to 0777 and they are created fine. The 3rd page is created in the "public_html" directory which fails with you do not have permission. The only way i have found to fix this is to chmod the "public_html" directory to 0770 which then everything works but i have been strongly advised by the hosting company not to do this bevause of the security risk.
So my question is, Is there any otherway to achieve this goal? Looking into it a bit it looks like i need to give the script "user" priviliges might work but this is beyond my knowledge at the moment. I`m not even sure what the script is running as at the moment, I would guess "group" as chmoding the public_html to 0770 allows "group"
My setup is: vps server running centos CENTOS 6.7 x86_64
php 5, dso, Apache suEXEC on
simplified Code i am using is:
$page_path = "/home/username/public_html/";
$loop[Html_Name] = "test.html";
$new_page_file = "test.html";
$fp = fopen($page_path.$loop[Html_Name], "w");
fwrite($fp, $new_page_file);
fclose($fp);
chmod($page_path.$loop[Html_Name], 0666);
Many thanks in advance.