Installing Ampache5 on Ubuntu: A Straight‑Forward Guide
If you’re looking to turn a spare laptop or a Raspberry Pi into a slick music server, install Ampache5 is the move you’ll want. In this post I’ll walk through every step— from prerequisites to a quick sanity test— so your tunes stream without a hitch.
What You’ll Need
- A machine running Ubuntu 22.04 LTS or Debian 12 (Buster/Bullseye)
- Root or sudo access
- A stable internet connection
Quick Reality Check
I once had a friend who set up Ampache on an old 2010 laptop, only to find the web interface would never load after a PHP upgrade. The culprit turned out to be a missing php-mbstring package that the new PHP version silently dropped. Knowing what to install and why makes those headaches disappear.
Update Your System
sudo apt update && sudo apt full-upgrade -y
Keeps your OS fresh, reduces the risk of dependency clashes later on.
Install Required Packages
sudo apt install -y apache2 mariadb-server php libapache2-mod-php php-mysql \
php-curl php-gd php-intl php-mbstring php-xml php-zip \
ffmpeg wget unzip git:
- apache2 + libapache2-mod-php: The web server and PHP handler.
- mariadb-server: Ampache stores its data here; MariaDB is a drop‑in MySQL replacement with fewer bugs on Ubuntu.
- All the php-* packages provide the extensions Ampache relies on— especially php-mbstring, which, as I mentioned, can break your setup silently if omitted.
Configure MariaDB
sudo mysql_secure_installation
During this interactive script:
- Set a root password.
- Remove anonymous users.
- Disable remote root login.
- Drop the test database.
After that create a dedicated user for Ampache:
CREATE DATABASE ampache CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL PRIVILEGES ON ampache.* TO 'ampache_user'@'localhost' IDENTIFIED BY 'StrongPassword!'; FLUSH PRIVILEGES; EXIT;
A dedicated database user follows the principle of least privilege and keeps your music data isolated.
Pull Ampache5
cd /var/www/ sudo git clone https://github.com/ampache/ampache.git ampache sudo chown -R www-data:www-data ampache
www-data is the default Apache user; giving it ownership prevents permission headaches when the web server writes to config or cache directories.
Set Up Apache Virtual Host
sudo tee /etc/apache2/sites-available/ampache.conf <<EOF
<VirtualHost *:80>
ServerName music.example.com
DocumentRoot /var/www/ampache/public
<Directory /var/www/ampache/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EOF
sudo a2ensite ampache.conf
sudo a2enmod rewrite
sudo systemctl reload apache2
The RewriteEngine is essential for Ampache’s friendly URLs. Setting the document root correctly tells Apache where to find the front‑end files.
Install Composer Dependencies
cd /var/www/ampache sudo -u www-data composer install --no-dev --optimize-autoloader
Why: Composer pulls PHP libraries Ampache needs. Running it as www-data ensures permissions stay consistent.
Run the Web Installer
Open a browser and go to:
http://music.example.com/install.php
Follow the on‑screen prompts:
1. Database – point to the ampache database you created earlier.
2. Admin User – choose a username/password; this account can log into the web UI.
3. Media Folder – give the absolute path where your music lives (e.g., /srv/music).
After finishing, delete the install.php file to lock down the installer:
sudo rm /var/www/ampache/install.php
Why: Keeping the installer script around is a security risk; once setup is done, it’s safe and polite to remove it.
Verify Everything Works
1. Navigate to http://music.example.com.
2. Log in with the admin credentials you just created.
3. Click “Upload” or “Scan for music” to confirm that Apache can write to the media directory.
If you see a blue “Welcome to Ampache!” page and your song list populates, congratulations—you’ve got a working Ampache5 server.
Optional Tweaks
- HTTPS – Use Let’s Encrypt with certbot for free TLS certificates.
- Automatic Backups – Schedule a nightly cron job that dumps the MariaDB database and copies your media folder to an external drive or cloud bucket.
A secure, backed‑up server is less likely to give you grief down the road.
That’s it. You now own a self‑hosted music library that streams wherever you want. If anything goes wrong (e.g., “500 Internal Server Error” after a PHP upgrade), check apache2.conf and your .htaccess; the most common culprits are missing modules or permission bits.