# Piwigo Installation and Configuration on gallery.deome.net

#### **Overview**
This page provides step-by-step instructions to install and configure Piwigo as a photo gallery on *gallery.deome.net*. This includes setting up the Apache virtual host, database configuration, and SSL with Let’s Encrypt.

---

#### **1. Prerequisites**

1. **Web Server**: Apache (see Apache wiki page).
2. **Database**: MariaDB (refer to MariaDB setup page).
3. **PHP**: Ensure PHP is installed along with the necessary modules:
   ```bash
   sudo apt install php php-mysql php-xml php-mbstring php-gd php-curl -y
   ```

---

#### **2. Download and Install Piwigo**

1. **Create the Document Root Directory**:
   - Create a directory for Piwigo:
     ```bash
     sudo mkdir -p /var/www/gallery
     ```

2. **Download Piwigo**:
   - Navigate to the gallery directory and download the latest Piwigo release:
     ```bash
     cd /var/www/gallery
     sudo wget https://piwigo.org/download/dlcounter.php?code=latest -O piwigo.zip
     sudo unzip piwigo.zip
     sudo mv piwigo/* ./
     sudo rm -rf piwigo piwigo.zip
     ```

3. **Set File Permissions**:
   - Make sure Apache has the correct permissions to access and modify the files:
     ```bash
     sudo chown -R www-data:www-data /var/www/gallery
     sudo chmod -R 755 /var/www/gallery
     ```

---

#### **3. Configure the Database**

1. **Log in to MariaDB**:
   ```bash
   sudo mysql -u root -p
   ```

2. **Create a Database and User for Piwigo**:
   ```sql
   CREATE DATABASE piwigodb;
   CREATE USER 'piwigouser'@'localhost' IDENTIFIED BY 'your_password';
   GRANT ALL PRIVILEGES ON piwigodb.* TO 'piwigouser'@'localhost';
   FLUSH PRIVILEGES;
   EXIT;
   ```

---

#### **4. Configure Apache Virtual Host for gallery.deome.net**

1. **Create the Virtual Host File**:
   - Open a new virtual host configuration file for *gallery.deome.net*:
     ```bash
     sudo nano /etc/apache2/sites-available/gallery.deome.net.conf
     ```

2. **Add the Virtual Host Configuration**:
   - Use the following configuration:
     ```apache
     <VirtualHost *:80>
       ServerName gallery.deome.net
       DocumentRoot /var/www/gallery
       <Directory /var/www/gallery>
           AllowOverride All
           Require all granted
       </Directory>
       ErrorLog ${APACHE_LOG_DIR}/gallery_error.log
       CustomLog ${APACHE_LOG_DIR}/gallery_access.log combined
     </VirtualHost>
     ```

3. **Enable the Site and Rewrite Module**:
   - Enable the virtual host and rewrite module, then reload Apache:
     ```bash
     sudo a2ensite gallery.deome.net.conf
     sudo a2enmod rewrite
     sudo systemctl reload apache2
     ```

---

#### **5. Set Up SSL with Let’s Encrypt**

1. **Install Certbot**:
   - If Certbot is not already installed:
     ```bash
     sudo apt install certbot python3-certbot-apache -y
     ```

2. **Generate SSL Certificate**:
   - Use Certbot to obtain an SSL certificate for *gallery.deome.net*:
     ```bash
     sudo certbot --apache -d gallery.deome.net
     ```

3. **Enable Auto-Renewal**:
   - Certbot will automatically handle renewal. Test the setup with:
     ```bash
     sudo certbot renew --dry-run
     ```

---

#### **6. Complete Piwigo Setup**

1. **Access the Piwigo Installation Wizard**:
   - Open a browser and go to `https://gallery.deome.net`. You should see the Piwigo setup wizard.

2. **Follow the Setup Wizard**:
   - Enter the database information:
     - **Database Name**: `piwigodb`
     - **Database User**: `piwigouser`
     - **Database Password**: `your_password`
   - Configure the admin account and complete the setup.

---

#### **7. Testing and Verification**

1. **Access Piwigo**:
   - Verify that Piwigo loads correctly at `https://gallery.deome.net`.

2. **Check Logs**:
   - Monitor the Apache logs if any issues arise:
     ```bash
     sudo tail -f /var/log/apache2/gallery_access.log
     sudo tail -f /var/log/apache2/gallery_error.log
     ```

---

#### **8. Maintenance and Updates**

1. **Database Backup**:
   - Set up regular database backups:
     ```bash
     mysqldump -u root -p piwigodb > /path/to/backup/piwigodb.sql
     ```

2. **Updating Piwigo**:
   - Periodically check for updates in the Piwigo admin dashboard.

---

This setup should get Piwigo running smoothly on *gallery.deome.net*. Let me know if you need any specific configurations or additional settings!