How to install Coppermine Photo Gallery on Ubuntu 16.04 LTS

Coppermine is a free, open source, fully featured and integrated photo gallery software written in PHP that allows us to publish and manage a collection of pictures, create personal photo albums, group albums by categories, send e-cards, organize images and photos, and many more.

In this tutorial, we will learn how to install Coppermine Photo Gallery on Ubuntu 16.04.

Prerequisites

  • A server running Ubuntu 16.04.
  • A non-root user with sudo privileges.

Install LAMP Server

Before starting, you will need to install LAMP (Apache, MariaDB and PHP7) to your system.

First, install Apache web server by running the following command:

sudo apt-get install apache2 -y

Once Apache is installed, start apache service and enable it to start on boot time with the following command:

sudo systemctl start apache2
sudo systemctl enable apache2

By default, the latest version of the MariaDB and PHP is not available in Ubuntu 16.04. So you will need to add the repository for that.

You can add the MariaDB and PHP repository with the following command:

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository ppa:ondrej/php
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://kartolo.sby.datautama.net.id/mariadb/repo/10.2/ubuntu xenial main'

Next, update the repository with the following command:

sudo apt-get update -y

Once the repository is updated, install MariaDB and PHP7 by running the following command:

sudo apt-get install mariadb-server libapache2-mod-php7.0 php7.0 php7.0-cli php7.0-common php7.0-curl php7.0-gd php7.0-intl php7.0-json php7.0-mysql php7.0-imagic imagemagick -y

Once all the packages are installed, start MariaDB server and enable it to start on boot time with the following command:

sudo systemctl start mysql
sudo systemctl enable mysql

Next, you will need to make some changes in php.ini file:

sudo nano /etc/php/7.0/cli/php.ini

Make the following changes:

max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 32M
upload_max_filesize = 32M
date.timezone = Asia/Kolkata

Save and close the file, when you are finished.

Configure MariaDB for Coppermine

First, you will need to secure MariaDB server. You can do this by running mysql_secure_installation script:

sudo mysql_secure_installation

Answer all the questions as shown below:

Set root password? [Y/n] Y
New password:
Re-enter new 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

Next, login to MariaDB shell and create a database and user for Coppermine:

mysql -u root -p

Enter your root password, then create a user and database for Coppermine with the following command:

MariaDB [(none)]> CREATE DATABASE copperminedb;
MariaDB [(none)]> CREATE USER 'coppermine'@'localhost' IDENTIFIED BY 'password';

Next, grant privileges to the Coppermine database with the following command:

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

Next, run the FLUSH PRIVILEGES command so that the privileges table will be reloaded by MariaDB:

MariaDB [(none)]> FLUSH PRIVILEGES;

Finally, exit from the MariaDB shell:

MariaDB [(none)]> EXIT

Install Coppermine

First, you will need to download the latest version of the Coppermine. You can do this by running the following command:

wget https://excellmedia.dl.sourceforge.net/project/coppermine/Coppermine/1.5.x/cpg1.5.46.zip

Next, extract the downloaded file with the following command:

unzip cpg1.5.46.zip

Next, copy extracted directory to the apache root directory:

sudo cp -r cpg15x /var/www/html/coppermine

Next, give proper permission to the coppermine directory:

sudo chown -R www-data:www-data /var/www/html/coppermine
sudo chmod -R 777 /var/www/html/coppermine

Configure Apache for Coppermine

Next, you will need to create an apache virtual host file for Coppermine. You can do this by running the following commmand:

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

Add the following lines:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/coppermine"
ServerName yourdomain.com
<Directory />
Options FollowSymLinks
AllowOverride All
<Directory "/var/www/html/coppermine/">
Options MultiViews FollowSymlinks
AllowOverride All Order allow,deny Allow from all </Directory> TransferLog /var/log/apache2/coppermine_access.log ErrorLog /var/log/apache2/coppermine_error.log </VirtualHost>

Save and close the file when you are finished, then enable virtual host with the following command:

sudo a2ensite coppermine

Finally, restart Apache service to apply all the changes:

sudo systemctl restart apache2

Access Coppermine

Open your web browser and type the URL http://yourdomain.com/install.php, you will be redirected to the following page:

Coppermine web installer

Here, choose the language and click on the Let's Go button, you should see the following page:

Start installation

Now, click on the click here button, you should see the following page:

Database settings

Here, provide your Coppermine admin credential and database details, then click on the Let's Go button you should see the following page:

Installation finished

The installation is now completed, click on the Let's Go button, you should see the following page:

Lets go

Here, provide your Admin login details, then click on Ok button, you should see the Coppermine dashboard in the following page:

Coppermine Photo Gallery Dashboard

Congratulations! you have successfully installed Coppermine in Ubuntu 16.04 server.

Share this page:

Suggested articles

2 Comment(s)

Add comment

Comments

From: Neil Groeber at: 2018-04-23 17:14:50

Configure Apache for Coppermine

Next, you will need to create an apache virtual host file for Coppermine. You can do this by running the following commmand:

sudo /etc/apache2/sites-available/coppermine.conf

Should this not be vi or nano between the sudo and the file path?

From: Neil Groeber at: 2018-04-23 17:22:37

<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/var/www/html/coppermine" ServerName yourdomain.com <Directory /> Options FollowSymLinks AllowOverride All <Directory "/var/www/html/coppermine/"> Options MultiViews FollowSymlinks AllowOverride All Order allow,deny Allow from all </Directory> TransferLog /var/log/apache2/coppermine_access.log ErrorLog /var/log/apache2/coppermine_error.log </VirtualHost>Syntax error on line 17 of /etc/apache2/sites-enabled/coppermine.conf: Expected </Directory> but saw </VirtualHost>