Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

How to Install Piwigo with Apache on Ubuntu 24.04

How to Install Piwigo with Apache on Ubuntu 24.04

Setting up a photo gallery website can be a rewarding way to showcase your images online. Piwigo is a popular open-source photo management system that allows you to organize, share, and manage your photos with ease. Installing Piwigo on Ubuntu 24.04 using Apache provides a reliable and scalable platform for your gallery. This guide walks you through each step, ensuring a smooth setup process. Before starting, ensure your Ubuntu server is up-to-date and has a stable internet connection. You will also need root or sudo privileges to install and configure the necessary software.

What You’ll Need

  • Ubuntu 24.04 Server with sudo privileges
  • Root or sudo access to the server
  • Stable internet connection
  • Basic knowledge of Linux commands

Step-by-Step

  1. Update Your System Packages
    sudo apt update && sudo apt upgrade -y

    Ensure your system is current to prevent compatibility issues during installation.

  2. Install Apache Web Server
    sudo apt install apache2 -y

    Apache will serve your Piwigo website. Enable and start Apache if not already running:

    sudo systemctl enable apache2
    sudo systemctl start apache2
  3. Install PHP and Required Modules
    Piwigo requires PHP and specific modules to operate properly.

    sudo apt install php php-mysql php-gd php-xml php-mbstring php-zip php-curl php-xmlrpc -y

    Verify PHP version:

    php -v
  4. Install Database Server (MySQL/MariaDB)
    You can choose either; here, we install MariaDB:

    sudo apt install mariadb-server -y

    Secure your MariaDB installation:

    sudo mysql_secure_installation

    Follow the prompts to set a root password and secure your database server.

  5. Create a Database and User for Piwigo
    Log into MariaDB:

    sudo mysql -u root -p

    Create a new database and user:

    CREATE DATABASE piwigodb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    CREATE USER 'piwigouser'@'localhost' IDENTIFIED BY 'your_secure_password';
    GRANT ALL PRIVILEGES ON piwigodb.* TO 'piwigouser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
  6. Download Piwigo
    Navigate to your web directory and download the latest Piwigo package:

    cd /var/www/html
    sudo wget https://github.com/Piwigo/Piwigo/releases/latest/download/piwigo.zip

    Unzip the package:

    sudo apt install unzip -y
    sudo unzip piwigo.zip -d piwigo

    Set proper permissions:

    sudo chown -R www-data:www-data /var/www/html/piwigo
  7. Configure Apache Virtual Host
    Create a new configuration file:

    sudo nano /etc/apache2/sites-available/piwigo.conf

    Insert the following configuration, replacing ‘yourdomain.com’ with your actual domain:

    <VirtualHost *:80>
        ServerName yourdomain.com
        DocumentRoot /var/www/html/piwigo
        <Directory /var/www/html/piwigo>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/piwigo_error.log
        CustomLog ${APACHE_LOG_DIR}/piwigo_access.log combined
    </VirtualHost>

    Enable the site and rewrite module:

    sudo a2ensite piwigo.conf
    sudo a2enmod rewrite
    sudo systemctl reload apache2
  8. Complete the Web Installation
    Open your browser and navigate to http://yourdomain.com or http://server-ip.
    Follow the on-screen instructions to connect to your database and complete the installation.
    Set your admin account, site name, and other preferences. Once finished, delete the install directory for security:

    sudo rm -rf /var/www/html/piwigo/install

Common Mistakes

  • Not updating the system packages before starting, leading to compatibility issues.
  • Forgetting to set proper permissions on the Piwigo directory, causing access problems.
  • Using incorrect database credentials during the web setup, resulting in connection errors.
  • Not enabling Apache rewrite module, which is essential for pretty permalinks.
  • Leaving the install directory intact after setup, which poses a security risk.
  • Failing to restart or reload Apache after configuration changes.

Tips

  • Use strong, unique passwords for your database user and admin account.
  • Configure a firewall (like UFW) to restrict access to your server, allowing only necessary ports.
  • Enable HTTPS with an SSL certificate for secure data transmission, using Let’s Encrypt.
  • Regularly update your system and Piwigo installation to patch security vulnerabilities.
  • Set up automatic backups of your database and Piwigo files to prevent data loss.
  • Use a domain name instead of IP address for easier access and better branding.

Troubleshooting

If you encounter issues during installation or access:

  • Unable to access Piwigo after setup: Check Apache error logs with sudo tail -f /var/log/apache2/error.log. Ensure permissions are correct and that the virtual host is enabled.
  • Database connection errors: Verify database credentials and ensure the database server is running. Test connection with mysql -u piwigouser -p -D piwigodb.
  • Site not displaying correctly or permalinks broken: Ensure AllowOverride All is set in your Apache configuration and that mod_rewrite is enabled.
  • PHP errors or missing modules: Check PHP error logs and verify all required modules are installed and enabled.
  • SSL issues: Confirm your SSL certificate is correctly installed and configured, and that your site is accessible via HTTPS.

In case of persistent problems, consult the Piwigo community forums or official documentation for further assistance.

Frequently Asked Questions

1. Can I install Piwigo without using a domain name?

Yes, you can access Piwigo via your server’s IP address, but using a domain name is recommended for easier access and SSL setup.

2. Is Piwigo secure to run on my server?

When properly configured with permissions, SSL, and regular updates, Piwigo is secure. Always follow security best practices.

3. How do I update Piwigo to the latest version?

Download the latest release, replace the old files (except for config files and uploads), and run the upgrade script via the web interface.

4. Can I customize the appearance of my Piwigo site?

Yes, Piwigo supports themes and plugins. You can install new themes or develop custom ones via the admin panel.

5. How do I add new photos to my gallery?

Upload images via the web interface or via FTP into the uploads directory. Piwigo will automatically process and add them to your gallery.

6. Is it possible to migrate an existing gallery to Piwigo?

Migration may require exporting your current data and importing it into Piwigo using plugins or manual methods. Check Piwigo documentation for migration guides.

Following these steps will help you successfully install and run Piwigo with Apache on Ubuntu 24.04, giving you a powerful platform to showcase your photos online with confidence and ease.

Related

How to Install Piwigo with Apache on Ubuntu 24.04
Scroll to top