bookmark_borderInstalling LEMP Stack on Rocky Linux 9

Hello,

In this week’s feature highlight, we look at How to Install LEMP Stack on Rocky Linux 9

LEMP 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.

Update system

First, we will update the system to the latest with the following commands,

dnf update

Install Nginx Web Server

First, we will start by installing the Nginx web server. To complete the installation, use the following command:

dnf install nginx -y

Output:

[root@server ~]# dnf install nginx -y
Last metadata expiration check: 0:12:50 ago on Sat 16 Jul 2022 10:32:06 PM CEST.
Dependencies resolved.
================================================================================
 Package                Arch        Version                Repository      Size
================================================================================
Installing:
 nginx                  x86_64      1:1.20.1-10.el9        appstream      594 k
Installing dependencies:
 nginx-filesystem       noarch      1:1.20.1-10.el9        appstream       11 k
 rocky-logos-httpd      noarch      90.11-1.el9            appstream       24 k

Transaction Summary
================================================================================
Install  3 Packages

Total download size: 629 k
Installed size: 1.8 M
Downloading Packages:
(1/3): nginx-filesystem-1.20.1-10.el9.noarch.rp  34 kB/s |  11 kB     00:00
(2/3): rocky-logos-httpd-90.11-1.el9.noarch.rpm  60 kB/s |  24 kB     00:00

Once the installation is complete, enable Nginx (to start automatically upon system boot), start the web server, and verify the status using the commands below.

systemctl start nginx

systemctl enable nginx

systemctl status nginx

Output:

[root@server ~]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor pre>
     Active: active (running) since Sat 2022-07-16 22:46:08 CEST; 269ms ago
   Main PID: 1309 (nginx)
      Tasks: 3 (limit: 11120)
     Memory: 2.8M
        CPU: 36ms
     CGroup: /system.slice/nginx.service
             ├─1309 "nginx: master process /usr/sbin/nginx"
             ├─1310 "nginx: worker process"
             └─1311 "nginx: worker process"

Check Nginx version

nginx -v

Output:

[root@server ~]# nginx -v
nginx version: nginx/1.20.1

To make your pages available to the public, you will have to edit your firewall rules to allow HTTP requests on your web server by using the following commands.

firewall-cmd --permanent --zone=public --add-service=http 

firewall-cmd --permanent --zone=public --add-service=https

firewall-cmd --reload

Output:

[root@server ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@server ~]# firewall-cmd --reload
success

Verify that the web server is running and accessible by accessing your server’s IP address.

From your browser,

http://IP_address
image

We need to make the user Nginx the owner of the web directory. By default, it’s owned by the root user.

chown nginx:nginx /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.

yum install mariadb-server mariadb -y

Output:

[root@server ~]# dnf install mariadb-server mariadb -y
Last metadata expiration check: 0:16:13 ago on Sat 16 Jul 2022 10:32:06 PM CEST.
Dependencies resolved.
================================================================================
 Package                       Arch    Version                 Repository  Size
================================================================================
Installing:
 mariadb                       x86_64  3:10.5.13-2.el9         appstream  1.6 M
 mariadb-server                x86_64  3:10.5.13-2.el9         appstream  9.3 M
Installing dependencies:
 checkpolicy                   x86_64  3.3-1.el9               appstream  339 k
 libaio                        x86_64  0.3.111-13.el9          baseos      23 k
 mariadb-common                x86_64  3:10.5.13-2.el9         appstream   32 k
 mariadb-connector-c           x86_64  3.2.6-1.el9_0           appstream  195 k
 mariadb-connector-c-config    noarch  3.2.6-1.el9_0           appstream  9.8 k
 mariadb-errmsg                x86_64  3:10.5.13-2.el9         appstream  188 k
 mysql-selinux                 noarch  1.0.4-2.el9             appstream   35 k
 perl-AutoLoader               noarch  5.74-479.el9            appstream   30 k
 perl-B                        x86_64  1.80-479.el9            appstream  188 k
 perl-Carp                     noarch  1.50-460.el9            appstream   29 k

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@server ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor p>
     Active: active (running) since Sat 2022-07-16 22:50:32 CEST; 285ms ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 3649 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 15 (limit: 11120)
     Memory: 73.0M
        CPU: 599ms
     CGroup: /system.slice/mariadb.service
             └─3649 /usr/libexec/mariadbd --basedir=/usr

Finally, you will want to secure your MariaDB installation by issuing the following command.

mysql_secure_installation

Output:

[root@server ~]# mysql_secure_installation

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@server ~]# mysql -e "SHOW DATABASES;" -p
Enter password:
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
[root@server ~]#

Install PHP

To Install PHP-FPM by running the following command.

yum install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring -y

Output:

[root@server ~]# yum install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring -y
Last metadata expiration check: 0:01:32 ago on Sat 16 Jul 2022 10:50:35 PM CEST.
Dependencies resolved.
================================================================================
 Package               Arch        Version                 Repository      Size
================================================================================
Installing:
 php                   x86_64      8.0.13-1.el9            appstream       14 k
 php-fpm               x86_64      8.0.13-1.el9            appstream      1.6 M
 php-gd                x86_64      8.0.13-1.el9            appstream       45 k
 php-mbstring          x86_64      8.0.13-1.el9            appstream      474 k
 php-mysqlnd           x86_64      8.0.13-1.el9            appstream      154 k
 php-opcache           x86_64      8.0.13-1.el9            appstream      511 k
 php-xml               x86_64      8.0.13-1.el9            appstream      136 k

Once the installation is complete, enable php-fpm (to start automatically upon system boot), start the php-fpm, and verify the status using the commands below.

systemctl start php-fpm

systemctl enable php-fpm

systemctl status php-fpm

Output:

[root@server ~]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor p>
     Active: active (running) since Sat 2022-07-16 22:55:32 CEST; 297ms ago
   Main PID: 4472 (php-fpm)
     Status: "Ready to handle connections"
      Tasks: 6 (limit: 11120)
     Memory: 12.5M
        CPU: 95ms
     CGroup: /system.slice/php-fpm.service
             ├─4472 "php-fpm: master process (/etc/php-fpm.conf)"
             ├─4473 "php-fpm: pool www"
             ├─4474 "php-fpm: pool www"
             ├─4475 "php-fpm: pool www"
             ├─4476 "php-fpm: pool www"
             └─4477 "php-fpm: pool www"

By default, PHP-FPM runs as the apache user. Since we are using the Nginx web server, we need to change the following line.

Using your favorite editor, edit the file /etc/php-fpm.d/www.conf.

nano /etc/php-fpm.d/www.conf

Find the below lines,

user = apache
group = apache

Change them into

user = nginx
group = nginx

Once changed, you will need to reload php-fpm,

systemctl reload php-fpm

Test your PHP, by creating a simple info.php file with a phpinfo() in it. The file should be placed in the root directory for your web server, which is /usr/share/nginx/html/.

To create the file use:

echo "<?php phpinfo() ?>" > /usr/share/nginx/html/info.php

Restart the Nginx and PHP-FPM.

systemctl restart nginx php-fpm

Now again, access http://localhost/info.php or http://yourserver-ip-address/info.php. You should see a page similar to the below one.

image

Done!

bookmark_borderInstalling GNOME GUI on Rocky Linux 9

Hello,

In this week’s feature highlight, we look at How to Install GNOME GUI on Rocky Linux 9

To use Rocky Linux 9 in graphical mode, you will need to install the GNOME package on the system to enable GUI. We will go through the steps required to install GNOME GUI.

Check the available package groups for Rocky Linux 9.

dnf group list

Output:

[root@server ~]# dnf group list
Last metadata expiration check: 0:00:23 ago on Wed 20 Jul 2022 04:16:58 PM CEST.
Available Environment Groups:
   Server with GUI
   Server
   Workstation
   Custom Operating System
   Virtualization Host
Installed Environment Groups:
   Minimal Install
Available Groups:
   Legacy UNIX Compatibility
   Console Internet Tools
   Development Tools
   .NET Development
   Graphical Administration Tools
   Network Servers
   Container Management
   Headless Management
   Scientific Support
   Security Tools
   Smart Card Support
   System Tools
   RPM Development Tools

Installing Gnome GUI

Installing a Gnome GUI requires several packages to be installed on the server. Thankfully this process is simplified using the groupinstall option and all the required packages related to Gnome are grouped in the Server with GUI group.

dnf groupinstall "Server with GUI"

Output:

[root@server ~]#   dnf groupinstall "Server with GUI" --skip-broken
Last metadata expiration check: 0:08:30 ago on Wed 20 Jul 2022 04:51:24 PM CEST.
Dependencies resolved.
================================================================================
 Package                     Arch    Version                   Repository  Size
================================================================================
Installing group/module packages:
 cups                        x86_64  1:2.3.3op2-13.el9_0.1     appstream  1.3 M
 gutenprint-cups             x86_64  5.3.4-4.el9               appstream  576 k
 pnm2ppa                     x86_64  1:1.04-52.el9             appstream  220 k
Installing dependencies:
 cups-client                 x86_64  1:2.3.3op2-13.el9_0.1     appstream   71 k
 cups-filesystem             noarch  1:2.3.3op2-13.el9_0.1     appstream   13 k
 cups-filters                x86_64  1.28.7-10.el9             appstream  788 k
 cups-filters-libs           x86_64  1.28.7-10.el9             appstream  137 k
 foomatic                    x86_64  4.0.13-19.el9             appstream  235 k
 foomatic-db                 noarch  4.0-72.20210209.el9       appstream  1.2 M
 foomatic-db-filesystem      noarch  4.0-72.20210209.el9       appstream  8.2 k
 foomatic-db-ppds            noarch  4.0-72.20210209.el9       appstream   58 M
 ghostscript                 x86_64  9.54.0-7.el9              appstream   37 k
 ghostscript-tools-fonts     x86_64  9.54.0-7.el9              appstream   13 k
 ghostscript-tools-printing  x86_64  9.54.0-7.el9              appstream   13 k
 poppler-cpp                 x86_64  21.01.0-12.el9            appstream   55 k
 poppler-utils               x86_64  21.01.0-12.el9            appstream  231 k
 qpdf-libs                   x86_64  10.3.1-4.el9              appstream  634 k
 cups-ipptool                x86_64  1:2.3.3op2-13.el9_0.1     appstream  3.9 M
Installing Environment Groups:

To enable the GUI as default and boot into graphical mode.

systemctl set-default graphical

Output:

[root@server ~]# systemctl set-default graphical
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target.

GUI Setup

Head over to CrownPanel to access the VNC feature for the next steps.

GUI welcome page will appear and it will prompt for various information to configure your server profile.

Create a user by providing the User name and Password.

Login Screen

Log in to the user which you’ve created.

Rocky Linux 9 desktop screen and its system information.

Rocky Linux 9 GNOME GUI complete!!!


bookmark_borderInstalling WordPress on AlmaLinux 9

Hello,

In this week’s feature highlight, we look at How to Install WordPress on AlmaLinux 9

WordPress is a Content Management System (CMS), a platform you can use to build and maintain a website without any knowledge of coding. This software enables you to customize just about every aspect of your site.

Prerequisites:

WordPress requires LAMP stack installed and running

For detailed installation, refer to LAMP Stack on Almalinux 9

Update Firewall Settings

The below commands will open or allow the HTTP (port 80) and HTTPS (port 443) and then reload the firewall configuration to effect.

firewall-cmd --permanent --zone=public --add-service=http

firewall-cmd --permanent --zone=public --add-service=https

firewall-cmd --reload

Output:

[root@server ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@server ~]# firewall-cmd --reload
success

Secure MariaDB Installation

Next, we secure our MariaDB installation and setup a root password for MariaDB

mysql_secure_installation

Output:

[root@server ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
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:

Creating the new Database

Log into MySQL with the following command,

mysql -u root -p

First, we’ll create a new database,

CREATE DATABASE wordpress;

Next, create a new MySQL user account that we will use to operate on WordPress’s new database, with the username “admin”

CREATE USER `admin`@`localhost` IDENTIFIED BY '<Enter Strong Password here>';

Link the user and DB together by granting our user access to the database,

GRANT ALL ON wordpress.* TO `admin`@`localhost`;

Flush the privileges so that MySQL knows about the user permissions we just added,

FLUSH PRIVILEGES;

Exit out of the MySQL command prompt by typing,

exit

Output:

MariaDB [(none)]> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> CREATE USER `admin`@`localhost` IDENTIFIED BY 'STRONG PASSWORD HERE';
Query OK, 0 rows affected (0.003 sec)

MariaDB [(none)]> GRANT ALL ON wordpress.* TO `admin`@`localhost`;
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> exit

Download and Extract WordPress

Download the WordPress by using the curl command and extract the downloaded file

curl https://wordpress.org/latest.tar.gz --output wordpress.tar.gz

tar xf wordpress.tar.gz

Copy the extracted WordPress directory into the /var/www/html directory

cp -r wordpress /var/www/html

Change permissions and change file SELinux security context

chown -R apache:apache /var/www/html/wordpress

chcon -t httpd_sys_rw_content_t /var/www/html/wordpress -R

Navigate to your browser

http://server_IP/wordpress

Start WordPress installation by clicking on the Run the installation button:

Provide the requested information

Once the WordPress is installed log in with your new user credentials