Replies (6)
How are you doing this?
Reply 1SOLVED (Look further down the thread) Hi Jeremy, thank you for
Reply 2Hi Jeremy, thank you for responding! PHP Scripts themselves seem to work fine, the issue is when I try to write a file nothing happens, no errors are output to the browser, it just doesn't create the file.
The information regading those commands are as follows:
turnkey-version:
turnkey-lamp-14.1-jessie-amd64
service apache2 status:
* apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2) Active: active (running) since Thu 2016-05-19 18:46:59 UTC; 20min ago Process: 497 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
ls -l /var/www:
test.php and test2.php
ls -l /etc/apache2/sites-enabled
lrwxrwxrwx 1 root root 35 Mar 3 05:17 000-default.conf -> ../sites-available/000-default.conf lrwxrwxrwx 1 root root 31 Mar 3 05:17 adminer.conf -> ../sites-available/adminer.conf
Sorry about your troubles with the spam filter
Reply 3Anyway, back to the issue at hand...
Thanks for the additional info. From that my guess is that it's a permissions issue. Although I can't be sure as you didn't post the output of the 2 commands that are probably most likely to show that up. So please try again to post these 2:
# so I can see ownership of the files and the directory: ls -la /var/www # see if Apache has been recording any errors: tail /var/log/apache2/error.log
So to clarify that I understand you correctly, your test.php files are meant to write new files within your doc root (i.e. /var/www)? If so please try the following:
chown -R www-data:www-data /var/www
That will give the webserver (Apache) and anything running under the webserver (e.g. PHP) full ownership to your document root. My suspicion is that it is currently owned by root so only read access is given to the webserver and any code it is running (PHP).
Note that giving write access to the webserver is a potential security concern. If there are bugs in your code (or in Apache or PHP) then an attacker could rewrite important parts of the code. Obviously in some cases that is a necessary evil. However to mitigate the potential damage one way is to make a sub directory (e.g. /var/www/uploads) that is writeable by the webserver and leave your main PHP code read only.
Awesome, thank you so much
Reply 4You got it! :)
Reply 5SOLUTION:
Reply 6Your solution worked, you were correct it was a permissions issue. Keep in mind I have no clue what I'm doing in Linux, but I'll list the steps and my understanding of what each step does for other users:
- I created a sub directory in "/var/www/" lets call it "NewFolder" so its path is "/var/www/NewFolder"
- I changed the ownership of "NewFolder" to the www-data user in the www-data group (I think...) using the following command:
chown -R www-data:www-data /var/www/NewFolder
From what I understand this command is read:
- chown = Change Onwer
- -R = Recursively, or to all files and folders within the directory
- www-data = for the user "www-data"
- :www-data = in the group "www-data"
- /var/www/NewFolder = for the directory "/var/www/NewFolder"
I think that's how you read the command, regardless, once I did this I was creating files left and right all over my server. Thanks again Jeremy!
So upload your file (let's call it `test.php`) to `/var/www` (so the full file path is `/var/www/test.php`) on your LAMP appliance. Then in your web browser browse to `http://lamp_ip/test.php` and it should be there working!
If that is still not working for you, please tell me what you see (instead of your test.php, e.g. an error message, etc). Plus please post the output of the following commands: