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:
nginxphp-fpm
Step 1 - Install Coppermine
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.zipNext, move the extracted directory to the
/var/wwwdirectory:# mv coppermine-1.6.x /var/www/coppermine # chown -R www-data:www-data /var/www/coppermineCreate a new virtual host file for Coppermine:
# nano /etc/nginx/sites-available/coppermine.confAdd 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.comwith your own domain name or IP address.Create a symbolic link of the virtual host file to the
sites-enableddirectory:# 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 -tRestart Nginx to apply the changes:
# systemctl restart nginx
Step 2 - Configure MySQL Database
Install MySQL server and client:
# nix-env -i mysql mysql-clientStart the MySQL service:
# systemctl start mysqlConnect to the MySQL server using the root user:
# mysql -u root -pCreate 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
passwordwith 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.sqlEnter the password of the
coppermineuser.
Step 3 - Configure Coppermine
Open the Coppermine configuration file:
# nano /var/www/coppermine/include/config.inc.phpUpdate the following configurations:
$CONFIG['dbuser'] = 'coppermineuser'; $CONFIG['dbpass'] = 'password'; $CONFIG['dbname'] = 'coppermine';Replace
passwordwith the password you set previously.Save and close the file.
Step 4 - Access Coppermine
- Open your web browser and navigate to
http://yourdomain.comorhttp://your-ip-address. - Coppermine installation wizard should appear. Follow the on-screen instructions to complete the installation.
- After installation, remove the
installdirectory 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!