You are here
manno - Thu, 2016/05/19 - 05:59
I cannot create files in PHP using my LAMP VM. When I upload the site to my web host however everything works fine. I know that it's possible to enable this functionality in my Turnkey LAMP appliance, but I clearly don't know what terms to search for, because I haven't found anything. I know this is a frustrating newbie question, but any help would be greatly appreciated.
Forum:
Tags:
How are you doing this?
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:
SOLVED (Look further down the thread) Hi Jeremy, thank you for
Hi 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:
service apache2 status:
ls -l /var/www:
ls -l /etc/apache2/sites-enabled
Sorry about your troubles with the spam filter
Anyway, 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 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:
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
SOLUTION:
Your 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:
From what I understand this command is read:
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!
You got it! :)
Add new comment