# Web Server Setup & Applications



# MariaDB Installation and Configuration

### **MariaDB Installation and Configuration**

#### **Overview**
This page provides step-by-step instructions for installing MariaDB on *buzz.deome.net* and configuring it to work with applications like BookStack and the photo gallery.

---

#### **1. Installing MariaDB**

1. **Update the System**:
   - Ensure all packages are up-to-date.
     ```bash
     sudo apt update && sudo apt upgrade -y
     ```

2. **Install MariaDB Server**:
   - Use the following command to install MariaDB:
     ```bash
     sudo apt install mariadb-server -y
     ```

3. **Start and Enable MariaDB**:
   - Start the MariaDB service and enable it to start on boot:
     ```bash
     sudo systemctl start mariadb
     sudo systemctl enable mariadb
     ```

4. **Verify Installation**:
   - Check the MariaDB version to confirm it is installed:
     ```bash
     mysql --version
     ```
   - You should see output confirming the MariaDB version, as shown in your initial check.

---

#### **2. Initial MariaDB Configuration**

1. **Run the Security Script**:
   - MariaDB provides a security script to help you configure common security settings.
     ```bash
     sudo mysql_secure_installation
     ```
   - This script will prompt you to:
     - Set a root password.
     - Remove anonymous users.
     - Disallow remote root login.
     - Remove test databases.
   - Answer each prompt as needed to secure the installation.

2. **Log in as the Root User**:
   - After configuring security, log in to MariaDB:
     ```bash
     sudo mysql -u root -p
     ```

3. **Create a New Database and User for Each Application**:
   - **Database for BookStack**:
     ```sql
     CREATE DATABASE bookstackdb;
     CREATE USER 'bookstackuser'@'localhost' IDENTIFIED BY 'your_password';
     GRANT ALL PRIVILEGES ON bookstackdb.* TO 'bookstackuser'@'localhost';
     FLUSH PRIVILEGES;
     ```
   - **Database for Photo Gallery**:
     ```sql
     CREATE DATABASE gallerydb;
     CREATE USER 'galleryuser'@'localhost' IDENTIFIED BY 'your_password';
     GRANT ALL PRIVILEGES ON gallerydb.* TO 'galleryuser'@'localhost';
     FLUSH PRIVILEGES;
     ```
   - Replace `your_password` with secure passwords.

4. **Exit MariaDB**:
   - Once databases and users are set up, exit MariaDB:
     ```sql
     EXIT;
     ```

---

#### **3. Basic MariaDB Configuration Options**

1. **Optimize Settings (Optional)**:
   - Open the MariaDB configuration file:
     ```bash
     sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
     ```
   - Modify settings under `[mysqld]` as needed. Example optimizations:
     ```ini
     max_connections = 100
     innodb_buffer_pool_size = 256M
     ```
   - Save and close the file.

2. **Restart MariaDB**:
   - Apply changes by restarting the MariaDB service:
     ```bash
     sudo systemctl restart mariadb
     ```

---

#### **4. Testing and Verification**

1. **Verify Databases and Users**:
   - Log in as root and list the databases to confirm they were created:
     ```bash
     sudo mysql -u root -p
     SHOW DATABASES;
     ```

2. **Connect Using Each Application’s Credentials**:
   - Use the created usernames and passwords to confirm access for BookStack and the gallery:
     ```bash
     mysql -u bookstackuser -p
     mysql -u galleryuser -p
     ```

3. **Connection from Applications**:
   - Ensure that *BookStack* and the photo gallery application can connect to MariaDB using the specified database names and credentials.

---

#### **5. Maintenance and Backup**

1. **Automate Backups**:
   - Create a cron job to back up each database:
     ```bash
     mysqldump -u root -p bookstackdb > /path/to/backup/bookstackdb.sql
     mysqldump -u root -p gallerydb > /path/to/backup/gallerydb.sql
     ```

2. **Update MariaDB**:
   - Periodically check for updates to keep MariaDB secure and optimized:
     ```bash
     sudo apt update && sudo apt upgrade mariadb-server

# Apache Web Server Installation and Configuration

### **Apache Web Server Installation and Configuration**

#### **Overview**
This page provides instructions for setting up and configuring Apache on *buzz.deome.net*. It includes steps for installing Apache, configuring virtual hosts for multiple sites, securing with SSL certificates, and basic performance tuning.

---

#### **1. Apache Installation**

1. **Update System Packages**:
   - Start by updating the package list and upgrading existing packages:
     ```bash
     sudo apt update && sudo apt upgrade -y
     ```

2. **Install Apache**:
   - Install Apache with the following command:
     ```bash
     sudo apt install apache2 -y
     ```

3. **Start and Enable Apache**:
   - Start the Apache service and enable it to run on boot:
     ```bash
     sudo systemctl start apache2
     sudo systemctl enable apache2
     ```

4. **Verify Installation**:
   - Check the Apache status to ensure it’s running:
     ```bash
     sudo systemctl status apache2
     ```

---

#### **2. Basic Apache Configuration**

1. **Main Configuration File**:
   - The main Apache configuration file is located at:
     ```bash
     /etc/apache2/apache2.conf
     ```

2. **Enable Recommended Modules**:
   - Enable commonly used modules:
     ```bash
     sudo a2enmod rewrite ssl headers
     ```
   - Restart Apache to apply the changes:
     ```bash
     sudo systemctl restart apache2
     ```

---

#### **3. Setting Up Virtual Hosts**

1. **Create a New Virtual Host**:
   - For each site, create a configuration file in `/etc/apache2/sites-available/`. For example, for *wiki.deome.net*:
     ```bash
     sudo nano /etc/apache2/sites-available/wiki.deome.net.conf
     ```
   - Add the following configuration:
     ```apache
     <VirtualHost *:80>
       ServerName wiki.deome.net
       DocumentRoot /var/www/wiki
       <Directory /var/www/wiki>
           AllowOverride All
       </Directory>
       ErrorLog ${APACHE_LOG_DIR}/wiki_error.log
       CustomLog ${APACHE_LOG_DIR}/wiki_access.log combined
     </VirtualHost>
     ```

2. **Enable the Virtual Host**:
   - Use `a2ensite` to enable each virtual host:
     ```bash
     sudo a2ensite wiki.deome.net.conf
     ```
   - Reload Apache to apply changes:
     ```bash
     sudo systemctl reload apache2
     ```

3. **Repeat for Additional Sites**:
   - Create similar configuration files for *gallery.deome.net*, *buzz.deome.net*, and any other sites you plan to host.

---

#### **4. SSL Configuration with Let’s Encrypt**

1. **Install Certbot**:
   - Install Certbot to automate SSL certificate generation:
     ```bash
     sudo apt install certbot python3-certbot-apache -y
     ```

2. **Generate SSL Certificates**:
   - Use Certbot to obtain SSL certificates for each virtual host:
     ```bash
     sudo certbot --apache -d wiki.deome.net
     sudo certbot --apache -d gallery.deome.net
     ```
   - Certbot will automatically configure SSL for the specified domains.

3. **Set Up Auto-Renewal**:
   - To ensure certificates renew automatically:
     ```bash
     sudo certbot renew --dry-run
     ```

---

#### **5. Performance and Optimization**

1. **Adjust Apache Settings**:
   - Open the main Apache configuration file:
     ```bash
     sudo nano /etc/apache2/apache2.conf
     ```
   - Consider modifying these settings under the `mpm_prefork_module` or `mpm_worker_module`:
     ```apache
     KeepAlive On
     MaxKeepAliveRequests 100
     KeepAliveTimeout 5
     ```

2. **Enable Caching**:
   - Install and enable Apache caching modules if desired:
     ```bash
     sudo a2enmod cache
     sudo a2enmod cache_disk
     sudo systemctl restart apache2
     ```

3. **Optimize Logging**:
   - Adjust log levels or configure centralized logging if needed. Logging configuration is in each virtual host file and `/etc/apache2/apache2.conf`.

---

#### **6. Maintenance and Monitoring**

1. **Monitor Apache Status**:
   - Check Apache’s status periodically:
     ```bash
     sudo systemctl status apache2
     ```

2. **Check Logs**:
   - Access logs for each virtual host in `/var/log/apache2/`, e.g.:
     ```bash
     sudo tail -f /var/log/apache2/wiki_access.log
     sudo tail -f /var/log/apache2/wiki_error.log
     ```

3. **Restarting Apache**:
   - Restart Apache after any configuration changes:
     ```bash
     sudo systemctl restart apache2
     ```

---

This wiki page provides a thorough guide for Apache installation, virtual host setup, SSL configuration, and performance tuning. Let me know if you’d like any additional details or further customization for your setup!

# BookStack Installation and Configuration on wiki.deome.net

#### **Overview**
This page provides a complete guide to setting up BookStack on *wiki.deome.net*, including installation, configuration, database setup, and SSL configuration with Let’s Encrypt.

---

#### **1. Prerequisites**

1. **Web Server**: Apache (refer to the Apache wiki page for installation).
2. **Database**: MariaDB (refer to the MariaDB wiki page for installation and configuration).
3. **PHP**: BookStack requires PHP 7.3 or higher. Install necessary PHP modules.
   ```bash
   sudo apt install php php-mysql php-xml php-mbstring php-zip php-gd -y
   ```

---

#### **2. Download and Install BookStack**

1. **Create the Document Root Directory**:
   - Create a directory for BookStack:
     ```bash
     sudo mkdir -p /var/www/wiki
     ```

2. **Download BookStack**:
   - Navigate to the web root and download the latest version:
     ```bash
     cd /var/www/wiki
     sudo git clone https://github.com/BookStackApp/BookStack.git ./
     sudo git checkout release
     ```

3. **Set File Permissions**:
   - Ensure Apache can read/write to the BookStack files:
     ```bash
     sudo chown -R www-data:www-data /var/www/wiki
     sudo chmod -R 755 /var/www/wiki
     ```

---

#### **3. Configure the Database**

1. **Log in to MariaDB**:
   ```bash
   sudo mysql -u root -p
   ```

2. **Create Database and User**:
   - Create a database for BookStack:
     ```sql
     CREATE DATABASE bookstackdb;
     CREATE USER 'bookstackuser'@'localhost' IDENTIFIED BY 'your_password';
     GRANT ALL PRIVILEGES ON bookstackdb.* TO 'bookstackuser'@'localhost';
     FLUSH PRIVILEGES;
     EXIT;
     ```

---

#### **4. Configure Environment Variables**

1. **Copy the Environment File**:
   - BookStack uses an `.env` file for configuration. Copy the example:
     ```bash
     sudo cp .env.example .env
     ```

2. **Edit the .env File**:
   - Open the `.env` file to configure your database and site settings:
     ```bash
     sudo nano .env
     ```
   - Update the following lines:
     ```env
     # Database configuration
     DB_HOST=localhost
     DB_DATABASE=bookstackdb
     DB_USERNAME=bookstackuser
     DB_PASSWORD=your_password

     # Application URL
     APP_URL=https://wiki.deome.net
     ```

3. **Save and Close**: Press `Ctrl + X`, then `Y`, and `Enter` to save changes.

---

#### **5. Set Up Apache Virtual Host for wiki.deome.net**

1. **Create the Virtual Host File**:
   ```bash
   sudo nano /etc/apache2/sites-available/wiki.deome.net.conf
   ```

2. **Configure the Virtual Host**:
   - Add the following configuration:
     ```apache
     <VirtualHost *:80>
       ServerName wiki.deome.net
       DocumentRoot /var/www/wiki/public
       <Directory /var/www/wiki/public>
           AllowOverride All
           Require all granted
       </Directory>
       ErrorLog ${APACHE_LOG_DIR}/wiki_error.log
       CustomLog ${APACHE_LOG_DIR}/wiki_access.log combined
     </VirtualHost>
     ```

3. **Enable the Site and Rewrite Module**:
   ```bash
   sudo a2ensite wiki.deome.net.conf
   sudo a2enmod rewrite
   sudo systemctl reload apache2
   ```

---

#### **6. 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**:
   ```bash
   sudo certbot --apache -d wiki.deome.net
   ```

3. **Auto-Renewal Setup**:
   - Certbot will auto-renew SSL certificates by default. To verify:
     ```bash
     sudo certbot renew --dry-run
     ```

---

#### **7. Complete BookStack Setup**

1. **Run the BookStack Installation Commands**:
   - Navigate to the BookStack directory and run the following commands to finish the setup:
     ```bash
     cd /var/www/wiki
     sudo -u www-data php artisan key:generate --force
     sudo -u www-data php artisan migrate --force
     ```

2. **Set Permissions (again, if necessary)**:
   - Ensure permissions are still correct after setup:
     ```bash
     sudo chown -R www-data:www-data /var/www/wiki
     sudo chmod -R 755 /var/www/wiki
     ```

---

#### **8. Testing and Verification**

1. **Access BookStack**:
   - Go to `https://wiki.deome.net` in your web browser.
   - Follow the on-screen instructions to set up the admin account.

2. **Check Logs**:
   - Monitor Apache logs if there are any issues:
     ```bash
     sudo tail -f /var/log/apache2/wiki_access.log
     sudo tail -f /var/log/apache2/wiki_error.log
     ```

---

#### **9. Ongoing Maintenance**

1. **Database Backups**:
   - Set up a cron job to regularly back up the BookStack database:
     ```bash
     mysqldump -u root -p bookstackdb > /path/to/backup/bookstackdb.sql
     ```

2. **Updating BookStack**:
   - Periodically pull the latest updates from the BookStack repository:
     ```bash
     cd /var/www/wiki
     sudo -u www-data git pull origin release
     sudo -u www-data php artisan migrate --force
     ```

---

This setup guide for BookStack covers installation, configuration, and basic maintenance. Let me know if you'd like additional details or specific troubleshooting steps included!

# 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!