Zenphoto is a lightweight, open-source content management system (CMS) tailored specifically for managing photo galleries, multimedia, and blogs. Designed with simplicity and extensibility in mind, itβs perfect for self-hosting enthusiasts who value data control, deep customization, and independence from third-party platforms. In this guide, weβll cover everything you need to deploy, configure, and manage your Zenphoto instance, including installation, setting up a reverse proxy, logging, backups, updates, and leveraging its unique features.
Installing Zenphoto
π¦ Docker/Docker Compose Setup
Deploying Zenphoto with Docker is a clean and efficient method. This docker-compose.yml
file configures the application, database, and persistent volumes for data storage.
version: '3.9'
services:
zenphoto:
image: zenphoto/zenphoto:latest
container_name: zenphoto
ports:
- "8080:80"
volumes:
- ./zenphoto_data:/var/www/html
environment:
- DB_HOST=mariadb
- DB_NAME=zenphoto
- DB_USER=zenphoto_user
- DB_PASSWORD=securepassword
depends_on:
- mariadb
mariadb:
image: mariadb:10.5
container_name: mariadb
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_DATABASE=zenphoto
- MYSQL_USER=zenphoto_user
- MYSQL_PASSWORD=securepassword
volumes:
- ./mariadb_data:/var/lib/mysql
Run the commands below to deploy Zenphoto:
mkdir zenphoto && cd zenphoto
## Save the docker-compose.yml file
nano docker-compose.yml
## Deploy the containers
docker-compose up -d
## Check the container status
docker ps
Visit http://<your-server-ip>:8080
and follow the web-based installation wizard to complete the setup.
π Manual Installation
For those who prefer manual deployment, follow these steps to set up Zenphoto on a Linux server:
## Update system packages
sudo apt update && sudo apt upgrade -y
## Install dependencies
sudo apt install apache2 php php-mysqli unzip wget -y
## Install MariaDB
sudo apt install mariadb-server -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
## Secure the MariaDB installation
sudo mysql_secure_installation
## Create a database and user for Zenphoto
sudo mysql -u root -p -e "CREATE DATABASE zenphoto; CREATE USER 'zenphoto_user'@'localhost' IDENTIFIED BY 'securepassword'; GRANT ALL PRIVILEGES ON zenphoto.* TO 'zenphoto_user'@'localhost'; FLUSH PRIVILEGES;"
## Download and extract Zenphoto
wget https://github.com/zenphoto/zenphoto/releases/latest/download/Zenphoto.zip
unzip Zenphoto.zip
sudo mv zenphoto /var/www/html/
sudo chown -R www-data:www-data /var/www/html/zenphoto
## Restart Apache
sudo systemctl restart apache2
Visit http://<your-server-ip>/zenphoto
to complete the configuration.
Configuring Nginx as a Reverse Proxy
π Nginx Configuration
Set up Nginx as a reverse proxy to serve Zenphoto and improve performance.
## Install Nginx
sudo apt install nginx -y
## Configure Nginx for Zenphoto
sudo nano /etc/nginx/sites-available/zenphoto
Add the following server block:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_log /var/log/nginx/zenphoto_error.log;
access_log /var/log/nginx/zenphoto_access.log;
}
Enable the configuration and reload Nginx:
sudo ln -s /etc/nginx/sites-available/zenphoto /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
π SSL/TLS Setup
Secure your Zenphoto instance with Let's Encrypt SSL:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com
Automate renewal:
sudo systemctl enable certbot.timer
π οΈ Testing and Reloading Nginx
Validate the configuration and check the status:
sudo nginx -t
sudo systemctl reload nginx
Logging and Debugging Zenphoto
ποΈ Enabling Debug Logs
Enable debug logging in Zenphoto by editing the zp-config.php
file:
define('DEBUG_LOGGING', true);
π Viewing Logs
If using Docker, view logs with:
docker logs zenphoto
For manual installations, check the log files:
tail -f /var/www/html/zenphoto/zp-core/logs/*.log
π οΈ Troubleshooting Common Issues
If Zenphoto is unreachable, confirm permissions:
sudo chown -R www-data:www-data /var/www/html/zenphoto
Restart services as needed:
sudo systemctl restart apache2 mariadb
π€ Exporting Logs
Export logs to an ELK Stack (Elasticsearch, Logstash, Kibana) using Filebeat:
sudo apt install filebeat -y
sudo nano /etc/filebeat/filebeat.yml
Configure the input to monitor zp-core/logs/
.
Backup and Restore
ποΈ File-Based Backups
Backup Zenphoto files with:
tar -czvf zenphoto_backup.tar.gz /var/www/html/zenphoto
π Database Backups
Dump the database with:
mysqldump -u zenphoto_user -p zenphoto > zenphoto_db_backup.sql
Restore the database:
mysql -u zenphoto_user -p zenphoto < zenphoto_db_backup.sql
π Automated Backup Scripts
Schedule backups using cron:
crontab -e
Add the following line to create nightly backups:
0 2 * * * tar -czvf /backups/zenphoto_backup.tar.gz /var/www/html/zenphoto && mysqldump -u zenphoto_user -pzenphoto_password zenphoto > /backups/zenphoto_db_backup.sql
Updating and Upgrading Zenphoto
β¬οΈ Updating Docker Images
To update a Docker-based installation:
docker-compose pull
docker-compose up -d
π οΈ Manual Updates
For manual updates, download the latest version, replace the files, and run the upgrade script:
wget https://github.com/zenphoto/zenphoto/releases/latest/download/Zenphoto.zip
unzip -o Zenphoto.zip -d /var/www/html/zenphoto
sudo chown -R www-data:www-data /var/www/html/zenphoto
Visit the admin dashboard to finalize the upgrade.
π Checking for Updates
Regularly monitor the Zenphoto GitHub page for new releases.
Leveraging Zenphotoβs Unique Features
π§ Enabling APIs
Enable Zenphotoβs API features in zp-config.php
:
define('API_ENABLED', true);
Query the API with curl
:
curl -X GET "http://yourdomain.com/api/photos" -H "Authorization: Bearer YOUR_TOKEN"
π Advanced Configurations
Add custom themes or plugins by uploading them to the themes
or plugins
directories. Adjust settings in the admin panel to enable them.
Wrapping Up
Zenphoto offers a powerful, self-hosted platform for managing photo galleries and multimedia content. By following this guide, youβve learned how to deploy Zenphoto, secure it with SSL, monitor logs, set up backups, and leverage its unique features. Dive into your Zenphoto instance today to enjoy full control and customization of your gallery management experience!