There is a new version of this tutorial available for Ubuntu 20.04 (Focal Fossa).

How to Set Up The Ampache Streaming Music Server In Ubuntu 12.04 LTS

I love ampache it allows me to have a home media server from which I can stream my music to any where in the world including any old random PC with internet that I can access while on holiday overseas.
Ampache is a cataloging and streaming service written for the web which recently moved its development to github. It is current receiving active development so I'm hoping for continued improvement and enhancements over time.

I have written this how-to in support of that project in the hopes that more people will download and support this excellent open source project and it will continue into the future. The aim was to provide a how-to to get your server up and running at home with as many options on and working and secure allowing you to choose to switch OFF services as required later rather than bang your head against the wall trying to switch them ON.



To follow this tutorial you will need:

  1. A PC with Ubuntu 12.04 LTS running LAMP
  2. Your own web address (optional - required for streaming music to external clients like your work computer or cell phone)
  3. Forward port 80 from your router to your ubuntu server (optional - required for #2 above)
  4. SAMBA/SWAT running on your server.

Each of these can be done for free by following each of the three nice tutorials linked below.


NB: The very last step of (4) is to login as a "member of the admin group" - you can ignore this and login to SWAT later when instructed to do so in this tutorial when you actually come to use it.

O.K. I will assume you followed these 4 guides and you now have an ubuntu 12.04 LAMP system running SAMBA/SWAT and a no-ip website address with port 80 forwarded to the ubuntu server.


Create Media directories

Create your media directory and a download directory and give them quite permissive permissions so anyone can access the folders on your network. Please note that you need to exchange <ubuntu username> for your own ubuntu username.

sudo mkdir ~/music
sudo chmod 777 ~/music
sudo mkdir ~/downloads
sudo chmod 777 ~/downloads

The permissions are set with the 777 code and it means that anyone with access to the system can read, edit, and run the files contained within. You could set more restrictive permissions here but I prefer easy access to my media folders.


Setup windows folder sharing using SWAT

On a web browser log in to SWAT as the admin: go to: http://<Ubuntu server hostname>:901 eg: http://amapche:901 Now, login with user name: "root" and your <root user password>.

Click on the shares box at the top. Now click "create share".

Enter the following into their respective boxes. Please remember to exchange <ubuntu username> to your own ubuntu username.

path:        /home/<ubuntu username>/music
valid users:    <ubuntu username>
read only:    no
available:    yes

Now click commit changes. Now click advanced and set all the "masks" to 0777.

Click "commit changes" again.

Now click basic and "create share". Repeat the process for your "downloads" folder.

You should now see your ubuntu server on the network and have access to the two shared folders you created provided you remember the <SAMBA user password> you set. Again please note this is quite permissive and gives everyone on the network easy access to the music and downloads folder provided they know the <SAMBA user password> when they try to access the folders.

Now you are ready to download and install ampache. At this point i like to start the copying of my music over to the shared music folder as this will take some time. Hopefully it will be done by the time I'm done installing ampache.


Install Ampache

Download and unpack ampache

Go to your putty terminal and enter

cd ~/downloads

Go to right click the latest tar.gz link and copy the link to the clipboard and paste it into the terminal as in the following line (after typing "sudo wget" then add the "-O ampache.tar.gz" part):

sudo wget -O ampache.tar.gz

Untar the tarball into an appropriate folder:

sudo mkdir /usr/local/src/www
sudo chmod 7777 /usr/local/src/www
sudo tar zxvf ampache.tar.gz -C /usr/local/src/www

Note the name of the root folder eg ampache-3.6-alpha6 use the noted name where you see this in the following text.

Relax the permissions on the extracted folder:

 sudo chmod -R 7777 /usr/local/src/www/ampache-3.6-alpha6

For securities sake, we will, once installation is complete give ownership of the extracted folder to the web-server and tighten permissions up again.

Enable php-gd in apache web server to allow for resizing album art:

sudo apt-get install php5-gd
sudo /etc/init.d/apache2 restart

Create a link from the web-server root folder to the extracted ampache site:

cd /var/www/
sudo ln -s /usr/local/src/www/ampache-3.6-alpha6 ampache

Doing it this way allows us to move websites around and rename them with ease.


Online initial ampache configuration

Go back to your web browser and go to: http://<Ubuntu server hostname>/ampache

If all went well so far you should see the start of the installation process. Note that since you used ubuntu 12.04 LAMP server all the little OK's are nice and green indicating that the system is ready to have ampache installed.

Click to start the configuration and fill in the boxes as follows

  • Desired Database Name        - ampache
  • MySQL Hostname             - localhost
  • something else I forget        - <leave blank>
  • MySQL Administrative Username     - root
  • MySQL Administrative Password     - <mySQL root password>
  • create database user for new database [check]
  • Ampache database username     - <ampache database user name> eg ampache
  • Ampache database User Password     - <ampache database password> eg ampachexyz123blahblah6htYd4
  • overwrite existing [unchecked]
  • use existing database [unchecked]

Here I recommend that you do NOT use your <ubuntu username> as the <ampache database user name> or the <ubuntu user password> as the <ampache database password> for simplicity. I recommend you use a new username and password here as they will be stored in clear text inside your config file and anyone reading them could gain control over the whole system if you used the ubuntu username and password here.
You only need to remember the database username and password for the next step. They are for ampache to use not you.

Click "insert database" and then fill in the boxes for the next section as follows:

  • Web Path         - /ampache   
  • Database Name         - ampache    
  • MySQL Hostname         - localhost    
  • MySQL port (optional)     - <leave empty>    
  • MySQL Username         - <ampache database user name>     or root
  • MySQL Password         - <ampache database password> or mysql root password

Click "write".

Note that the red words turn into green OK's.

Click to continue to step 3.

Create the admin user passwords
Ampache admin username    - <apache admin username>
Ampache admin password    - <Ampache admin password>
Repeat the password

Here I usually use a password I can easily remember as I will need to use this to access the ampache site whenever I want to use it.

Click to update the database.

Click return.

The main ampache login screen should open and you can log in with the ampache admin username and password you just set.
DONT forget this password as its quite a pain to reset it.

Now you should see the main ampache interface. Ampache is up and running but needs some more specific configuration before you can use it.


Ampache user specific configuration

Back to the putty terminal.

First we'll create a space to drop the error logs so you can locate any issues later:

sudo mkdir /var/log/ampache
sudo chmod 7777 /var/log/ampache

Now we'll create a temp directory to store zip files for users to download songs, albums, and playlists.

sudo mkdir /ziptemp
sudo chmod 7777 /ziptemp

Now we will start editing the ampache config file:

sudo nano /usr/local/src/www/ampache-3.6-alpha6/config/ampache.cfg.php

Scroll slowly down through the file and edit each set of the appropriate lines to read as follow. I have titled the sets to help split up their use.
To speed things up You can use ctrl-w to search for specific config parameters

Network access - allow access from offsite:

require_localnet_session = "false"
access_control = "true"

Allow zip downloads of songs/albums/playlists etc:

allow_zip_download = "true"
file_zip_download = "true"
file_zip_path = "/ziptemp"
memory_limit = 128

Aesthetic improvement:

resize_images = "true" 

Allow comprehensive debugging:

debug = "true"
debug_level = 5
log_path = "/var/log/ampache"
Share this page:

1 Comment(s)

Add comment

Please register in our forum first to comment.


By: Aireagoir

Could you please update this there's a new ampache for Ubuntu 14.04 and one for Ubuntu 15.04.


A tutorial for these versions would be extremely appreciated