Install Backuppc with Lighttpd
From backuppc
Contents |
Installation of BackupPC with the Lighttpd web server
I will explain how to install BackupPC and make it work with the web server Lighttpd instead of Apache.
All the provided explanations are based upon my Debian 4.0 etch install with Lighttpd 1.4.13 and BackupPC 3.1.0 (but I am sure you can adapt it to your own distribution).
I will assume that your are logged as a root user, have your Lighttpd web server already up and running and know how to edit files.
Please, feel free to update, correct or extend this tutorial as I am not an expert.
Installation
First of all download BackupPC (search on www.debian.com for the latest package and/or a mirror):
root:~# wget http://ftp.de.debian.org/backports.org/pool/main/b/backuppc/backuppc_3.1.0-3%7Ebpo40+1_all.deb
and install all the necessary dependencies for BackupPC except Apache related packages:
root:~# aptitude install perl libdigest-md5-perl libcompress-zlib-perl libarchive-zip-perl \
tar adduser dpkg perl-suid debconf debconf-2.0 smbclient samba-common bzip2
Finally install BackupPC (do not use aptitude as it will force the installation of the missing Apache packages):
root:~# dpkg -i backuppc_3.1.0-2~bpo40+1_all.deb
You will be prompt to choose between four Apache installation (apache, apache-ssl, apache-perl, apache2). Don't select any as you want to use Lighttpd instead.
Lighttpd Configuration
There are three different ways to configure Lighttpd:
- Change Lighttpd uid (change the user and group that will be used to execute Lighttpd). I will explaine this solution as this is the one I experienced
- Create an instance of Lighttpd that will be dedicated to the use of BackupPC (this means that if you are using Lighttpd for other websites, you will have a dedicated configuration of Lighttpd for BackupPC, with its own configuration file, using a dedicated port, running as user and group backuppc)
- Use SuEXEC to keep Lighttpd running as the default user (for Debian it is www-data) and run BackupPC as the user backuppc (You keep the default user to run Lighttpd and there is no need to have a dedicated instance of Lighttpd running). This seems to be the best of the two previous possibilities.
Most of your work will have to be done in the Lighttpd configuration file, edit it:
root:~# vi /etc/lighttpd/lighttpd.conf
Edit this section to change the user and group used to run Lighttpd to backuppc:
## change uid to <uid> (default: don't care) #server.username = "www-data" server.username = "backuppc" ## change uid to <uid> (default: don't care) #server.groupname = "www-data" server.groupname = "backuppc"
Edit this section to enable the needed Lighttpd server modules (mod_auth, mod_cgi, mod_alias):
## modules to load
server.modules = (
"mod_access",
"mod_accesslog",
"mod_alias",
"mod_auth",
"mod_cgi"
)
Edit this section to add index.cgi as an authorized index file:
## files to check for if .../ is requested
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm",
"index.cgi")
Add this section in your configuration file to assign cgi files to the perl binary:
#Assign file extensions to specific binaries cgi.assign = ( ".cgi" => "/usr/bin/perl", ".cgi" => "/usr/bin/perl")
Add this section in your configuration file to create an alias to the BackupPC web page:
#Configure aliases alias.url += ( "/backuppc" => "/usr/share/backuppc/cgi-bin" )
Add this section to your configuration file to create a virtual host:
#Configure virtual hosts
$HTTP["host"] == "backuppc.mydomain" {
server.document-root = "/usr/share/backuppc/cgi-bin"
auth.require = ( "" => ( "method" => "basic", "realm" => "BackupPC", "require" => "valid-user" ))
}
Note on aliases and virtual hosts: I was not able to create aliases and virtual hosts with another name than backuppc. Alias like http://mydomain/bkp/ or virtual host like http://bkp.mydomain/ would not fully work as links regarding pictures, css and js files were broken (I don't really understand why). Any advices are welcomed
Add this section in your configuration file to set user authentification:
#Set authorization rules auth.backend = "htpasswd" auth.backend.htpasswd.userfile = "/etc/lighttpd/lighttpd-htpasswd.user" auth.require += ( "/backuppc" => ( "method" => "basic", "realm" => "BackupPC", "require" => "valid-user" ))
You can now save your Lighttpd configuration file.
In order to be able to restart Lighttpd, you will have to change the permissions on the log files generated by your web server so it matches the user and group you just set in your configuration file:
root:~# chown -R backuppc:backuppc /var/log/lighttpd/
You will also need to change the user and group on the Lighttpd cache directory:
root:~# chown -R backuppc:backuppc /var/cache/lighttpd/
Restart your Lighttpd web server:
root:~# /etc/init.d/lighttpd restart
Create a user authentication file for Lighttpd
As you may know .htaccess are used by Apache for user authentication. We will use the same system with Lighttpd.
If you don't have them, you will need to install the apache2-utils package in order to use htpasswd:
root:~# aptitude install apache2-utils
Then create your user authentication file, for Lighttpd we will call it lighttpd-htpasswd.user
root:~# htpasswd -c -m /etc/lighttpd/lighttpd-htpasswd.user johndoe
You will be prompt to create a password for your user johndoe.
The -m parameter is used to force the md5 encryption of the password, this is needed for Lighttpd.
The -c parameter is used to create the file the first time, if you want to add users, proceed this way
root:~# htpasswd -m /etc/lighttpd/lighttpd-htpasswd.user janedoe
BackupPC Configuration
Most of your work will have to be done in the BackupPC hosts file, edit it:
root:~# vi /etc/backuppc/hosts
Add the hosts you need at the end of this file:
host dhcp user moreUsers # <--- do not edit this line #farside 0 craig jill,jeff # <--- example static IP host entry #larson 1 bill # <--- example DHCP host entry #localhost 0 backuppc JohnLaptop 0 johndoe admin JaneLaptop 0 janedoe admin
This means that johndoe and janedoe will manage BackupPC only for their own computer but admin will be able to mange both of them.
Take a look at this page of the HowToForge tutorial for more information: http://www.howtoforge.com/linux_backuppc_p3
You are done!
You should be able to access BackupPC from your browser at http://mydomain/backuppc
and authenticate with one of the user you previouly added.
For more information on how to use BackupPC it self, read the full tutorial on the HowToForge website: http://www.howtoforge.com/linux_backuppc
