Having installed the web server is there a simple way to set a user able to use the graphic interface to copy files and directories to the local web server /var/www
I gave myself administrative privileges in Ubuntu but it still doesn't allow copies.
If you make /var/www writeable by its group and add the user to the group, that user will not have to use sudo. Try this:
The user should then be able to edit /var/www/ files without hassle.
The first line adds the user to the www-data group, the second line clears up any files with messed up ownership, and the third makes it so that all users who are members of the www-data group can read and write all files in /var/www.
If you are logged in as
<username>
you need to log out and log back in for the group membership to take effect.You can
chown
, that isch
ange theown
er of that folder. This will allow you to change the user and group of the folder, allowing your user to add/remove files on it. To do it, replaceyourusername
with your name and run:And thats it.
However, I preffer to create a virtualhost in my home folder, it's much easier.
Basically it allows you to use any folder as a apache serving folder. To show it how it simple, lets assume that your username is username and that the folder that you want to serve is /home/username/www
Create the following file (for instance
mywebprojects
) in /etc/apache2/sistes-available replacing the username and the folder path (basically just copy and paste and replace in #CHANGE HERE):Now lets create the
www
folder, add a simple hello world, disable the default website (/var/www
), enable our websitemywebprojects
and restart apache.And that it, now you dont need to go to
/var/www
, you simply add files to yourwww
(or other givename) and it's already there :).Method 1:
Press ALT+F2 and enter gksudo nautilus and then click Run.
Method 2:
nautilus -q
in your terminal to refresh right click menus.It will open that file/folder with root permission.
It could be as simple as
sudo usermod -a -G developers $username
using ACL.That takes a little work, though, to start. This is for Ubuntu 10.10 at least. First mount the file systems with the acl option in /etc/fstab.
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx / ext4 defaults,acl 0 1
Then make a group to which a user may belong for this purpose.
The user needs to log out and in again to become a member of the developers group.
Of course, do not do this if you have content in the /var/www directory that you want, but just to illustrate setting it up to start:
Then replace references to "/var/www" with "/var/www/public" in a config file and reload.
If we wanted to restrict delete and rename from all but the user who created the file:
This way, if we want to create directories for frameworks that exist outside the Apache document root or maybe create server-writable directories, it's still easy.
Apache-writable logs directory:
Apache-readable library directory:
Easiest way to do is follow the steps given below:-
sudo -s
and login with your password.root
.nautilus
and it will open the home folder for you as root. So now you can easily edit the files and do whatever you want.Hope this helps. :)
/var/www folder
is owned by the root.. you have to change the ownership to your own username for modifying files in this folder. For this you can try the following commands..sudo -i
// to change to root consoleNow the ownership of the folder
/var/www/html will
be assigned to the userscott
. Now scott can copy/move files in this folder.Although this question is old, the answer needs to be brought up to date.
Let's consider the following :
You state you gave yourself "administrative privileges". And by the accepted answer here user and group
www-data
now has permissions to write to the directory in question.Out of the box, when you install a LAMP stack,
/var/www
directories and files are recursively owned by user and grouproot:root
, unless you have changed the default ownership/permissions. Which in your case is true. To confirm :The output with default LAMP stack installation :
Above, there is a reason why
/var/www
andhtml
directories are owned by user and grouproot:root
on a default level, it gives read/executable permissions only toothers
which includeswww-data
. This conforms to least privileges security aspect. We wouldn't want an attacker to gain access to thewww-data
user/group which is the most vulnerable here, with permissions towrite
a script and takeover the server!This should help understand the default permissions of the
html
directory created when apache/nginx was installed :What we can do to safely use
your_domain
directory to transfer directories and files in a graphical interface with the necessary permissions is to :Assign ownership to the directory in question :
Now check the permissions of
/your_domain
:From the output here we can clearly see that
your_user
is owner and group and that others (www-data
) have read/execute permissions only. Which is a safe way to not compromise the web server and other users directories :Reload Apache :
Once this is done, here is a "simple" way to add files to
/var/www/your_domain
:Install vsftpd on your server and FileZilla on the client machine :
You can follow this guide to install and setup both vsftpd and FileZilla.
Just replace the
/home/username/ftp/files
to suite your needs and substitute where neededusername
( in the guide username issammy
) withyour_username
.Note : You may need to add this entry
pasv_enable=Yes
to your/etc/vsftpd.conf
file for Windows client.After vsftpd setup is done, we create the directory
/home/username/ftp/files/www
and mount/var/www/your_domain
to this directory./etc/fstab
to add the mount point :Source : here
Reboot the server.
Now the previous method of creating a permanent mount will work with a minimal image ( i.e. Container ) where it's
fstab
file indicatesUNCONFIGURED FSTAB FOR BASE SYSTEM
, this will NOT work with physical servers.So, if you still insist on FTP a temporary approach would be to bind the directories ( This method cannot survive system reboot ) like so :
Another, and permanent approach, would be to simply use a symbolic link. Keep in mind with this method you would need to choose where Protocol: in FileZilla -> SFTP-SSH File Transfer Protocol. To create the symbolic link we cannot use an absolute path ( i.e.
/var/www/your_domain
). We will use the relative path from/home/username/ftp/files/www
to/var/www/your_domain
. The command would be :You will find a guide for SFTP setup here.
And finally here is a simple way to edit files in
/var/www/your_domain
:Edit the files on your development machine.
Stop your web server, example :
sudo service apache2 stop
orsudo service nginx stop
.Add the files with FileZilla with protocols SFTP(symbolic link method) or FTP(mount method).
Restart the web server :
sudo service apache2 start
orsudo service nginx stop
.If you're using the server version, try webmin. It has a great web UI and file manager. Either that or Filezilla