Skip to content

NXNJZ

Linux and Security

  • BLOG
  • Cowsay Fortune
  • Contact
  • Gitlab
  • Company Homepage

Installing Ampache on CentOS 7.

Posted on February 5, 2019 - May 1, 2020 by nxnjz

Ampache requires a web server, PHP, and a MySQL database. We will be using Apache, PHP 7, and MariaDB to fulfill these requirements.

Installing the web stack and other required packages.

yum update -y
yum install -y httpd mariadb-server mariadb wget yum-utils epel-release git

And make sure Apache and MariaDB are enabled and running:

systemctl enable --now mariadb.service httpd.service

Installing PHP7.2

The default PHP version in CentOS repositories is not recent enough for Ampache. We will install PHP 7.2 from a third party repository.

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php72
yum install php php-common php-pdo php-cli php-mysql php-xml php-gd

Installing Composer.

Composer will be used to install additional PHP dependencies for Ampache.

Run the following command to download composer’s installation script:

wget https://getcomposer.org/installer -O composer-setup.php

And execute it:

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Installing FFmpeg

FFmpeg will be used for audio and video encoding/decoding. It isn’t available in official CentOS repositories, hence the need for the third-party repo known as Nux Dextop.

Install Nux Dextop:

rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

FFmpeg can now be installed with:

yum install -y ffmpeg

Database Configuration

Start by running the built-in MariaDB secure installation program:

mysql_secure_installation

When prompted for Y/n answers, choose Y for all questions and make sure you set a strong password.

Ampache requires a database and a MySQL user. Enter the MySQL console:

mysql -u root -p

Create a database named ampache:

MariaDB [(none)]> CREATE DATABASE ampache;

Create a local user named ampache;

MariaDB [(none)]> CREATE USER 'ampache'@'localhost' IDENTIFIED BY 'ampache_password';

Replace ampache_password with a password of your choice.

And grant that user full access to its respective database:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON ampache.* TO 'ampache'@'localhost';

Then exit:

MariaDB [(none)]> exit;

Apache Configuration

Create a new virtual host file with a text editor of your choice, for example:

vim /etc/httpd/conf.d/ampache.conf

And paste the following, replacing SERVER_IP with the correct IP address or your FQDN if you wish to use one.

<VirtualHost *:80>
    ServerName SERVER_IP
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/ampache/
    ErrorLog /var/log/httpd/ampache-error.log
    CustomLog /var/log/httpd/ampache-access.log combined
    <Directory /var/www/html/ampache/>
    AllowOverride All
    </Directory>
</VirtualHost>

Save and exit.

Restart Apache.

systemctl restart httpd.service

Firewalld configuration

Enable HTTP ports in the firewall daemon:

firewall-cmd --add-service http --add-service https --permanent
firewall-cmd --reload

Disabling SELinux

Ampache will not work properly with SELinux enabled. To disable it, open /etc/sysconfig/selinux with a text editor of your choice, and replace SELINUX=enforcing with SELINUX=disabled. You should now either reboot, or execute setenforce 0 to disable SELinux immediately.

Ampache Installation:

You can download the latest stable release with the following command:

wget https://github.com/ampache/ampache/archive/master.tar.gz

Extract and move the resulting directory:

tar -xzf master.tar.gz
mv ampache-master/ /var/www/html/ampache/

Ampache uses composer to install and manage dependencies. Optionally, switch to a non-root user before running composer.

cd /var/www/html/ampache
composer install --prefer-source --no-interaction

Once composer finishes, give Apache full ownership of the ampache web root and its content:

chown -R apache:apache /var/www/html/ampache/

You should be able to access Ampache at http://SERVER_IP/

The remaining configuration will now be done using the web interface. Here are some guidelines:

  1. Select your Preferred Language and press “Start Configuration”
  2. The next page will check if requirements are established.
  3. In the database creation step, fill in the details as follows:
    • Desired Database Name: ampache
    • MySQL Hostname: localhost
    • MySQL port: leave blank
    • MySQL Administrative Username: ampache
    • MySQL Administrative Password: The password chosen during user creation in the MySQL console.
    • Create Database: unchecked
    • Overwrite if database already exists: unchecked
    • Create Tables: checked
    • Create Database User: unchecked
  4. In the configuration generation step:
    • Web Path: /
    • Database Name: ampache
    • MySQL Hostname: localhost
    • MySQL Port: leave blank
    • MySQL Username: ampache
    • MySQL Password: The password chosen during user creation in the MySQL console.
    • Installation type: Assuming you want a fully featured installation for personal use, choose Default.
    • Transcoding Template Configuration: ffmpeg
    • Players: You should leave these settings unchanged in most cases.
  5. Create Admin Account: Choose a username and password and proceed.

Your Ampache installation is now ready for use. You can login at http://SERVER_IP//login.php

You can read about creating your first catalog in the Ampache wiki.

Optional

If you plan on uploading files via Ampache, you should change the PHP max upload size. Using a text editor of your choice, open the file /etc/php.ini and find the following line:

upload_max_filesize = 2M

Change it to:

upload_max_filesize = 100M

This will allow upload of files up to 100MB in size, you can change this value according to your needs.

Posted in Linux

Post navigation

Installing Ampache on Ubuntu 18.04.
Installing Ampache on Fedora 29.

5 Comments

  1. matt ferraro says:
    April 30, 2020 at 2:40 am

    Thank you for making this very simple to do! One small thing you forgot – git needs to be installed for the composer to install ampache – pretty simple and easy to correct on your page at the top – just incase others are like wtf thanks again for the godo tutorial!!

    Reply
  2. Rail Neira says:
    December 19, 2020 at 3:17 am

    Thank you very much for the post. After a few problems I finally did the installation. One of my problems was the Composer version. I had to downgrade for some reason to Composer 1 to being able to install the necesary dependecies for ampache.

    Reply
  3. Kaj Te Briga says:
    June 8, 2021 at 5:18 pm

    :=)

    Reply
  4. Christian Mora says:
    November 21, 2021 at 6:30 am

    Thank you for the post too!! I need help with ampache https streaming channels on Centos 8 with LAMP server.

    Could you please help me??

    Reply
  5. Tyreeb says:
    March 25, 2022 at 3:09 pm

    yum –enablerepo=remi install php-intl needs to be added before running composer or it will error

    Reply

Leave a Reply Cancel reply

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

Recent Posts

  • CVE-2021-42052 full disclosure
  • How to Set Up an Interactive SSH Honeypot on CentOS 8.
  • HackTheBox.eu Jarvis Writeup
  • How to setup a simple proxy server with tinyproxy (Debian 10 Buster)
  • How to Install qdPM 9.1 on Debian 10 LEMP

Tags

802.11 ampache apache aspx bash cd centos cms crm cve debian exploits fedora fulldisclosure hackthebox honeypot http httpd ifconfig iw iwconfig labs lfi linux mariadb memory monit music nginx pastebin php privatebin privesc project management proxy reconnoitre selinux shopt ssh systemd txpower ubuntu wallabag wireless xxe

Categories

  • BASH (1)
  • CTF/Labs (2)
  • CVE / full disclosure (1)
  • Information Gathering (1)
  • Linux (25)
  • Password Cracking (1)
  • Privilege Escalation (2)
  • SQL Injection (1)
  • Web-Shells (1)
  • Wifi (2)
  • XXE (1)

Recent Comments

  • Bernard Martiny on How to Install PrivateBin on Ubuntu 18.04 LTS
  • VuCSA on List of security labs/challenges/CTFs
  • Brian on How to Install PrivateBin on Fedora 29.
  • Tyreeb on Installing Ampache on CentOS 7.
  • Christian Mora on Installing Ampache on CentOS 7.