24/7/365 Support

Installing Ampache server in Ubuntu

This recipe covers the installation of the Ampache server. It is a simple PHP-based web application. Once installed and set up, you can use a web interface to play your audio/video files or use any of the various popular streaming clients to stream content over the intranet or even the Internet.

Getting ready

We will be using Ubuntu Server 16.04, but you can choose to have any version of Ubuntu.

Additionally, we will need the Samba server. It will be used as shared network storage.

As always, access to a root account or an account with sudo privileges will be required.

How to do it…

Ampache is a web application developed in PHP. We will start the installation with the LAMP stack. This recipe covers installation with the Apache web server, but you can choose any other web server:

Install the LAMP stack if it's not already installed:

$ sudo apt-get update

$ sudo apt-get install apache2 mysql-server-5.5 php7 \

php7-mysql php7-curl libapache2-mod-php7

Next, download the latest Ampache server source code. Ampache is a PHP application:

$ wget https://github.com/ampache/ampache/archive/3.8.0.tar.gz

Extract achieve contents under a web root directory

$ tar -xf 3.8.0.tar.gz -C /var/www

$ mv /var/www/ampache-3.8.0 /var/www/ampache

We also need to create some configuration files. You can use the default configuration that ships with the Ampache setup and rename the existing files:

$ cd /var/www/ampache

$ mv rest/.htaccess.dist rest/.htaccess

$ mv play/.htaccess.dist play/.htaccess

$ mv channel/.htaccess.dist channel/.htaccess

The Ampache web setup will save the configuration under the config directory. It will need write access to that directory:

$ chmod 777 -R config

Next, we need to configure the Apache web server, enable mod_rewrite, and set a virtual host pointing to the Ampache directory.

Enable mod_rewrite with the following command:

$ sudo a2enmod rewrite

Create a new virtual host configuration:

$ cd /etc/apache2/sites-available/

$ sudo vi ampache.conf

Add the following lines to ampache.conf:

<VirtualHost *:80>

DocumentRoot /var/www/ampache

<Directory /var/www/ampache/>

DirectoryIndex index.php

AllowOverride All

Order allow,deny

Allow from all

</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Now, disable any default configuration that is using port 80, or alternatively you can use a port other than 80 for Ampache installation.

Reload the Apache server for the changes to take effect:

$ sudo service apache2 reload

Here, we have installed and configured the base setup. Now, we can move on to configuration through a web-based installer. You can access the web installer at the domain name or IP address of your server. The installer should greet you with a big Ampache logo and a language selection box; something similar to the following:

Select the language of your choice and click the Start configuration button.

On the next page, Ampache will check all the requirements and show you a list of settings that need to be fixed. These are mostly the configuration changes and file permissions.

Most of these requirements should already be marked with a green OK button. You need to fix things that are marked in red. The requirements screen will look as follows:

Click the Continue button when you are done reviewing all the requirements.

On the next page, you need to configure the MySQL settings. Fill in the necessary details and select Create Database User to create a new Ampache user under the MySQL server:

Click Insert Database to configure database settings.

The next screen will confirm the database settings and write the configuration changes to a file under the config directory. You can choose to change the installation type and enable transcoding configuration from this screen. Once done, click the Continue button to write the configuration file. If you see any errors, scroll to the bottom of the page and click the write button to write config changes.

Finally, the web setup will ask for admin account credentials for the Ampache server. The Create Admin Account form will be shown with Username and Password fields, as follows. Set the admin account username and password and click the Create Account button:

Once the account is created, the Ampache installation script will redirect you to the web player screen. If it shows a login screen, use the admin account credentials created in the last step to log in. The landing page of the web player will be rendered as follows:

You have completed the Ampache setup process. Now you need to upload content and enjoy your own streaming server. We will learn to create a catalog and upload content in the next recipe.

How it works…

Ampache is a web application written in PHP. We have downloaded the latest Ampache code and set it to work with our web server using Virtual Host configuration. Ampache provides sample htaccess files that set required redirection rules. We have enabled respective rules by renaming the sample files. If you are using a web server other than Apache, make sure you check the Ampache documentation for your web server. It supports Nginx and lighttpd as web servers.

Ampache has made it easy to cross-check all requirements and configure your database connection using the web installer. The installer checks for the required PHP settings and extensions and returns a simple page with things that need to fixed. Next, we can configure database settings and push schema directly from the web installer.

Once everything is configured, the web installer returns the login page, from where you can access the Ampache server.

There's more…

The Ampache community have created a Docker image for the Ampache server. If you have a Docker system set up, you can quickly get started with Ampache with its Docker image.

You can get the Dockerfile at https://github.com/ampache/ampache-docker .

Ampache is also available in the Ubuntu package repository and can be installed with the following single command:

$ sudo apt-get install ampache mysql-server-5.5

The currently available version of Ampache is 3.6. If you don't care about the latest and greatest updates, you can use the Ubuntu repository for quick and easy installation.

See also

Ampache installation guide: https://github.com/ampache/ampache/wiki/Installation

Help Category:

What Our Clients Say