I am running Ubuntu version 14.04, and I have an apache2 server set up to host some php files on localhost that are stored in /var/www/html
.
When I try to execute the following code in one of my php script
<?php
$file = fopen("test.txt","w");
fwrite($file,"Hello World. Testing!");
fclose($file);
?>
I do not find a file stored in my /var/www/html named test.txt, or anywhere on my computer after searching. The file name does not already exist, and I am using sudo nautilus
because I do not have the necessary permissions to edit the php files inside the /var/www/html
. Why are the files not appearing in my /var/www/html
folder and how can I fix this so that the file is created?
www-data
having write access to thewww
directory (or one of its subfolders) is a major security hazard on production, and bad practice in general. Please pick a separate data folder, or use a database engine instead. – Ruud Helderman Nov 02 '14 at 17:26