ubuntu 22.04 | LinuxHostSupport Linux Tutorials and Guides Mon, 05 Dec 2022 13:16:57 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 How to Install Uptime Kuma on Ubuntu 22.04 https://linuxhostsupport.com/blog/how-to-install-uptime-kuma-on-ubuntu-22-04/ https://linuxhostsupport.com/blog/how-to-install-uptime-kuma-on-ubuntu-22-04/#respond Fri, 30 Dec 2022 18:30:00 +0000 https://linuxhostsupport.com/blog/?p=1737 Uptime Kuma is an open-source monitoring solution. We can monitor our websites and servers’ uptime and configure them to send us notifications via multiple options, like Telegram, email, Discord, etc. Uptime Kuma is an easy-to-use monitoring tool, and it is powerful for traffic control, observability, service discovery, etc. This article will show you how to […]

The post How to Install Uptime Kuma on Ubuntu 22.04 appeared first on LinuxHostSupport.

]]>
Uptime Kuma is an open-source monitoring solution. We can monitor our websites and servers’ uptime and configure them to send us notifications via multiple options, like Telegram, email, Discord, etc. Uptime Kuma is an easy-to-use monitoring tool, and it is powerful for traffic control, observability, service discovery, etc. This article will show you how to install Uptime Kuma on Ubuntu 22.04.

Prerequisites

  • An Ubuntu server 22.04
  • SSH access with root privileges

Step 1. Log in to the server

First, log in to your Ubuntu 22.04 VPS through SSH as the root user:

ssh root@IP_Address -p Port_number

You would need to replace ‘IP_Address‘ and ‘Port_number‘ with your server’s IP address and SSH port number.

Before starting, we need to make sure that all Ubuntu 22.04 packages installed on the server are up to date. You can do this by executing the following commands:

# apt update -y

Step 2. Create a System User

In this step, we will create a new system user and grant it sudo privileges. Let’s say the new system user is called ‘master’; you can choose any username you like.

# adduser master

Next, let’s run the command below to add the new user to sudo group. In Ubuntu operating system, users who are members of sudo group are allowed to run sudo commands.

# usermod -aG sudo master

Once created and given sudo privileges, we can log in as the new user ‘master’, and we will use this user to run commands and complete the Uptime Kuma installation.

# su - master

Step 3. Install NodeJS and NPM

Uptime Kuma requires NodeJS runtime environment and npm. We can install NodeJS from the Ubuntu default repository, but we will get an older version of NodeJS if we use this method and Uptime Kuma requires at least NodeJS version 14. In this step, we will install NodeJS and npm through the NodeJS repository to get the most recent version of it.

$ curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

Once completed, we need to download the package information from the newly added source above.

$ sudo apt update

Next, run the following command to install NodeJS and NPM finally.

$ sudo apt install nodejs

That’s it; nodejs and NPM are installed; you can check the installed version by executing this one-liner:

$ node -v; npm -v

You will see an output like this:

master@ubuntu22:~$ node -v; npm -v
v16.18.0
8.19.2

Step 4. Install Uptime Kuma

Uptime Kuma is not available in the default Ubuntu repository. We can install it by downloading it from GitHub using git.

$ sudo apt install git

After git is installed, we can continue to clone Uptime Kuma from its GitHub repository.

$ git clone https://github.com/louislam/uptime-kuma.git
$ cd uptime-kuma

It’s time to run the installation using the NPM package manager of Nodejs.

$ npm run setup
uptime kuma npm run setup

Step 5. Install PM2

With Process Manager (PM2), we can keep our applications alive forever, reload them without downtime, and facilitate common system admin tasks. Execute the command below to install PM2 on your Ubuntu 22.04.

$ sudo npm install pm2 -g

Once pm2 is installed, we can run our Uptime Kuma with this command.

$ pm2 start server/server.js --name kuma

uptime kuma pm2 start

Now, you can open your web browser and navigate to the page at http://YOUR_SERVER_IP_ADDRESS:3001, and you will see the uptime Kuma welcome page, you can create a new user now.

uptime kuma welcome

To add monitoring, you can click on the ‘Add New Monitor’ button

uptime kuma monitor

You can customize and configure your monitoring here.

uptime kuma customize monitor

After starting Uptime Kuma, we can create a service file for PM2 to make Uptime Kuma start automatically upon reboot.

$ pm2 startup

You will get an output like this:

[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u master --hp /home/master

Just follow the instruction shown on the screen, for example:

$ sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u master --hp /home/master

Then, you will also see an output like this one:

uptime kuma pm2 startup

Now we need to save the current ongoing process:

$ pm2 save

Step 6. Install and Configure NGINX

Your Uptime Kuma install has now been completed, and you should be able to access it at your server’s public IP with port number 3001. However, if you want to access your Uptime Kuma website using a domain name or subdomain name instead of typing the server’s IP address and the port number in the URL, you would need to configure a reverse proxy on your server.

This step will show you how to implement the reverse proxy configuration using Nginx.

First, install Nginx with the following command:

$ sudo apt install nginx

On Ubuntu 22.04, Nginx is configured to start running upon installation; you can check it by running this command:

$ sudo systemctl status nginx

Once installed, create a new Nginx server block configuration file. Replace kuma.yourdomain.com with your actual domain or subdomain name:

$ sudo nano /etc/nginx/sites-enabled/kuma.yourdomain.com.conf

Add the following content to the file:

server {

listen 80;
server_name kuma.yourdomain.com;
location / {
    proxy_pass http://localhost:3001;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    }

location ~ /.well-known {
    alias /var/www/html;
    }
}

Save the file by pressing CTRL + O, then press CTRL + X to exit the nano editor, then restart Nginx.

$ sudo systemctl restart nginx

Step 7. Install SSL certificate

This is an optional step but highly recommended to complete. We will install a free SSL certificate from Let’s Encrypt.

$ sudo apt install python3-certbot-nginx -y

Once completed, we can run this command to install the SSL certificate.

$ sudo certbot certonly -d kuma.yourdomain.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Nginx Web Server plugin (nginx)
2: Spin up a temporary webserver (standalone)
3: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 1
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): you@yourdomain.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: n
Account registered.
Requesting a certificate for kuma.yourdomain.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/kuma.yourdomain.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/kuma.yourdomain.com/privkey.pem
This certificate expires on 2023-01-19.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
master@ubuntu22:~#

Make sure to pay attention to these lines; we need them when editing our nginx server block.

Certificate is saved at: /etc/letsencrypt/live/kuma.yourdomain.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/kuma.yourdomain.com/privkey.pem

Next, we need to edit the nginx server block for kuma.yourdomain.com

$ sudo nano /etc/nginx/sites-enabled/kuma.yourdomain.com.conf

Replace the content with the lines below.

server {
    listen 443 ssl http2;
    server_name kuma.yourdomain.com;
    ssl_certificate /etc/letsencrypt/live/kuma.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/kuma.yourdomain.com/privkey.pem;

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_pass http://localhost:3001/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }
}

server {
    listen 80;
    server_name kuma.yourdomain.com;
    return 301 https://kuma.yourdomain.com$request_uri;
}

Save the file, then exit and restart nginx

$ sudo systemctl restart nginx

Now, you should be able to access your Uptime Kuma website in HTTPS mode at https://kuma.yourdomain.com; you can proceed with building your application using the Uptime Kuma.

Of course, you don’t have to pull your hair to install Uptime Kuma on Ubuntu 22.04 if you have a managed Linux VPS hosting plan hosted with us. If you do, you can simply ask our support team to install Uptime Kuma on Ubuntu 22.04 for you. They are available 24/7 and will be able to help you with the installation of Uptime Kuma, as well as any additional requirements that you may have.

PS. If you enjoyed reading this blog post on how to install Uptime Kuma on Ubuntu 22.04, feel free to share it on social networks or simply leave a comment down in the comments section. Thank you.

The post How to Install Uptime Kuma on Ubuntu 22.04 appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-uptime-kuma-on-ubuntu-22-04/feed/ 0
Improve Website Performance Using gzip and Nginx on Ubuntu 22.04 https://linuxhostsupport.com/blog/improve-website-performance-using-gzip-and-nginx-on-ubuntu-22-04/ https://linuxhostsupport.com/blog/improve-website-performance-using-gzip-and-nginx-on-ubuntu-22-04/#respond Thu, 01 Dec 2022 18:30:00 +0000 https://linuxhostsupport.com/blog/?p=1728 A website’s performance depends on many factors, and choosing a suitable web server is one of them. You can choose from many web servers, like Apache, LiteSpeed, Nginx, etc. Nginx is an open-source web server, it was initially developed by Igor Sysoev and released in October 2004. In Nginx, gzip compression can significantly reduce the […]

The post Improve Website Performance Using gzip and Nginx on Ubuntu 22.04 appeared first on LinuxHostSupport.

]]>
A website’s performance depends on many factors, and choosing a suitable web server is one of them. You can choose from many web servers, like Apache, LiteSpeed, Nginx, etc.

Nginx is an open-source web server, it was initially developed by Igor Sysoev and released in October 2004. In Nginx, gzip compression can significantly reduce the size of transmitted data to website visitors.

Modern web browsers support GZIP compression by default. However, we need to configure our server to serve the compressed resources to our website visitors properly. Without a proper configuration, it could make your server load higher and even slower. This article will show you how to improve website performance using GZIP and Nginx on Ubuntu 22.04.

Prerequisites

  • Ubuntu 22.04
  • SSH access with root privileges or a regular system user with sudo privileges

What is GZIP Compression

GZIP or GNU zip is an open-source algorithm for file compression. GZIP compresses your website resources, such as Javascript and CSS files, while serving requests to the web browsers. It compresses text files effectively, while image files are not compressed because they have some built-in compression.

How to Enable GZIP Compression

To enable compression in Nginx, simply include the following directives in your nginx.conf file, or comment them out if you already have the lines.

gzip on;
gzip_vary on;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

Save and close the file, then verify Nginx for any syntax errors:

$ sudo nginx -t

You should get the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Next, restart the Nginx service using the following command:

$ sudo systemctl restart nginx

Then check the status.

$ sudo systemctl status nginx

You should see the following output:

● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-09-19 17:51:13 WIB; 1s ago
Docs: man:nginx(8)
Process: 1249555 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 1249574 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 1249579 (nginx)
Tasks: 3 (limit: 4532)
Memory: 4.4M
CGroup: /system.slice/nginx.service
├─1249579 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─1249580 nginx: worker process
└─1249581 nginx: worker process

Sep 19 17:51:12 home systemd[1]: Starting A high performance web server and a reverse proxy server...
Sep 19 17:51:13 home systemd[1]: Started A high performance web server and a reverse proxy server.

The following are explanations of our directives to enable and configure gzip in nginx.

gzip on;

The directive above should be turned on to enable gzipping of responses.

In gzip_type directive, you can add another MIME type because, by default, Nginx compresses responses only with MIME type text/thml.

gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

To set gzip compression level, you can add gzip_comp_level directive. The value should be between 1 and 9. The higher the value, the higher the compression. Please note that the most compressed data usually requires more work to compress or decompress, so if you have it set fairly high on a busy website, you may see the difference in your CPU usage.

gzip_comp_level 6;

Another directive, gzip_vary is optional. It is used to enable or disable inserting the “Vary: Accept-Encoding” response header. This header inform the browsers if the client can handle the compressed version of the website or not, especially when your Nginx server is behind CDN or another reverse caching server. If gzip_vary is enabled, you will see vary: Accept-Encoding in the header response, like the following.

HTTP/2 200 
server: nginx
date: Mon, 19 Sep 2022 10:25:15 GMT
content-type: text/html
content-length: 14512
last-modified: Sat, 22 Jan 2022 13:53:28 GMT
vary: Accept-Encoding
etag: "61ec0c58-38b0"
accept-ranges: bytes

Since compression happens at runtime, it can add considerable processing overhead, which can negatively affect your server performance. You can lower your gzip_comp_level if you think your CPU usage is abnormally higher after enabling gzip in Nginx.

How to Verify GZIP is working?

There are several ways to verify whether the gzip compression is working or not. You can use an online tool like Google PageSpeed Insights to check it, or use your browser’s developer tools, or even simply use the curl shell command as follow:

$ curl -I -H 'Accept-Encoding: gzip,deflate' https://www.rosehosting.com/

The command above will show you an output like this:

HTTP/2 200 
server: nginx
date: Mon, 19 Sep 2022 09:52:28 GMT
content-type: text/html
last-modified: Sat, 22 Jan 2022 13:53:28 GMT
etag: W/"61ec0c58-38b0"
content-encoding: gzip

As we can see in the output, the website is compressed using gzip (content-encoding: gzip).

Compare GZIP and Plain Text

After enabling gzip compression, you can compare the files transmitted by nginx to you by simply running these commands.

$ curl -s --output uncompressed https://www.rosehosting.com/
$ curl -s --output compressed -H 'Accept-Encoding: gzip,deflate' https://www.rosehosting.com/

Then, run ‘ls -lh’ or ‘ll -h’ command to see the file size.

As seen above, the compressed file has a lower file size. The lower the file size, the faster your website is and the higher number of concurrent visitors your server can handle.

Congratulations! You have successfully improved your website performance using gzip and Nginx on Ubuntu 22.04.

Of course, if you are one of our Ubuntu Hosting customers, you don’t have to improve your website performance using gzip and Nginx yourself – simply ask our admins, sit back, and relax. Our admins will improve your website performance using gzip and Nginx for you immediately without any additional fee, along with many useful optimizations that we can do for you. Improving your website performance using gzip and Nginx is not just about the installation; we can help you with optimizing your website if you have a VPS with us.

If you liked this post about how to improve your website performance using gzip and Nginx on Ubuntu 22.04, please share it with your friends on the social networks using the share buttons below, or simply leave a comment in the comments section. Thanks.

The post Improve Website Performance Using gzip and Nginx on Ubuntu 22.04 appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/improve-website-performance-using-gzip-and-nginx-on-ubuntu-22-04/feed/ 0