Sunday, November 17, 2013

Change owner and permission of /var/www

Previous post show how to "Install LAMP web server on Raspberry Pi". The /var/www directory is owned by the root by default after installed. It's suggested to change the owner to another group/user, such as www-data. Such that you can easy to modify it, even via ssh remotely.

To change it owned by www-data user and group, enter the command.
$ sudo chown -R www-data:www-data /var/www

To grant permission to www-data group to read/write/execute the directory /var/www.
$ sudo chmod -R 775 /var/www

Add user pi to the group www-data
$ sudo usermod -a -G www-data pi

May be you have to reboot, or log-out/log-in to let the change take effect.
$ sudo reboot

remark: I checked many solution from Internet, almost all provide the first two steps, chown and chmod, without -R option. It make me fail to change the owner and mode!

Then you can login as user pi remotely via ssh, edit the file /var/www/index.html using the build-in graphical edit leafpad.
$ leafpad /var/www/index.html


No comments: