Manual Installation
Normally, the Bacula Enterprise REST API is installed using rpms or debs, in which case other than fine tuning the installation, everything is already done.
Below, we give all the steps necessary to install the REST API manually.
Requirements
Web server (recommended: lighttpd)
PHP 5.3 or newer
PHP modules:
PDO PHP support (for PostgreSQL, MySQL or other)
cURL PHP module
BCMath PHP module (php-bcmath package on Redhat)
The Web server Installation with PHP
Bacula REST API Server uses a web server environment for work. The REST API is available via http(s) protocol. The recommended web server for using with Bacula REST API Server is Lighttpd.
The whole package is installed in the directory /opt/bacula/rest-api. Under the rest-api directory, you will find the following additional directories:
- binwhere any binaries or start scripts are placed.
- etcwhere configuration files are placed (e.g. lighttpd.conf)
- logwhere you can find lighttpd log files
- scriptswhere you can find various useful scripts
- uploadswhere your app can upload files if necessary (not recommended)
- wwwwhere the rest-api web files reside
Lighttpd Installation (Ubuntu/Debian)
The following command will install lighttpd:
# apt-get install lighttpd
PHP Installation (Ubuntu/Debian)
There is also need to have PHP support for web server. Command for install all PHP dependencies looks like:
# apt-get install php5-cgi php5-curl php5-pgsql
The above example shows installation for PostgreSQL database (php5-pgsql). If you use another than PostgreSQL database as Bacula catalog, then you need to install your database driver for PHP PDO (PHP Data Objects).
SSL Certificate Preparation
For using SSL encryption (https) in web server there is need to have SSL certificate.
Certificate for Lighttpd
Below is example generation of SSL certificate for Lighttpd server. Each ’yourhost’ name you should replace to your own host name.
# mkdir -p /etc/lighttpd/ssl/yourhost
# cd /etc/lighttpd/ssl/yourhost
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout yourhost.key -out yourhost.crt
After executing the openssl command you will be asked about few parameters for generating yourhost.crt file. Most of them you may skip, but in question “Common Name (e.g. server FQDN or YOUR name) []:” you need to write yourhost name (eg. api.myhost.com) for which SSL certificate will be work.
Last step for SSL certificate preparation is:
# cat yourhost.key yourhost.crt > yourhost.pem
Web Server Configuration
Below is an example lighttpd configuration file that can be used with
the Bacula Enterprise REST-API. Unless you are testing, you should
replace the server.name
with your actual hostname. This
configuration file is normally located in
/opt/bacula/rest-api/etc/lighttpd.conf.
#
# Bacula REST-API lighttpd configuration file
#
server.port = 443
server.username = "bacula"
server.groupname = "bacula"
server.name = "localhost"
server.document-root = "/opt/bacula/rest-api/www"
server.follow-symlink = "enable"
#server.upload-dirs = ( "/opt/bacula/rest-api/uploads" )
server.errorlog = "/opt/bacula/rest-api/log/error.log"
accesslog.filename = "/opt/bacula/rest-api/log/access.log"
server.breakagelog = "/opt/bacula/rest-api/log/debug.log"
server.pid-file = "/opt/bacula/working/lighttpd.pid"
ssl.engine = "enable"
ssl.pemfile = "/opt/bacula/rest-api/etc/lighttpd/server.pem"
ssl.ca-file = "/opt/bacula/rest-api/etc/lighttpd/server.crt"
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_rewrite",
"mod_fastcgi",
# "mod_accesslog",
)
#
# Turn on the following for debug and restart lighttpd
#
#debug.log-request-handling = "enable"
#debug.log-request-header = "enable"
#debug.log-request-header-on-error = "enable"
"index.htm", "default.htm",
" index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl"
dir-listing.encoding = "utf-8"
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/x-javascript", "text/css", "text/html", "text/plain" )
#include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
#include_shell "/usr/share/lighttpd/create-mime.assign.pl"
#
# If the above /usr/share/lighttpd/create-mime.assign.pl
# does not exist, enable the following lines
#
mimetype.assign = (
".html" => "text/html",
".gif" => "image/gif",
".jpeg" => "image/jpeg",
".jpg" => "image/jpeg",
".png" => "image/png",
".ico" => "image/x-icon",
".css" => "text/css",
".json" => "text/plain",
".js" => "application/javascript",
)
fastcgi.server = (".php"=>((
"bin-path"=>"/usr/bin/php5-cgi",
"socket"=>"/tmp/php.socket"
)))
url.rewrite-once = (
"^/themes/(.+)$" => "/themes/$1",
"^/assets/(.+)$" => "/assets/$1",
"^/(.+)$" => "/index.php/$1"
)
PHP configuration
For the Lighttpd server to work correctly with PHP, there is need to adjust PHP configuration file for CGI scripts (usually located in /etc/php5/cgi/php.ini). You must add the following line:
cgi.fix_pathinfo=1
See also
Go back to:
Go to:
Go back to the REST API chapter.
Go back to the main Advanced Features Usage page.