Skip to content

Installing Ampache on CentOS 7 (Apache, MariaDB, PHP 5.4)

This is way out of date now

The information in this post is so out-dated that I wonder why I'm keeping it around. I guess I'm a digital hoarder...

Image

Been getting bored and spinning up VMs like a fiend here of late. The latest one is an Ampache Server.

This one had proven to be more of a chore than I'd originally hoped. CentOS 7 may not have been the best distro to try this on...

Initial Steps

Installing the needed packages.

yum install httpd php-gd php-pdo php-mysql php mariadb mariadb-server

Start and enable the services.

systemctl start mariadb httpd
systemctl enable mariadb httpd

Initialize MariaDB and set your MariaDB root user password. (I accepted the defaults all the way through)

mysql_secure_installation

(You will be able to specify the database name, user, etc in the web installer, so we do not need to create and users/databases/tables ourselves.)

Getting Ampache

I chose to clone Ampache via Git. You could also download the Release Archive

I'm also going to throw it in the default httpd document root, as I don't plan to add any other web sites or services to this server.

cd /var/www/html
git clone https://github.com/ampache/ampache.git
chown -R apache. ampache/

(Optional Steps - this is if you want to install Ampache at http://example.com rather than http://example.com/ampache)

cd /var/www/html
# Using rsync to copy all items from ampache/ to /var/www/html then
# removing the /var/www/html/ampache directory.
rsync -av /var/www/html/ampache/ /var/www/html/
rm -rf /var/www/html/ampache/

PHP

Increase your max upload size in /etc/php.ini to 20MB or more.

From the installer Requirements Check

"This is not strictly necessary, but may result in a better experience."

Find the following settings in your php.ini file and adjust. I used 20M upload and double that for post.

upload_max_filesize = 20M
post_max_size = 40M

Now restart httpd so the settings are used.

systemctl restart httpd

FFMPEG and some encoders

I was surprised to find no FFMPEG packages in the default repos (or epel). After some DuckDuckGoing, I decided that FFMPEG is not packaged for CentOS 7 (yet?).

Time to get the standard tool set plus a little something for ffmpeg (yasm).

yum groupinstall "Development Tools"
yum install yasm

We will need to install libmp3lame and libvorbis before we compile ffmpeg. (This will allow you to encode to mp3 and ogg.)

Again, after some searching I decided that libmp3lame is not in CentOS 7's repos (epel or otherwise) so we will need to install it from source.

cd /usr/local/src
wget http://softlayer-dal.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar -xvf lame-3.99.5.tar.gz
rm lame-3.99.5.tar.gz
cd lame-3.99.5
./configure
make
make install

The next encoder, libvorbis, was easier to come by. Just had to install libvorbis-devel.

yum install libvorbis-devel

Now we can get the sourcecode for ffmpeg.

cd /usr/local/src
wget http://ffmpeg.org/releases/ffmpeg-2.4.3.tar.bz2
bunzip2 ffmpeg-2.4.3.tar.bz2
tar -xvf ffmpeg-2.4.3.tar
rm ffmpeg-2.4.3.tar

Configure and Compile. Make might take awhile...

(During make, you will probably get some warnings. This is 'normal'(?). AKA - it warned about deprecated items...but still worked)

cd /usr/local/src/ffmpeg-2.4.3
./configure --enable-libmp3lame --enable-libvorbis
make
make install

After that finished, I tried testing ffmpeg, but was hit with an unexpected error.

ffmpeg: error while loading shared libraries: libmp3lame.so.0: cannot open shared object file: No such file or directory"

Whoops...

Now, I bet there is a better way to do this, but for now I'm just going to symlink the library to /usr/lib and run ldconfig.

ln -s /usr/local/lib/libmp3lame.so.0.0.0 /usr/lib/libmp3lame.so.0
ldconfig

That should do it for ffmpeg with mp3 and ogg encoding.

Firewall

You will need to open ports 80 at the least and also port 443 if you plan to enable SSL.

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

SeLinux

SeLinux will probably step on you during the next steps. It caused issues on my setup with write permissions for the apache user and allowing a connection to the database.

setsebool -P httpd_unified on

Ampache First Time Setup

Just follow the steps and you should be good to go.

I plan to write up another doc targeted at using Ampache and setting up your first Catalog...but right now I'm lazy, so you will just have to wait or stumble through it on your own.