Coppermine is a free, open-source, and powerful web-based photo gallery software. In this tutorial, we will learn how to install Coppermine on nixOS Latest.
Before we start, make sure your nixOS system is up-to-date and you have root access. Also, ensure that you have installed the following packages:
nginx
php-fpm
First, download the latest version of Coppermine from the official website:
# sudo su -
# cd /tmp
# wget https://github.com/coppermine-gallery/coppermine/archive/1.6.x.zip
# unzip 1.6.x.zip
Next, move the extracted directory to the /var/www
directory:
# mv coppermine-1.6.x /var/www/coppermine
# chown -R www-data:www-data /var/www/coppermine
Create a new virtual host file for Coppermine:
# nano /etc/nginx/sites-available/coppermine.conf
Add the following lines to the virtual host file:
server {
listen 80;
root /var/www/coppermine;
index index.php;
server_name yourdomain.com;
location / {
try_files $uri $uri/ /index.php;
}
location ~* \.(jpg|jpeg|gif|png|ico|css|js)$ {
expires 365d;
log_not_found off;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
}
}
Replace yourdomain.com
with your own domain name or IP address.
Create a symbolic link of the virtual host file to the sites-enabled
directory:
# ln -s /etc/nginx/sites-available/coppermine.conf /etc/nginx/sites-enabled/
Test the Nginx configuration and make sure there are no syntax errors:
# nginx -t
Restart Nginx to apply the changes:
# systemctl restart nginx
Install MySQL server and client:
# nix-env -i mysql mysql-client
Start the MySQL service:
# systemctl start mysql
Connect to the MySQL server using the root user:
# mysql -u root -p
Create a new database and user for Coppermine:
mysql> CREATE DATABASE coppermine;
mysql> GRANT ALL PRIVILEGES ON coppermine.* TO 'coppermineuser'@'localhost' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> exit;
Replace password
with a secure password of your choice.
Import the Coppermine database schema to the newly created database:
# mysql -u coppermineuser -p coppermine < /var/www/coppermine/coppermine.sql
Enter the password of the coppermineuser
.
Open the Coppermine configuration file:
# nano /var/www/coppermine/include/config.inc.php
Update the following configurations:
$CONFIG['dbuser'] = 'coppermineuser';
$CONFIG['dbpass'] = 'password';
$CONFIG['dbname'] = 'coppermine';
Replace password
with the password you set previously.
Save and close the file.
http://yourdomain.com
or http://your-ip-address
.install
directory inside the Coppermine directory for security reasons:# rm -rf /var/www/coppermine/install/
Congratulations! You have successfully installed Coppermine on nixOS Latest. You can now start uploading your photos and creating albums. Enjoy!
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!