How to Install Ampache with Apache on Ubuntu 18.04 | 20.04

How to Install Ampache with Apache on Ubuntu 18.04 20.04

In this post, we are going to show that how to Install Ampache with Apache web server on Ubuntu 18.04 | 20.04. If your are going to Install Ampache on your Ubuntu then this post is ideal for you.

Ampache is a free and open source web based audio, video and media streaming software that is used to host your own audio/video streaming server. It is similar like a file manager and with the help of it, anyone can access your music and video from around the world over the internet.

Ampache is comes with a simple web interface which is very useful to manage you media collection and play your audio/video from any device.

Features of Ampache

  • Music collection – Manage and Browse your media collection via a simple web interface
  • Music streaming -You can stream your music to your preferred media player or directly stream on the web with Modern HTML5 player.
  • Free and Open source – 100% Free and Open Source
  • Ampache everywhere – You can listen to your music from any device and from anywhere.

How to Install Ampache with Apache Server

Simply follow below steps to install Ampache with Apache on your Ubuntu:

Step 1 : Install Apache

Run the commands below to install Apache2 HTTP on Ubuntu server:

sudo apt update
sudo apt install apache2

Next, run the commands below to stop, start and enable Apache2 service to always start up with the server boots:

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

For check if Apache2 server is installed or not, simply open your browser and type server IP or hostname.

If browser show result similar like below then Apache2 is installed and working properly.

http://localhost
apache-default-page

Step 2 : Install MariaDB Database Server

To install MariaDB database, simply run the commands below:

sudo apt update
sudo apt install mariadb-server mariadb-client

Next, run the commands below to stop, start and enable MariaDB service to always start up with the server boots:

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Now, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.

sudo mysql_secure_installation

When you run the above command, it will prompted to answer the questions as show below:

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

Now, Restart the MariaDB server using below command:

sudo systemctl restart mariadb.service

For check if MariaDB is installed or Not, run the command below:

sudo systemctl status mariadb.service

Step 3 : Install PHP 7.4 and Related Modules

For install PHP 7.4, you will need to get it from third-party repositories because PHP 7.4 not includes in Ubuntu default repositories. Simply run the command below to add the third party repository:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Now update and upgrade to PHP 7.4 by using command below:

sudo apt update

Next, run the commands below to install PHP 7.4 and its related modules:

sudo apt install php7.4 libapache2-mod-php7.4 php7.4-common php7.4-curl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd php7.4-xml php7.4-cli php7.4-zip

After finished installing of PHP 7.4 and its related modules, run the command below to open PHP default config file for Apache server:

sudo nano /etc/php/7.4/apache2/php.ini

After open the configuration file, Changes the following below lines in the default configuration file and save it:

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

Step 4: Create Ampache Database

To create Ampache database, first you will need to create a blank Ampache database. Simply run the command below to logon to MariaDB database server:

sudo mysql -u root -p

Next, create a database named ampache using command below:

CREATE DATABASE ampache;

Now, run the command below to create a database user named ampacheuser :

CREATE USER 'ampacheuser'@'localhost' IDENTIFIED BY 'your_new_password';

Grant the newly created database user to the database by using command below:

GRANT ALL ON ampache.* TO 'ampacheuser'@'localhost' WITH GRANT OPTION;

Next, save your changes and exit:

FLUSH PRIVILEGES;
EXIT;

Step 5 : Download and Install Ampache

You can download Ampache package from its official download page or you can download it using command line.

To download it using command line, run the commands below:

cd /tmp
wget https://github.com/ampache/ampache/releases/download/4.1.1/ampache-4.1.1_all.zip
sudo unzip ampache-4.1.1_all.zip -d /var/www/ampache

After that, you will need to change the root folder permissions by using command below:

sudo chown -R www-data:www-data /var/www/ampache/
sudo chmod -R 755 /var/www/ampache/

Step 6 :  Configure Apache for Ampache Site

To configure Apache for Ampache site, you will need to create a new configuration file named ampache.conf. To do that, run the commands below:

sudo nano /etc/apache2/sites-available/ampache.conf

After create configuration file, copy and paste the below content into the configuration file and save it. Replace the highlighted line with your own domain name and directory root location:

<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/ampache
     ServerName example.com
     ServerAlias www.example.com

     <Directory /var/www/glpi/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save the configuration file and exit.

After that, run the command below to enable VirtualHost:

sudo a2ensite ampache.conf
sudo a2enmod rewrite

Next, restart the Apache using command below:

sudo systemctl restart apache2.service

Step 7 : Launch Ampache Web Interface

At this stage, Ampache is installed and ready to use. To launch it, open your favorite web browser and browse to the server domain name http://example.com.

http://example.com

It will open the Ampache setup wizard screen. At the setup wizard screen, select your preferred language and click on the Start Configuration button to continue installation process.

Ampache setup wizard with Apache

Next, Make sure that all the required PHP extensions are installed and all PHP requirements are met. Click on  Continue button if all are OK.

ampache-php-requirement with Apache

At next screen, you will need to provide your database details. Type your database name, database username and password, uncheck Create Database, check Create Tables, uncheck Create Database Users and then click on the Insert Database button.

Ampache-database-details

Next, select Subsonic backend for Ampache and click on the Create Config button.

select ampache backend

After that, create an initial account, simply provide your admin username, password and then click on the Create Account button.

Ampache create-account

To access the Ampache dashboard, login with the admin account that you are created above.

login-ampache with Apache

After successful login, you should see the Ampache dashboard as show in below image:

Ampache dashboard

That’s all

If you face any error and issue in above steps , please use comment box below to report.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top