In this week’s feature highlight, we look at How To Install Netdata on Ubuntu 22.04
Netdata is an Open Source real time server monitoring tool. It collects real time data like CPU usage, RAM usage, Load, SWAP usage, Bandwidth usage, Disk usage etc.
Update the Server
Let us update the server using the following command,
apt update -y
apt upgrade -y
Download Netdata Package
Install Netdata on the server using below command.
apt install netdata -y
The -y option is used for the confirmation which will be prompted by the installer.
Netdata Configuration
We need a small change in the configuration file, so that the dashboard is available on a public IP.
If you intend to use this locally, then you do not need to make this change.
nano /etc/netdata/netdata.conf
Configuration file will look like this.
[global]
run as user = netdata
web files owner = root
web files group = root
# Netdata is not designed to be exposed to potentially hostile
# networks. See https://github.com/netdata/netdata/issues/164
bind socket to IP = 127.0.0.1
By default, the bind socket to IP it set to 127.0.0.1. To access the dashboard using the IP address, you need to replace 127.0.0.1 with your actual server IP Address.
[global]
run as user = netdata
web files owner = root
web files group = root
# Netdata is not designed to be exposed to potentially hostile
# networks. See https://github.com/netdata/netdata/issues/164
bind socket to IP = <Enter your IP address here>
Save the file and restart the netdata service using the below command.
systemctl restart netdata
Firewall
Netdata listens on port 19999 by default, enable ports in firewall to use Netdata from browser.
ufw allow 19999
Netdata Dashboard
Enter the following URL on the browser to access the Netdata dashboard. By default netdata works on 19999 port.
Hello, In this week’s feature highlight, we look at How To Install PostgreSQL on Ubuntu 22.04
PostgreSQL is a powerful, open-source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.
Install PostgreSQL on Ubuntu
Install PostgreSQL on Ubuntu by using the following command
root@crown:~# apt install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
postgresql-contrib is already the newest version (13+225ubuntu1).
The following packages were automatically installed and are no longer required:
libfile-find-rule-perl libnumber-compare-perl libtext-glob-perl
Use 'apt autoremove' to remove them.
Suggested packages:
postgresql-doc
The following NEW packages will be installed:
postgresql
PostgreSQL Roles and Databases
We’ll switch to Postgres account for the next steps, to switch to the postgres account, use the following command,
sudo -i -u postgres
You can access a PostgreSQL prompt using the psql utility
psql
Output:
postgres@crown:~$ psql
psql (14.2 (Ubuntu 14.2-1))
Type "help" for help.
postgres=#
Exit out of the PostgreSQL shell type
\q
Create PostgreSQL Role,
sudo -u postgres createuser --interactive
Output:
Enter name of role to add: john
Shall the new role be a superuser? (y/n) y
Create a PostgreSQL database,
sudo -u postgres createdb john
Open a Postgres Prompt with the New Role.
sudo adduser john
Switch over and connect to the database.
sudo -u john psql
Output:
root@crown:~# sudo -u john psql
could not change directory to "/root": Permission denied
psql (14.2 (Ubuntu 14.2-1))
Type "help" for help.
john=#
Once you logged in as john and check your current connection information.
\conninfo
Output:
john=# \conninfo
You are connected to database "john" as user "john" via socket in "/var/run/postgresql" at port "5432".
john=#
Hello, In this week’s feature highlight, we look at How to Install LEMP Stack (Nginx, MariaDB, PHP8.1) on Ubuntu 22.04
LEMP Stack is a combination of free, open source software. The acronym LEMP refers to the first letters of Linux (Operating system), Nginx Server, MySQL (database software), and PHP, PERL or Python, principal components to build a viable general purpose web server.
Updating the system
We first update the system to make sure that all our installed packages are up to date. Your Ubuntu system can be updated easily with the following command.
apt update
apt upgrade
Install Nginx
We will start by installing the Nginx web server. To complete the installation, use the following command.
apt install nginx
Output:
root@crown:~# apt install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
fontconfig-config fonts-dejavu-core libdeflate0 libfontconfig1 libgd3
libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip2
libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip2 libtiff5
libwebp7 libxpm4 nginx-common nginx-core
Suggested packages:
libgd-tools fcgiwrap nginx-doc ssl-cert
Once the installation is complete, enable Nginx (to start automatically upon system boot), start the webserver, and verify the status using the commands below.
systemctl start nginx
systemctl enable nginx
systemctl status nginx
Output:
root@crown:~# systemctl status nginx
● 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 Thu 2022-03-17 14:43:23 UTC; 36min ago
Docs: man:nginx(8)
Process: 42595 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=ex>
Process: 42596 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, sta>
Main PID: 42597 (nginx)
Tasks: 2 (limit: 1074)
Memory: 2.8M
CPU: 34ms
CGroup: /system.slice/nginx.service
├─42597 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
└─42598 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "">
Verify that the webserver is running and accessible by accessing your server’s IP address.
From your browser,
http://IP_address
we need to make the user Nginx the owner of the web directory. By default, it’s owned by the root user.
chown www-data:www-data /usr/share/nginx/html -R
Install MariaDB Server
MariaDB is a popular database server. The installation is simple and requires just a few steps as shown.
apt install mariadb-server mariadb-client
Output:
root@crown:~# apt install mariadb-server mariadb-client
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
galera-4 libcgi-fast-perl libcgi-pm-perl libclone-perl
libconfig-inifiles-perl libdaxctl1 libdbd-mysql-perl libdbi-perl
libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
libhttp-date-perl libhttp-message-perl libio-html-perl
liblwp-mediatypes-perl libmariadb3 libmysqlclient21 libndctl6 libpmem1
libsnappy1v5 libtimedate-perl liburi-perl liburing2 mariadb-client-10.6
mariadb-client-core-10.6 mariadb-common mariadb-server-10.6
mariadb-server-core-10.6 mysql-common socat
Once the installation is complete, enable MariaDB (to start automatically upon system boot), start the MariaDB, and verify the status using the commands below.
systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb
Output:
root@crown:~# systemctl status mariadb
● mariadb.service - MariaDB 10.6.7 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-03-17 13:37:36 UTC; 1h 37min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 26174 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 7 (limit: 1074)
Memory: 57.2M
CPU: 1.671s
CGroup: /system.slice/mariadb.service
└─26174 /usr/sbin/mariadbd
Finally, you will want to secure your MariaDB installation by issuing the following command.
mysql_secure_installation
Output:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
Once secured, you can connect to MySQL and review the existing databases on your database server by using the following command.
mysql -e "SHOW DATABASES;" -p
Output:
root@vps:~# mysql -e "SHOW DATABASES;" -p
Enter password:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
In this week’s feature highlight, we look at How to Install LAMP Stack with MariaDB on Ubuntu 22.04
A LAMP stack is a group of open-source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL or MariaDB database, and dynamic content is processed by PHP.
First, check for any pending system upgrades.
apt update
apt upgrade
Install Apache
Command to install Apache along with its utilities.
root@server:~# systemctl status mariadb
● mariadb.service - MariaDB 10.6.7 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-03-14 20:55:55 UTC; 57min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 14311 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 7 (limit: 1074)
Memory: 57.2M
CPU: 1.266s
CGroup: /system.slice/mariadb.service
└─14311 /usr/sbin/mariadbd
To start MariaDB if it is not active.
systemctl start mariadb
Use the following command to auto start MariaDB at boot time.
systemctl enable mariadb
Next, MariaDB database security.
NOTE: In this step, you will be prompted with several questions.
mysql_secure_installation
Output:
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
To login to MariaDB.
mariadb -u root -p
To exit from MariaDB.
exit
To check MariaDB Version.
mariadb --version
Output:
root@server:~# mariadb --version
mariadb Ver 15.1 Distrib 10.3.25-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Install PHP
PHP 8.1 is the default version of PHP that would be installed on Ubuntu 22.04.
To Enable the Apache PHP module and restart the Apache Web server.
a2enmod php
systemctl restart apache2
To check PHP Version.
php --version
Output:
root@crown:~# php --version
PHP 8.1.0 (cli) (built: Nov 25 2021 19:57:29) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies
To test PHP scripts we need to add the info.php file in the document.
nano /var/www/html/info.php
Add the following to the file.
<?php phpinfo(); ?>
To verify enter the following link in a web browser.
NOTE: Replace with your server IP address below.
http://ip-address/info.php
Run PHP-FPM with Apache [Optional]
FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for heavy-loaded sites.
NOTE: This is an optional step, PHP 8.1 is used to run the PHP code but if you want to run PHP code with PHP-FPM follow the below steps.
First, Let us disable PHP,
a2dismod php
Next, Install PHP-FPM.
apt install php8.1-fpm
Enable proxy_fcgi and setenvif module.
a2enmod proxy_fcgi setenvif
Output:
Considering dependency proxy for proxy_fcgi:
Enabling module proxy.
Enabling module proxy_fcgi.
Module setenvif already enabled
To activate the new configuration, you need to run:
systemctl restart apache2
To enable php8.1-fpm file.
a2enconf php8.1-fpm
Restart the Apache.
systemctl restart apache2
To enable php-fpm.
systemctl enable php8.1-fpm
To start php-fpm.
systemctl start php8.1-fpm
To check the status of php-fpm.
systemctl status php8.1-fpm
Output:
root@crown:~# systemctl status php8.1-fpm
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-03-14 22:16:17 UTC; 29s ago
Docs: man:php-fpm8.1(8)
Main PID: 24942 (php-fpm8.1)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 3 (limit: 1074)
Memory: 7.3M
CPU: 48ms
CGroup: /system.slice/php8.1-fpm.service
Now you have successfully installed the LAMP stack (Apache, MariaDB, and PHP8.1) on Ubuntu 22.04.