How to Install WonderCMS with Nginx on Debian 12/11/10

In the vast digital expanse of content management systems (CMS), WonderCMS has managed to carve out its niche, particularly among users who prefer simplicity and efficiency. While popular options such as WordPress have their undeniable merits, WonderCMS offers unique advantages that may make it a more suitable choice for certain applications.

WonderCMS is a free, open-source CMS that focuses on speed, simplicity, and security. The platform does not require a traditional database like MySQL. Instead, it leverages a flat file system which can provide a slew of benefits for users craving simplicity and speed.

Why WonderCMS?

Before diving into the specifics, it’s crucial to understand why someone would prefer WonderCMS over more renowned CMS platforms like WordPress:

  • Simplicity: WonderCMS offers a simple and intuitive interface that allows even novice users to create and manage their content efficiently. Unlike WordPress, which can be overwhelming due to its complex structure and myriad plugins, WonderCMS provides an easy-to-navigate dashboard that keeps everything straightforward.
  • Performance and Speed: With its flat file system, WonderCMS can be notably faster and more efficient than database-driven CMSs. There are no databases to query, which means pages typically load quicker. This speed can significantly enhance the user experience and even help boost your site’s SEO performance.
  • Security: WonderCMS has a firm commitment to security. It incorporates a unique login URL by default and utilizes hashed and salted passwords. In addition, it employs CSRF protection to prevent cross-site request forgery attacks.
  • Lightweight: WonderCMS is extremely lightweight, with the default installation package taking up less than 15KB. This compactness makes it a great choice for those who need to conserve server resources or aim to run a lean operation.
  • Extensibility: Despite its simplicity, WonderCMS is not lacking in power or flexibility. It offers a variety of themes and plugins that allow you to customize your site to your liking. However, unlike WordPress, which can become bogged down by too many plugins, WonderCMS maintains its swift performance even as you add additional features.

WonderCMS vs. WordPress

WonderCMS and WordPress cater to different segments of the market, each with its own distinct set of strengths:

  • User Experience: WordPress offers a wide range of features and functionalities, making it versatile but also more complex. WonderCMS, on the other hand, aims for ease-of-use, providing only the essential features needed to build and manage a website.
  • System Requirements: WordPress requires a server with PHP and MySQL, meaning more server resources are necessary. WonderCMS operates on a flat file system, so it requires less server space and resources.
  • Security Measures: Both CMSs place a high emphasis on security. However, due to its popularity, WordPress is a more common target for hackers. WonderCMS’s unique login URL provides an extra layer of security not natively present in WordPress.
  • Customizability: WordPress’s extensive plugin and theme libraries outmatch WonderCMS’s smaller selection. However, the simplicity of WonderCMS allows users to make changes directly in the source code, offering a different kind of customizability.

Choosing between WonderCMS and WordPress, or any other CMS for that matter, largely depends on your specific needs and circumstances. If simplicity, speed, and security are your top priorities, WonderCMS might be the perfect fit.

The following guide will demonstrate how to install WonderCMS with Nginx on Debian 12 Bookworm, Debian 11 Bullseye, or Debian 10 Buster, helping you get started with this unique CMS.

Section 1: Setting Up Nginx Environment

Step 1: Update the Debian System

Before we start the installation of WonderCMS, it’s crucial to have an up-to-date system. This ensures you have the latest security patches, bug fixes, and software features for optimal system stability and performance. Run the following command to update all existing packages:

sudo apt update && sudo apt upgrade

If your system prompts for any significant upgrades, such as the Linux Kernel, remember to reboot your server to make sure the updates take effect correctly.

Step 2: Nginx Installation

Having ensured that your Debian system is updated, let’s proceed with the installation of Nginx. Nginx is a high-performance HTTP server and reverse proxy that we will use to serve our WonderCMS website. Execute the command below to install Nginx:

sudo apt install nginx

Upon successful installation, the Nginx service is typically activated by default. Nonetheless, we must verify that it’s functioning correctly to avoid potential hiccups later. Use the following command to check the status of Nginx:

systemctl status nginx

You should see an output indicating that Nginx is active and running. If for any reason the Nginx service hasn’t been activated, use the following command to enable it:

sudo systemctl enable nginx --now

Enabling the service ensures that Nginx starts automatically every time the server is rebooted, crucial for maintaining uptime of your WonderCMS site.

Step 3: Optimize Nginx for Performance

To further enhance your WonderCMS site’s performance, it’s advisable to use the latest Nginx mainline version. This version includes additional features and enhancements that improve your website’s speed and overall performance. For instructions on how to install the latest Nginx mainline directly from Nginx’s APT repository, please follow this guide: Install Nginx Mainline on Debian Linux.

Section 2: Fine-tuning UFW Firewall for Nginx

Step 1: Installation of UFW

To enhance the security of your Nginx server, it’s vital to properly configure your firewall settings. The Uncomplicated Firewall (UFW) is a user-friendly interface for managing iptables firewall rules. It provides an easy way to build a robust firewall while maintaining simplicity in configuration.

If UFW is not already installed on your Debian system, you can add it using the following command:

sudo apt install ufw

Step 2: Enable UFW

With UFW installed, it’s time to activate it on your system. By default, UFW is set to deny all incoming connections while allowing all outgoing ones. This setting helps create a safe default environment until you’re ready to open up services to outside traffic. Execute the following command to enable UFW:

sudo ufw enable

Step 3: Review Available Nginx Profiles

Now that UFW is active, let’s focus on configuring it specifically for Nginx. UFW has application profiles which are essentially predefined settings for various applications. Nginx comes with its own set of profiles that simplify this process. Run the following command to view the available Nginx profiles:

sudo ufw app list

The output reveals three profiles for Nginx. The Nginx HTTP profile allows traffic on port 80 (HTTP), Nginx HTTPS permits traffic on port 443 (HTTPS), and Nginx Full combines the two, permitting traffic on both HTTP and HTTPS.

Step 4: Configuring UFW with an Nginx Profile

Deciding which profile to use will depend on your specific requirements. If your website needs to accommodate both secure (HTTPS) and non-secure (HTTP) traffic, apply the Nginx Full profile:

sudo ufw allow 'Nginx Full'

However, if you’re aiming to provide only secure traffic, employ the Nginx HTTPS profile:

sudo ufw allow 'Nginx HTTPS'

If your use case is such that you only require HTTP access, implement the Nginx HTTP profile:

sudo ufw allow 'Nginx HTTP'

It’s also worth mentioning that if you wish to allow a specific port, say 8080 for a specific application, you can do so by executing:

sudo ufw allow 8080

Always remember that your configuration choices should mirror your specific server requirements and conform to best security practices.

Section 3: Setting Up PHP and PHP-FPM for WonderCMS

Step 1: PHP Installation

PHP, an open-source scripting language, is a crucial component for running WonderCMS, as it interprets and processes the code of your website. It’s often recommended to utilize the latest stable PHP version for improved performance, security, and support for newer functionalities. More detailed instructions on installing the most recent PHP version can be found here.

To install PHP along with PHP-FPM (FastCGI Process Manager) and the necessary modules on your Debian system, use the following command:

sudo apt install php php-fpm php-mbstring php-bcmath php-common php-cli php-curl php-zip

Step 2: Verifying PHP Service Status

After the installation process completes, it’s crucial to verify the status of the PHP service to ensure it’s functioning properly. You can do this similarly to how you checked the status of MariaDB and Nginx. Here, we’ll look at PHP 8.2, which is the default version on Debian 12 Bookworm. Run the following command to verify the status:

systemctl status php8.2-fpm

Optional: Confirming the PHP Version

As a final step, you might want to confirm the specific PHP version that is installed on your system. This can be useful if you need to troubleshoot or are preparing for updates. Display the installed PHP version by running the following command:

php -v

With PHP and PHP-FPM properly set up on your Debian system, you can continue your WonderCMS installation. Ensuring the correct PHP version is running is essential for the overall functionality and efficiency of your WonderCMS setup. Remember, updating your PHP version can provide performance improvements, more security, and access to the latest features and enhancements.

Section 4: Setting Up WonderCMS on Your Debian System

Step 1: Downloading WonderCMS

The first part of installing WonderCMS involves downloading the software archive package. You can access the latest version of WonderCMS through the official GitHub releases page, available here. To download the file directly to your Debian system, you will employ either the wget or curl command in the terminal.

wget https://github.com/WonderCMS/wondercms/releases/download/x.x.x/wondercms-xxx.zip

Please note: the link above serves as a template. You must replace it with the most current link from the official release page.

Step 2: Setting Up WonderCMS Folder Structure

With the WonderCMS archive downloaded, it’s time to extract the package and move its contents to the appropriate directory (www directory). Begin by creating a new directory specifically for WonderCMS:

sudo mkdir -p /var/www/wondercms

Then, extract the WonderCMS files to the www directory:

sudo unzip wondercms*.zip -d /var/www/

Should you encounter issues with the above command, it may be necessary to install the zip package:

sudo apt install zip unzip

Step 3: Configuring Proper Permissions for WonderCMS

Next, it’s crucial to set the correct directory owner permissions for WonderCMS. Without the proper permissions set to www-data, WonderCMS may experience write permission issues. The commands below will ensure the appropriate ownership and permission settings:

sudo chown -R www-data:www-data /var/www/wondercms/
sudo find /var/www/wondercms -type d -exec chmod 755 {} \;
sudo find /var/www/wondercms -type f -exec chmod 644 {} \;

Step 4: Crafting an Nginx Server Block Configuration for WonderCMS

To set up the server block for WonderCMS, create a new server block file:

server {
    listen 80;
    server_name www.wonder-example.com;
    root /var/www/wondercms;
    index index.php;
    autoindex off;

    location / {
        try_files $uri $uri/ @rewrite;
    }

    location @rewrite {
        rewrite ^/(.+)$ /index.php?page=$1 last;
    }

    location ~ database.js {
        return 403;
    }

    location ~ cache.json {
        return 403;
    }

    location ~ \.php$ {
      fastcgi_pass unix:/run/php/php8.2-fpm.sock;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
      include snippets/fastcgi-php.conf;
      fastcgi_buffer_size 128k;
      fastcgi_buffers 4 128k;
      fastcgi_intercept_errors on; 
    }
}

This is a critical step, as the Nginx server block works much like a virtual host for users migrating from Apache-based web applications. It defines how to respond to requests for a specific website.

Ensure that you replace all placeholder text (www.wonder-example.com, example.com, etc.) with the actual domain and paths you’re using.

Step 5: Enabling the Nginx

Once you’ve created your server block configuration file, it’s time to enable it. This process involves creating a symbolic link from the sites-available directory to the sites-enabled directory. Execute the following command:

sudo ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/

Replace example.com.conf with your actual configuration file’s name.

Then, execute a test run to check your Nginx configuration:

sudo nginx -t

If the configuration test runs successfully without returning any errors, you can restart the Nginx service:

sudo systemctl restart nginx

Step 6: Adjusting the PHP.ini Configuration

Before proceeding to the web-based setup, it’s advisable to optimize your PHP settings to accommodate WonderCMS. Let’s edit the PHP.ini file to adjust a few parameters, which will improve the overall performance of your CMS.

To start, open the PHP.ini file. Note that its location might differ based on your PHP version:

sudo nano /etc/php/{version}/fpm/php.ini

Here are some recommendations that you can follow to enhance your CMS’s performance:

upload_max_filesize = 100MB
post_max_size = 100MB
max_execution_time = 120
max_input_vars = 5000
memory_limit = 256M

After making the necessary changes, restart your PHP-FPM server:

sudo systemctl restart php{version}-fpm

Step 7: Updating the Nginx Server Block

The final step involves revisiting your Nginx server block to accommodate larger body sizes. To do this, reopen your server block file:

sudo nano /etc/nginx/sites-available/example.com

Add the following line to increase the allowed body size:

client_max_body_size 100M;

Ensure that the client_max_body_size value aligns with your PHP file settings.

Lastly, test your changes:

sudo nginx -t

If everything checks out, restart your Nginx service to apply the changes:

sudo systemctl restart nginx

With this step, you have successfully configured your Debian system for WonderCMS and can proceed to the GUI section to complete the setup.

Section 5: Setting Up WonderCMS Web User Interface

With the backend configurations complete, it’s now time to bring our attention to the front end of the WonderCMS platform: the Web User Interface (WebUI). This is where the heart of your website’s content management occurs.

Step 1: Accessing the Installation Page

To begin, open your preferred web browser and navigate to your domain where WonderCMS is set up:

https://www.yoursite.com

Replace ‘yoursite.com’ with your actual domain. This will initiate the WonderCMS installation process.

Step 2: Logging In to WonderCMS

You will be greeted by an initial page displaying a temporary password and a ‘Login’ button.

To proceed, click on the ‘Login’ button and enter the temporary password provided. If you fail to remember or misplace the password, simply navigate back, copy the temporary password again, and retry logging in.

Step 3: Configuring Your Website

Upon successful login, you will land on a page that seemingly mirrors the initial login page. However, this new interface is an editable page of your CMS. At the top of this page, you’ll notice an option labeled ‘Change settings’.

Click on ‘Change settings’ to access the configuration panel for your site. It is strongly recommended to update your settings promptly to bolster your website’s security.

Step 4: Customizing Your WonderCMS Website

After ensuring the security of your website, it’s time for the fun part — customizing your site! WonderCMS offers a variety of options for personalizing your website. You can add new pages, alter themes, and adjust the overall aesthetics of your site to match your unique preferences.

Feel free to explore and experiment with the customization options. After all, your website should reflect your individuality and cater to the needs of your specific audience.

Section 5: Basic Tips for WonderCMS on Debian

Post the installation of WonderCMS on your Debian server, the road ahead is filled with the exploration of an assortment of features and customization alternatives. In this piece, we aim to guide you with a potpourri of useful information, customizations, and generic tips to enhance your initiation journey with WonderCMS.

A Collation of Useful Tips

Consistent WonderCMS Updates

Consistency in updating your WonderCMS ensures that you are always running on the latest version. This translates into better security, performance, and unlocks access to new features and enhancements.

Activate HTTPS

Add an extra layer of security to your website by activating HTTPS. It secures data between your server and the users’ browsers, courtesy of a free SSL certificate from Let’s Encrypt.

Regular Data Backups

Take protective measures for your website’s data via regular backups. It is a safety net that will expedite recovery in the event of data loss or server complications.

Customization Opportunities

Theme Alteration

WonderCMS provides a plethora of themes to cater to diverse needs. You can customize the outlook of your website by selecting a theme that resonates with your style. Further, the WonderCMS community houses an array of additional themes or you can even create your own.

Plugin Addition

Augment your website’s functionality by installing plugins. The community of WonderCMS offers a multitude of plugins that expand your website’s capacities like adding contact forms, SEO optimization, and many more.

Menu Customization

Bring structure to your website’s navigation by customizing menus. You can add custom links to external pages, create new menus, and rearrange menu items to suit your preferences.

Other Handy Suggestions

Image Optimization

Boost your website’s loading speed by optimizing images. Online tools like TinyPNG or Compressor.io come in handy to compress your images without compromising on quality.

Caching Activation

Improve your website’s speed by enabling caching. It stores replicas of your web pages on the users’ browsers, thereby reducing server load and enhancing page load times.

Website Performance Monitoring

Regularly monitor your website’s performance with tools like Google Analytics and Google Search Console. These tools offer valuable insights into potential issues, user behavior, and your website’s traffic.

Section 6: Implementing HTTPS with Let’s Encrypt for WonderCMS

Website security is paramount to ensure user privacy and data protection. Leveraging HTTPS is one such way to secure your website, and Let’s Encrypt provides a free, automated, and open certificate authority for this purpose. It is operated by the nonprofit Internet Security Research Group (ISRG). This guide will navigate you through implementing HTTPS using Let’s Encrypt for your WonderCMS website operating on Nginx.

Step 1: Installation of the Certbot Package

Kickstart the process by installing the Certbot package. The Certbot package is necessary for obtaining SSL certificates from Let’s Encrypt and configuring HTTPS on the server. Use the following command:

sudo apt install python3-certbot-nginx -y

Step 2: Generating an SSL Certificate

Once the Certbot package installation is successful, the next step involves generating your SSL certificate. The command shown below accomplishes this. Remember to replace the email and domain name placeholders with your actual details:

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email you@example.com -d www.example.com

The command above not only generates the SSL certificate but also sets up a secure configuration. It includes force HTTPS 301 redirects, a Strict-Transport-Security header, and OCSP Stapling. Remember to adjust the email and domain name as per your specific needs.

Your website URL will now use https://www.example.com instead of http://www.example.com. Any attempts to access the previous HTTP URL will automatically redirect to the new HTTPS version.

Setting up Automatic Certificate Renewal

SSL certificates require regular renewal to stay valid. Setting up a cron job will automate the renewal process and keep your SSL certificates up-to-date. Certbot comes with a script that takes care of this process.

Start by testing the renewal process with a dry run. This test helps to ensure that the automatic renewal process will function as expected when the certificate nears expiration:

sudo certbot renew --dry-run

If the dry run executes without errors, the next step is to open the crontab window:

sudo crontab -e

In the crontab window, establish a new cron job to carry out daily checks for certificate renewals. If renewal is required, the script will manage the update automatically. Use the command below as a template and modify the schedule as required:

00 00 */1 * * /usr/sbin/certbot-auto renew

You can use the crontab.guru tool to assist in identifying a suitable time for the renewal checks. Following these steps will equip your WonderCMS website with HTTPS, utilizing a free SSL certificate provided by Let’s Encrypt.

Closing Thoughts

In summary, the steps provided guide you in installing and customizing WonderCMS on a Debian server using Nginx. We began by detailing the installation process, proceeded to discuss how to optimize performance, enhance security with Let’s Encrypt SSL certificates, and concluded with setting up automatic certificate renewal. The information presented is intended to equip you with the necessary skills to successfully deploy and maintain your WonderCMS website.

Additional Resources

If you wish to delve deeper into WonderCMS and Nginx, or need further assistance, the following official resources are highly recommended:

  • WonderCMS Official Documentation: Comprehensive documentation covering all aspects of WonderCMS. It includes everything from the basics to advanced customization and theme development.
  • Nginx Official Documentation: Nginx’s official documentation is an excellent resource to get to know more about its advanced features and configuration.
  • WonderCMS Community: Connect with the WonderCMS community, participate in discussions, get help from other users, and stay up-to-date with the latest news.
  • Let’s Encrypt Documentation: Detailed guides and information about obtaining and managing SSL certificates with Let’s Encrypt.

Share to...