Ubuntu Server Lamp Permissions...

embers

Reputable
Dec 27, 2014
103
0
4,710
So I have put my website within the /var/www/html/ folder and given my self access over a FTP server to do so, however when my webpages run php code that creates a new file within /var/www/html/ it basically does not allow it to do so.

So I guess because this is a new server, the permission are not correct, any ideas on how to fix this?

I am running Ubuntu Linux 14.04.2 with LAMP.
 
Solution
You have to give the web server account (usually, www-data) the necessary rights over your html folder and subfolders, something like
# chown -R www-data.www-data /var/www/html
# chmod ug+a /var/www/html
First line will change file ownership of all files to www-data user and group. Second line will give the www-data user, and everyone in the www-group, full access to the files and folders.
You can then add yourself to www-data group so you can upload files there.
You have to give the web server account (usually, www-data) the necessary rights over your html folder and subfolders, something like
# chown -R www-data.www-data /var/www/html
# chmod ug+a /var/www/html
First line will change file ownership of all files to www-data user and group. Second line will give the www-data user, and everyone in the www-group, full access to the files and folders.
You can then add yourself to www-data group so you can upload files there.
 
Solution