How To Install Piwigo on Ubuntu 24.04 LTS
Piwigo is a robust, open-source photo gallery software that allows you to create and manage your own online photo gallery. Whether you’re a professional photographer or someone who loves organizing personal photos, Piwigo offers a flexible and feature-rich solution. This guide provides a detailed, step-by-step process to install Piwigo on Ubuntu 24.04 LTS, ensuring a smooth and efficient setup.
Prerequisites
Before diving into the installation process, ensure that your system meets the following requirements:
- Operating System: Ubuntu 24.04 LTS installed and updated.
- Access: A non-root sudo user with administrative privileges.
- Firewall: Properly configured to allow necessary traffic.
- LAMP Stack: Linux, Apache, MySQL/MariaDB, and PHP installed.
- Terminal Access: Ability to execute commands via SSH or direct terminal access.
Additionally, ensure that your server has sufficient resources to handle your photo gallery’s expected traffic and storage needs.
System Preparation
1. Update Package Repositories
Start by updating your system’s package repositories to ensure you have the latest software versions:
sudo apt update
sudo apt upgrade -y
2. Install Apache Web Server
Apache is a widely-used web server that will host your Piwigo gallery:
sudo apt install apache2 -y
3. Install PHP and Necessary Extensions
Piwigo requires PHP along with several extensions. Install them using the following command:
sudo apt install php libapache2-mod-php php-gd php-mysql php-xml php-mbstring php-curl -y
4. Install MySQL/MariaDB
Piwigo uses a MySQL or MariaDB database to store its data. Install MariaDB with:
sudo apt install mariadb-server mariadb-client -y
5. Secure MySQL/MariaDB Installation
Run the security script to secure your database installation:
sudo mysql_secure_installation
Follow the prompts to set a root password, remove anonymous users, disallow remote root login, and remove test databases.
6. Configure PHP Settings
Adjust PHP settings to meet Piwigo’s requirements. Edit the PHP configuration file:
sudo nano /etc/php/8.2/apache2/php.ini
Ensure the following settings are configured:
- memory_limit: Set to at least 128M
- upload_max_filesize: Set according to your needs, e.g., 50M
- post_max_size: Should be larger than upload_max_filesize, e.g., 100M
- max_execution_time: Set to 300
After making changes, save and close the file.
7. Restart Apache to Apply Changes
Restart the Apache service to apply the new PHP settings:
sudo systemctl restart apache2
Installing Piwigo
1. Download Piwigo
Navigate to the official Piwigo website to get the latest version. Use wget to download it directly to your server:
wget https://piwigo.org/download/dlcounter.php?code=latest -O piwigo.zip
2. Extract the Downloaded Archive
Unzip the downloaded Piwigo package into the Apache web root directory:
sudo unzip piwigo.zip -d /var/www/html/
3. Set Correct Permissions
Assign proper ownership and permissions to the Piwigo directory to ensure Apache can read and write as needed:
sudo chown -R www-data:www-data /var/www/html/piwigo
sudo chmod -R 755 /var/www/html/piwigo
4. Configure Apache for Piwigo
Create a new Apache configuration file for your Piwigo site:
sudo nano /etc/apache2/sites-available/piwigo.conf
Add the following content, replacing your_domain.com
with your actual domain:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName your_domain.com
DocumentRoot /var/www/html/piwigo
<Directory /var/www/html/piwigo>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
5. Enable the New Site and Rewrite Module
Enable your Piwigo site configuration and the Apache rewrite module:
sudo a2ensite piwigo.conf
sudo a2enmod rewrite
6. Restart Apache to Apply Changes
Restart Apache to load the new configuration:
sudo systemctl restart apache2
Database Configuration
1. Log into MySQL/MariaDB
Access the MySQL shell as the root user:
sudo mysql -u root -p
2. Create a Database for Piwigo
Create a new database named piwigo_db
:
CREATE DATABASE piwigo_db;
3. Create a Database User
Create a new user piwigo_user
with a strong password:
CREATE USER 'piwigo_user'@'localhost' IDENTIFIED BY 'YourStrongPassword';
4. Grant Necessary Permissions
Grant all privileges on the piwigo_db
database to the new user:
GRANT ALL PRIVILEGES ON piwigo_db.* TO 'piwigo_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Web-Based Installation
1. Access the Installation Wizard
Open your web browser and navigate to http://your_domain.com
or http://your_server_ip/piwigo
. This will trigger the Piwigo installation wizard.
2. Step-by-Step Configuration
Follow these steps in the installation wizard:
- Welcome: Click on “Start installation”.
- Database Configuration: Enter the database name (
piwigo_db
), username (piwigo_user
), and password you set earlier. - Administrator Account: Create an admin username and password for managing your gallery.
- Gallery Settings: Configure basic settings such as gallery title, language, and URL.
- Finalize Installation: Review your settings and complete the installation.
Once completed, you will be redirected to your new Piwigo gallery dashboard.
Post-Installation Tasks
1. Security Hardening
Enhance the security of your Piwigo installation by implementing the following measures:
- Enable SSL/TLS: Use Let’s Encrypt to secure your site with HTTPS.
- Restrict File Permissions: Ensure configuration files are not writable by unauthorized users.
- Regular Updates: Keep your system and Piwigo installation updated to patch vulnerabilities.
2. Performance Optimization
Improve the performance of your photo gallery with these tips:
- Enable Caching: Use caching mechanisms like
mod_cache
in Apache. - Optimize Images: Compress images without losing quality to reduce load times.
- Content Delivery Network (CDN): Utilize a CDN to distribute your content globally.
3. Backup Solutions
Set up regular backups to prevent data loss:
- Database Backups: Schedule regular dumps of your MySQL/MariaDB database.
- File Backups: Backup the
piwigo
directory to preserve your gallery and configurations.
4. Test Functionality
Ensure that your Piwigo installation is functioning correctly:
- Upload a few photos and verify they appear correctly in the gallery.
- Check user permissions and ensure only authorized users can access certain areas.
- Test different browsers and devices to confirm compatibility.
Advanced Configuration
1. Custom Themes Installation
Personalize your gallery by installing custom themes:
- Download themes from the official Piwigo website or third-party providers.
- Upload the theme to the
themes
directory using FTP or your preferred method. - Activate the theme from the Piwigo admin dashboard under “Themes”.
2. Plugin Management
Enhance Piwigo’s functionality with plugins:
- Navigate to the “Plugins” section in the admin dashboard.
- Browse and install plugins that suit your needs, such as SEO tools, social media integrations, or enhanced photo management features.
- Configure each plugin according to its documentation to optimize performance.
3. User Management Setup
Manage user roles and permissions to control access to your gallery:
- Create user accounts for contributors, moderators, and administrators.
- Assign appropriate roles to ensure users have the necessary permissions without compromising security.
- Regularly review and update user roles as needed.
4. Gallery Organization Tips
Organize your photos efficiently to enhance user experience:
- Create albums and sub-albums to categorize your photos logically.
- Utilize tags and keywords to make searching for specific photos easier.
- Enable sorting options such as date, popularity, or custom criteria.
5. Performance Tweaks
Fine-tune your server and Piwigo settings for optimal performance:
- Enable gzip compression in Apache to reduce page load times.
- Configure PHP’s OPcache to speed up PHP script execution.
- Monitor server resources and optimize as necessary to handle increased traffic.
Troubleshooting Common Issues
1. Permission Problems
If you encounter permission denied errors, ensure that the Piwigo directory has the correct ownership and permissions:
sudo chown -R www-data:www-data /var/www/html/piwigo
sudo chmod -R 755 /var/www/html/piwigo
2. Database Connection Issues
Verify your database credentials and ensure that the MySQL/MariaDB service is running:
- Check the
piwigo_conf.php
file for correct database details. - Restart the database service if necessary:
sudo systemctl restart mariadb
3. Upload Limitations
If you’re unable to upload large photos, adjust the PHP settings:
- Increase
upload_max_filesize
andpost_max_size
inphp.ini
. - Restart Apache to apply changes:
sudo systemctl restart apache2
4. Memory Constraints
Allocate more memory to PHP if you encounter memory limit errors:
- Set a higher
memory_limit
inphp.ini
, for example:
memory_limit = 256M
Restart Apache to apply the change:
sudo systemctl restart apache2
5. Web Server Conflicts
Ensure no other services are conflicting with Apache on port 80. Use the following command to check:
sudo lsof -i :80
If another service is using port 80, consider stopping it or changing Apache’s listening port.
Maintenance and Updates
1. Regular Backups
Implement a backup strategy to safeguard your data:
- Schedule automated backups of your database using
mysqldump
. - Backup the Piwigo directory to preserve your photo gallery and configurations.
- Store backups on an external server or cloud storage for redundancy.
2. Update Management
Keep your system and Piwigo installation up to date:
- Regularly update Ubuntu packages:
sudo apt update
sudo apt upgrade -y
Check for Piwigo updates in the admin dashboard and apply them promptly to benefit from new features and security patches.
3. Security Patches
Stay informed about security updates for Apache, PHP, and your database system. Apply patches as they become available to protect against vulnerabilities.
4. Performance Monitoring
Use monitoring tools to track your server’s performance:
- Install and configure tools like htop or Netdata to monitor system resources.
- Analyze Piwigo’s performance reports to identify and address bottlenecks.
5. Health Checks
Regularly perform health checks to ensure your Piwigo gallery is running smoothly:
- Verify that all photos are accessible and properly displayed.
- Check for broken links and fix them promptly.
- Ensure that user accounts and permissions remain correctly configured.
Congratulations! You have successfully installed Piwigo. Thanks for using this tutorial for installing the Piwigo Photo Gallery on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Piwigo website.