How to Install Coppermine on nixOS Latest

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.

Prerequisites

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:

Step 1 - Install Coppermine

  1. 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
    
  2. 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
    
  3. Create a new virtual host file for Coppermine:

    # nano /etc/nginx/sites-available/coppermine.conf
    
  4. 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.

  5. 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/
    
  6. Test the Nginx configuration and make sure there are no syntax errors:

    # nginx -t
    
  7. Restart Nginx to apply the changes:

    # systemctl restart nginx
    

Step 2 - Configure MySQL Database

  1. Install MySQL server and client:

    # nix-env -i mysql mysql-client
    
  2. Start the MySQL service:

    # systemctl start mysql
    
  3. Connect to the MySQL server using the root user:

    # mysql -u root -p
    
  4. 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.

  5. 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.

Step 3 - Configure Coppermine

  1. Open the Coppermine configuration file:

    # nano /var/www/coppermine/include/config.inc.php
    
  2. Update the following configurations:

    $CONFIG['dbuser'] = 'coppermineuser';
    $CONFIG['dbpass'] = 'password';
    $CONFIG['dbname'] = 'coppermine';
    

    Replace password with the password you set previously.

  3. Save and close the file.

Step 4 - Access Coppermine

  1. Open your web browser and navigate to http://yourdomain.com or http://your-ip-address.
  2. Coppermine installation wizard should appear. Follow the on-screen instructions to complete the installation.
  3. After installation, remove the 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!