How to Install WonderCMS with Nginx on Ubuntu 22.04 LTS

WonderCMS is a fast and straightforward content management system requiring no database to create websites. It offers rich features such as a custom login URL, SEO friendly design with WYSIWYG elements for editing your site in plain text or HTML code formats; flexible CSS framework so you can change up the look on individual pages without affecting other parts of the webpage, including headings/font sizes, etc. Along with native markdown support, which allows users easy ways to publish articles online using only paragraphs.

In the following tutorial, you will learn how to install WonderCMS using Nginx and PHP along with importing up-to-date repositories or using the default version and how to create a server block and set it up using the command line terminal on Ubuntu 22.04 LTS Jammy Jellyfish desktop or server.

Update Ubuntu

Before proceeding with the tutorial, it is good to ensure your system is up-to-date with all existing packages.

sudo apt update && sudo apt upgrade -y

Install Nginx

To kickstart the installation, you will need to install the Nginx web server. This is straightforward. In your terminal, use the following command to install the webserver.

sudo apt install nginx nginx-full nginx-core -y

Next, enable Nginx on system boot using the following command.

sudo systemctl enable nginx --now

Lastly, check the status to ensure the service is active and no errors have occurred.

systemctl status nginx

Example output:

How to Install WonderCMS with Nginx on Ubuntu 22.04 LTS

Configure UFW Firewall for Nginx

Debian users who have installed UFW will need to adjust the UFW rules to allow outside access to the default web ports. Luckily, during the installation, Nginx registers itself with UFW to provide a few profiles that can be used to enable or disable access, making it easy and quick to configure.

By default, UFW should be installed but re-run the installation command if you are unsure.

sudo apt install ufw -y

Next, enable UFW. When you enable the firewall, it will deny all incoming and allow all outgoing by default.

sudo ufw enable

First, list the application profiles to see the Nginx profiles that are available by the following command:

sudo ufw app list

Example output:

How to Install WonderCMS with Nginx on Ubuntu 22.04 LTS

From the output above, you have three profile options to choose from. To break it down, Nginx runs on port 80 (HTTP), Nginx Secure runs on port 443 (HTTPS), and Nginx Full is a combination of allowing both. The most common is either Nginx Full or Nginx Secure.

The tutorial will set up SSL later as nearly all users will be using this; the best choice is to allow both.

sudo ufw allow 'Nginx Full'

Example output:

How to Install WonderCMS with Nginx on Ubuntu 22.04 LTS

As above, the rules have been added for both IPV4 and IPV6.

Install PHP & PHP-FPM

The second part of the backend installation is to install PHP. PHP 8.0 is becoming relatively stable, and the newer versions of PHP 8.1 are now available and should be used unless you have trouble with it. WonderCMS has updated its code for PHP 8.1, so it technically should run great.

The tutorial will focus on importing Ondřej Surý’s latest PHP version, the maintainer for Debian PHP. This is always up to date even when new PHP versions are dropped.

Import Ondřej Surý PHP Repository

The first step is to import and install the GPG and repository.

In your terminal, use the following command.

sudo add-apt-repository ppa:ondrej/php -y

This command will install the PHP repository and update your APT repository.

Next, update the repository list as the new repository will require some existing packages to be upgraded and is advised to do before installing any versions of PHP.

sudo apt update && sudo apt upgrade

Option 1. Install PHP 8.0

The default of many CMS minimum PHP versions is to install PHP 8.0. While this is considered incredibly stable, ideally, you should install PHP 8.0 or higher if possible for performance and security benefits, installing the 7 series is still possible, but I would refrain away from it at this point.

In your terminal, execute the following command.

sudo apt install php8.0 php8.0-fpm php8.0-mbstring php8.0-curl php8.0-zip

Next, start and enable PHP 8.0-FPM to be automatically started on boot.

sudo systemctl enable php8.0-fpm --now

Option 2. Install PHP 8.1

Most users should be installing PHP 8.1 for their web applications, with 8.0 considered an older stable version, similar to 8.0 in your terminal; execute the following command.

sudo apt install php8.1 php8.1-fpm php8.1-mbstring php8.1-curl php8.1-zip

Next, start and enable PHP 8.1-FPM to be automatically started on boot.

sudo systemctl enable php8.1-fpm --now

Install WonderCMS

Download WonderCMS

First, download the WonderCMS archive package by visiting the official download page to grab the latest link and download using your terminal command with either wget command.

Example:

wget https://github.com/robiso/wondercms/releases/download/3.3.1/wondercms-331.zip

Create Folder Structure for WonderCMS

Now you have the archive downloaded, proceed to unzip it and move it to your www directory.

Create the directory for WonderCMS:

sudo mkdir -p /var/www/wondercms

UnzipWonderCMS to the www directory:

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

You must set the directory owner permissions to WWW or have trouble with WonderCMS write permissions.

Set chown permission (necessary):

sudo chown -R www-data:www-data /var/www/wondercms/

Set chmod permission folders (important):

sudo find /var/www/wondercms -type d -exec chmod 755 {} \;

Set chmod permission files (important):

sudo find /var/www/wondercms -type f -exec chmod 644 {} \;

Create Nginx Server Block Configuration

The next stage is to create the server block for WonderCMS for new users to Nginx; this is the website configuration file for the web application on the back-end, the same as the virtual host for users migrating from Apache type web applications.

First, create a server block using the following command, be sure to replace the example.com with your domain name or name.

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

Below is an example; you can choose the parts; however, the “location ~ \.php$” needs to be in the Nginx configuration file.

NOTE: Make sure to change www.example.com and example.com and the root path.

server {
        listen 80;
        # adapt to your server name
        server_name www.wonder-example.com;
        # adapt the path
        root /var/www/wondercms;
        index index.php;
        # prevent directory listing
        autoindex off;

        # rewrite url to make it pretty
        location / {
            try_files $uri $uri/ @rewrite;
        }
            location @rewrite {
            rewrite ^/(.+)$ /index.php?page=$1 last;
        }

        # prevent access to database.js
        location ~ database.js {
            return 403;
        }

        location ~ cache.json {
            return 403;
        }

        # use php-fpm for dealing with php files

location ~ \.php$ {
      fastcgi_pass unix:/run/php/php8.1-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; 
        }
    }

Note, find and replace the above line “fastcgi_pass unix:/run/php/php8.1-fpm.sock;” to “fastcgi_pass unix:/run/php/php8.0-fpm.sock;” for 8.0.

Next, you will need to enable the Nginx configuration file from “sites-available.” To do this, you will create a symlink to “sites-enabled” as follows.

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

Make sure to replace “example.conf” with your configuration file name.

You can now do a dry run and then restart your Nginx server if everything is ok.

sudo nginx -t

After checking that everything is ok with your Nginx dry run test, restart the Nginx service.

sudo systemctl restart nginx

PHP.ini Configuration

Before moving onto the web UI installation part, you should adjust your PHP for optimal use for WonderCMS. These settings are more of a guide, and you can increase decrease them as you see fit.

First, bring up your php.ini. Note that your location may differ depending on your PHP version number.

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

Next, ideally, you can further improve your CMS by adjusting some of the settings below. Note that you will not do much if you are on a low resource 1VCPU, 1GB. However, the settings below are just a guide, do some research or use these and tinker away.

##increase upload max size recommend 50 to 100mb example only## 
 upload_max_filesize = 100MB

##increase post max size recommend 50 to 100mb  example only##
 post_max_size = 100MB

## increase max execution time recommend 120 to 300##
 max_execution_time = 120

## increase GET/POST/COOKIE input variables recommend 5000 to 10000##
max_input_vars = 5000

## increase memory limit recommend 256mb or 512mb##
memory_limit = 256M

Now restart your PHP-FPM server.

sudo systemctl restart php{version}-fpm

The PHP settings you adjusted are for the PHP backend. You will also need to change the Nginx server block to allow large body sizes. This is done by re-opening your server block and adding the following line.

Open up your server block.

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

Adjust this line to increase body size.

client_max_body_size 100M;

Remember, keep the client max size the same as your PHP file setting.

Next, test the changes, then restart your Nginx server if everything is ok.

sudo nginx -t

After checking that everything is ok with your Nginx dry run test, restart the Nginx service.

sudo systemctl restart nginx

Install WonderCMS WebUI

Now that all the backend setup and configuration are complete, you can go to your domain and begin installing.

##go to installation address##
 https://www.yoursite.com

The first page you will see is a temporary password and the login button.

Click login to proceed.

Example:

How to Install WonderCMS with Nginx on Ubuntu 22.04 LTS

Enter your password to continue using the password available on the Welcome to your website login page. If you forgot or did not copy, click back and re-copy, then re-login.

Example:

How to Install WonderCMS with Nginx on Ubuntu 22.04 LTS

Once logged in, you will hit your CMS page that looks like the original login page, do not be fooled; this is an open-edit page. At the top, you will see change settings, and this is highly advised immediately to secure your Website further.

Example:

How to Install WonderCMS with Nginx on Ubuntu 22.04 LTS

Once you open the settings page, you can adjust plugins security settings and start customizing your website back end before hitting the WonderCMS page editor.

Example:

How to Install WonderCMS with Nginx on Ubuntu 22.04 LTS

Next, pick a theme, grab some plugins that suit the purpose of your website in the tabs, and get it up and running. Overall, the process is straightforward, even for a fresh beginner in website design.

Example:

How to Install WonderCMS with Nginx on Ubuntu 22.04 LTS

Congratulations, you have successfully installed the latest version of WonderCMS with Nginx and PHP.

Secure Nginx with Let’s Encrypt SSL Free Certificate

Ideally, you would want to run your Nginx on HTTPS using an SSL certificate. The best way to do this is to use Let’s Encrypt, a free, automated, and open certificate authority run by the nonprofit Internet Security Research Group (ISRG).

First, install the certbot package as follows.

sudo apt install python3-certbot-nginx -y

Once installed, run the following command to start the creation of your certificate:

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

This ideal setup includes force HTTPS 301 redirects, a Strict-Transport-Security header, and OCSP Stapling. Just make sure to adjust the e-mail and domain name to your requirements.

Now your URL will be HTTPS://www.example.com instead of HTTP://www.example.com.

If you use the old HTTP URL, it will automatically redirect to HTTPS.

Optionally, you can set a cron job to renew the certificates automatically. Certbot offers a script that does this automatically, and you can first test to make sure everything is working by performing a dry run.

sudo certbot renew --dry-run

If everything is working, open your crontab window using the following terminal command.

sudo crontab -e

Next, please specify the time when it should auto-renew. This should be checked daily at a minimum, and if the certificate needs to be renewed, the script will not update the certificate. If you need help finding a good time to set, use the crontab.guru free tool.

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

Comments and Conclusion

In the tutorial, you have learned a few ways to install WonderCMS on Ubuntu 22.04 LTS Jammy Jellyfish using Nginx and PHP.

It is a great CMS and would suit anyone looking for an easy-to-use CMS that doesn’t require any hosting. If you want a self-hosted CMS with a great community and design, then WonderCMS is the perfect option!



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!