Category Archives: CentOS

PostgreSQL on AlmaLinux

How to Install PostgreSQL 17 on AlmaLinux 9

PostgreSQL (often called Postgres) is a powerful, open-source relational database management system (RDBMS). It is known for its scalability, extensibility, and strong compliance with SQL standards.

If you’re running AlmaLinux 9 and need to set up PostgreSQL, you’re in the right place.

In this guide, I’ll walk you through the installation process step by step no stress, just what you need to get it up and running.

Step 1: Update Your System

Before installing anything, let’s make sure your system is up to date. Open a terminal and run:

dnf update & dnf upgrade

This ensures you have the latest security patches and software versions. It’s always a good habit to update before installing new software.

Step 2: Check Available PostgreSQL Versions

AlmaLinux ships with multiple versions of PostgreSQL. To see what’s available, run:

dnf module list postgresql

You’ll get a list of PostgreSQL versions that you can install.

PostgreSQL server 15 and 16 are included in the AppStream components.

So to install PostgreSQL 17 we will need to add the following official repositories:

dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Disable the default PostgreSQL module once the repository has been added:

dnf -qy module disable postgresql

Step 3: Install PostgreSQL 17

Now, let’s install the PostgreSQL 17 server and some extra tools:

dnf install postgresql17-server postgresql17-contrib

This will pull in all the necessary packages.

Step 4: Initialize the Database

Before we can use PostgreSQL, we need to initialize the database.

Run this command:

/usr/pgsql-17/bin/postgresql-17-setup initdb

This sets up the default database files and configurations as well as the main configuration file /var/lib/pgsql/17/data/postgresql.conf.

Step 5: Start and Enable PostgreSQL 17

Now, let’s start the PostgreSQL 17 service and make sure it runs automatically on system boot:

systemctl enable --now postgresql-17

To check if PostgreSQL is running, use:

systemctl status postgresql-17

If everything is working, you should see a message saying PostgreSQL is “active (running).”

● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running)
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 104278 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 104283 (postgres)
      Tasks: 7 (limit: 14115)
     Memory: 17.7M
        CPU: 659ms
     CGroup: /system.slice/postgresql-17.service
             ├─104283 /usr/pgsql-17/bin/postgres -D /var/lib/pgsql/17/data/
             ├─104284 "postgres: logger "
             ├─104285 "postgres: checkpointer "
             ├─104286 "postgres: background writer "
             ├─104288 "postgres: walwriter "
             ├─104289 "postgres: autovacuum launcher "
             └─104290 "postgres: logical replication launcher "

Step 6: Set a Password for the PostgreSQL 17

User By default, PostgreSQL creates a user called postgres. You’ll want to set a password for it.

Switch to the postgres user with:

su postgres

Then, enter the PostgreSQL shell:

psql

Set a new password by running:

ALTER USER postgres WITH PASSWORD 'your_secure_password';

Replace ‘your_secure_password’ with something strong! Once done, type \q to exit, then exit to return to your regular user.

Step 7: Backup and Restore a Single Database

You can back up and restore a single database using the pg_dump utility.

For example, to back up a single database named db and generate a backup file named db_backup.sql, run the following command:

su - postgres
pg_dump -d db -f db_backup.sql

You can also restore a single database using psql command.

For example, to restore a single database named db from a backup file named db_backup.sql, run the following command:

su - postgres
psql -d db -f db_backup.sql

Step 8: Allow Remote Connections (Optional)

By default, PostgreSQL only allows local connections. If you need remote access, edit the config file:

nano /var/lib/pgsql/17/data/postgresql.conf

Find this line:

#listen_addresses = 'localhost'

Uncomment it and change it to:

listen_addresses = '*'

Then, edit the authentication settings:

nano /var/lib/pgsql/17/data/pg_hba.conf

Add this line at the bottom (replace 192.168.1.0/24 with your network range):

host all all 192.168.1.0/24 md5

Restart PostgreSQL for changes to take effect:

sudo systemctl restart postgresql

Comments and Conclusion

You’re Done! That’s it. You now have PostgreSQL 17 server running on AlmaLinux 9!

You can start creating databases and working with your applications. If you have any issues, check the logs with:

journalctl -u postgresql-17 --no-pager | tail -50

For additional help or useful information, we recommend you to check  the official PostgreSQL 17 documentation.

If you have any questions please leave a comment below.

How to Install Varnish with Nginx on AlmaLinux 9

Varnish is a popular open-source web application accelerator, also known as a caching HTTP reverse proxy, that is used to speed up dynamic web content delivery. It caches frequently accessed content and serves it directly from memory, reducing the load on the application servers and reducing the response time for users.

Varnish sits between the client and the web server and acts as an intermediary. When a user requests a web page, Varnish checks if the page is already in its cache. If it is, Varnish serves the page directly from its cache, without having to request it from the web server. If the page is not in the cache, Varnish requests it from the web server and caches it for future use.

Varnish also allows users to configure cache policies and rules to optimize caching behavior, and provides tools for monitoring and analyzing cache performance. It is commonly used by high-traffic websites to improve their performance and scalability.

In this tutorial, we will show you how to install  and configure Varnish with Nginx on AlmaLinux 9.

Step 1: Update Operating System

Update your AlmaLinux 9 operating system to make sure all existing packages are up to date:

# dnf update

Also, install the EPEL package manager to allow Varnish dependencies to be installed:

# dnf install epel-release 

Step 2: Install Nginx

You can install Nginx via dnf package manager by executing the following command.

# dnf install nginx

Nginx does not start automatically when it is installed. You can start the Nginx service and configure it to run on startup by entering the following commands:

# systemctl start nginx
# systemctl enable nginx

Verify the status of the Nginx service using systemctl status command:

# systemctl status nginx

Output:

 nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
    Drop-In: /usr/lib/systemd/system/nginx.service.d
             └─php-fpm.conf
     Active: active (running)
   Main PID: 1720 (nginx)
      Tasks: 2 (limit: 5740)
     Memory: 2.3M
        CPU: 28ms
     CGroup: /system.slice/nginx.service
             ├─1720 "nginx: master process /usr/sbin/nginx"
             └─1721 "nginx: worker process"

If firewalld is enabled consider allowing HTTP and HTTPS services:

$ sudo firewall-cmd --permanent --add-service={http,https}
$ sudo firewall-cmd --reload

Now you need to configure Nginx to work with Varnish Cache.

Open the Nginx config file /etc/nginx/nginx.conf :

 # nano /etc/nginx/nginx.conf

Search for the Listen line and change it to 8080:

.....   
    server {
        listen       8080;
        listen       [::]:8080;
        server_name  _;
        root         /usr/share/nginx/html;
 .....

Save and close the file. Then restart the Nginx service to apply the changes:

# systemctl restart nginx

Step 3: Install Varnish 7

First disable the Varnish service from the dnf package manager:

# dnf module disable varnish

By default, the latest version of Varnish is not available on the AlmaLinux 9 base repository.

So you need to run the following command to add the latest Varnish repository to your system:

curl -s https://packagecloud.io/install/repositories/varnishcache/varnish73/script.rpm.sh | bash

After the repository is added, install Varnish using the following command:

# dnf install varnish

Check the installed version with the following command:

# varnishd -V

Output:

varnishd (varnish-7.3.0 revision 84d79120b6d17b11819a663a93160743f293e63f)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2023 Varnish Software

Now start and enable Varnish (to start automatically upon system boot):

# systemctl start varnish
# systemctl enable varnish

Verify the status using the following command:

# systemctl status varnish
● varnish.service - Varnish Cache, a high-performance HTTP accelerator
Loaded: loaded (/usr/lib/systemd/system/varnish.service; enabled; vendor preset: disabled)
Active: active (running)
Main PID: 4266 (varnishd)
Tasks: 217
Memory: 113.4M
CPU: 2.074s
CGroup: /system.slice/varnish.service
├─4266 /usr/sbin/varnishd -a :6081 -a localhost:8443,PROXY -f /etc/varnish/default.vcl -P /run/varnish/varnishd.pid -p feature=+http2 -s malloc>
└─4280 /usr/sbin/varnishd -a :6081 -a localhost:8443,PROXY -f /etc/varnish/default.vcl -P /run/varnish/varnishd.pid -p feature=+http2 -s malloc>

Step 4: Configure Varnish Cache

The default Varnish listening port is 6081. Now we need to configure Varnish to listen on port 80.

You can do it by editing /usr/lib/systemd/system/varnish.service file:

# nano /usr/lib/systemd/system/varnish.service

Add the configuration to change the port 6081 to 80 as shown below:

...
ExecStart=/usr/sbin/varnishd \
-a :80 \
-a localhost:8443,PROXY \
-f /etc/varnish/default.vcl \
-P %t/%N/varnishd.pid \
-p feature=+http2 \
-s malloc,256m
ExecReload=/usr/sbin/varnishreload
...

After the changes, restart the Varnish service for the changes to take effect.

# systemctl daemon-reload
# sudo systemctl restart varnish

Step 5: Test Varnish Cache

Test if Varnish cache is enabled and working with the Nginx service using the curl command:

# curl -I http://your-IP-address

Output:

HTTP/1.1 200 OK
Server: nginx/1.20.1
Date: Thu, 06 Apr 2023 11:22:04 GMT
Content-Type: text/html
Content-Length: 4681
Last-Modified: Sat, 09 Oct 2021 17:49:21 GMT
ETag: "6161d621-1249"
X-Varnish: 2
Age: 0
Via: 1.1 192.168.1.150 (Varnish/7.3)
Accept-Ranges: bytes
Connection: keep-alive

This means that your Varnish Cashe is active and running on your server.

Comments and Conclusion

In the tutorial, you have learned how to install and configure Varnish on AlmaLinux 9.

For additional help or useful information, you can check the official Varnish website.

How to Install and Configure CSF on AlmaLinux 9

ConfigServer Security & Firewall (CSF) is an iptables-based firewall that provides high-level security to the Linux system.

CSF includes a wide range of features, such as IP blocking, port blocking, and DoS protection. It also supports advanced security measures, such as rate limiting, connection tracking, and SSH login detection. In addition to its firewall features, CSF includes tools for system and file integrity checking, as well as email and login tracking.

Step 1: Update Operating System

Update your AlmaLinux 9 operating system to make sure all existing packages are up to date:

# dnf update

Also, install:

# dnf install wget nano tar

Step 2: Disable firewalld and any other iptables firewall

Run the following command below to sto p and disable the firewalld service:

# systemctl stop firewalld
# systemctl disable firewalld

Step 3: Install Required Perl Modules for CSF

Install the following Perl modules required by CSF.

# dnf install perl-libwww-perl.noarch perl-LWP-Protocol-https.noarch perl-GDGraph

If some modules are not available in the default repository install the epel repository using the following command:

# dnf install epel-release

Then try to install the modules again.

Step 4: Download CSF

By default, CSF is not available in the AlmaLinux standard repository, so you will need to download it from their official website.

# wget https://download.configserver.com/csf.tgz

Once downloaded, extract file with the following command:

# tar xzf csf.tgz

Change the directory to the extracted directory:

# cd csf

Install the CSF by running the installation script:

# sh install.sh

Then you can check the iptables mode using below command.

# perl /usr/local/csf/bin/csftest.pl

You should see the following output:

Testing ip_tables/iptable_filter…OK
Testing ipt_LOG…OK
Testing ipt_multiport/xt_multiport…OK
Testing ipt_REJECT…OK
Testing ipt_state/xt_state…OK
Testing ipt_limit/xt_limit…OK
Testing ipt_recent…OK
Testing xt_connlimit…OK
Testing ipt_owner/xt_owner…OK
Testing iptable_nat/ipt_REDIRECT…OK
Testing iptable_nat/ipt_DNAT…OK

RESULT: csf should function on this server

Step 5: Configuring the CSF

CSF runs in TEST mode by default. To disable it, you need to edit the /etc/csf/csf.conf file.

# nano /etc/csf/csf.conf

Locate the line TESTING = 1 and change the value to 0 or else LFD daemon fail to start.

TESTING = "0"

Locate the line RESTRICT_SYSLOG = 0 and change its value to 3. This means only members of the RESTRICT_SYSLOG_GROUP can access the syslog/rsyslog files.

RESTRICT_SYSLOG = "3"

Also, you can allow incoming and outgoing port as per your requirement:

# Allow incoming TCP ports
TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995"

# Allow outgoing TCP ports
TCP_OUT = "20,21,22,25,53,80,110,113,443,587,993,995"

Once your done all the configuration, restart and enable CSF:

# systemctl restart csf && systemctl restart lfd
# systemctl enable csf && systemctl enable lfd
# systemctl status csf && systemctl status lfd

Step 6: Enable CSF GUI

By default, it is disabled in the CSF default configuration file, so you will need to enable it first. For enabling CSF GUI you need to setup Integrated User Interface section in csf.conf configuration file.

Open the CSF main configuration file with the following command:

# nano /etc/csf/csf.conf

Change the following lines:

###############################################################################
# SECTION:Integrated User Interface
###############################################################################

# 1 to enable, 0 to disable web ui 
UI = "1"

# Set port for web UI. The default port is 6666. 
UI_PORT = "8888"

# Leave blank to bind to all IP addresses on the server 
UI_IP = ""

# Set username for authetnication 
UI_USER = "admin"

# Set a strong password for authetnication 
UI_PASS = "Test@12345"

Next you need to allow the IP from where you are going to access CSF GUI. You can either allow the entire subnet or you can also choose to allow some specific IP Address like below.

# echo "YOUR_PUBLIC_IP_ADDRESS" >>  /etc/csf/ui/ui.allow

Then restart the CSF and LFD service to apply the changes.

# systemctl restart csf
# systemctl restart lfd

Step 7: Access CSF Web Interface

Open your web browser and type the URL https://your-server-IP:8888. You will be redirected to the CSF login page:

Provide your admin username and password and click on the Enter button. You should see the dashboard:

Step: 8: Manage CSF with Command Line

To list all firewall rules, run the following command:

# csf -l

To stop CSF, run the following command:

# csf -s

To allow a specific IP address, run the following command:

# csf -a IP-address

To deny an IP address, run the following command:

# csf -d IP-address

To remove blocked IP address from a CSF rule, run the following command:

# csf -dr IP-address

To verify whether the IP address is blocked or not, run the following command:

# csf -g IP-address

To flush the CSF firewall rules, run the following command:

# csf -f

To disable CSF, run the following command:

# csf -x

Step 9: Uninstall CSF and LFD on AlmaLinux

Run the following script to remove CSF and LFD from your system.

# sh /etc/csf/uninstall.sh

List of Important CSF Configuration Files

Below are the important configuration files that control the most of the rules in the CSF.

  • csf.conf – the main configuration file, it has helpful comments explaining what each option does
  • csf.allow – a list of IP’s and CIDR addresses that should always be allowed through the firewall
  • csf.deny – a list of IP’s and CIDR addresses that should never be allowed through the firewall
  • csf.ignore – a list of IP’s and CIDR addresses that lfd should ignore and not not block if detected
  • csf.*ignore – various ignore files that list files, users, IP’s that lfd should ignore. See each file for their specific purpose and tax

If you manually modify these files, you will need to restart csf and then lfd them to take effect.

Conclusion

Congratulations! You have successfully installed CSF Firewall. Thanks for using this tutorial for installing ConfigServer Security & Firewall (CSF) on your AlmaLinux 9 OS. For additional help or useful information, you can check the official CSF Firewall website.

 

How to Install phpBB on AlmaLinux 9

phpBB is an acronym for PHP Bulletin Board. It is a fully scalable and customizable open-source forum written in PHP. It can be used to to create forums, start topics and share ideas.

In this tutorial we will show you how to install phpBB on AlmaLinux 9 using the LAMP stack.

Step 1: Update Operating System

Update your AlmaLinux 9 operating system to make sure all existing packages are up to date:

# dnf update

Also, install:

# dnf install wget nano unzip

Step 2: Install Apache web server

To install Apache web server, run the following command:

# dnf install httpd

Apache does not start automatically when it is installed, you need to start it:

# systemctl start httpd

Then enable it to start on boot time.

# systemctl enable httpd

If firewalld is enabled consider allowing HTTP and HTTPS services:

# firewall-cmd --permanent --add-service={http,https}
# firewall-cmd --reload

Step 3: Install PHP and required PHP modules

In this section we will install PHP and PHP extensions required to run phpBB with the following command:

# dnf install php php-mysqli php-gd php-zip php-intl php-mbstring php-json

Once the installation is complete, verify the version of PHP installed:

# php -v
Output:
PHP 8.0.13 (cli) (built: Nov 16 2021 18:07:21) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

Step 4: Install MariaDB and create a database

To be able to install MariaDB on AlmaLinux 9 you need to add the MariaDB YUM repository:

# curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup

Once the repository has been added to the system, installing MariaDB is an easy task that can be accomplished with the following command:

# dnf install mariadb-server

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

# systemctl start mariadb
# systemctl enable mariadb

Verify the installed version of MariaDB.

# systemctl status mariadb

Output:

 mariadb.service - MariaDB 10.5 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running)
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 47677 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 11 (limit: 10951)
Memory: 71.2M
CPU: 2.238s
CGroup: /system.slice/mariadb.service
└─47677 /usr/libexec/mariadbd --basedir=/usr

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script:

mysql_secure_installation

Configure it like this:

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Once the database server is installed, log into the MariaDB prompt:

#  mysql -u root -p

To create a database, database user, and grant all privileges to the database user run the following commands:

MariaDB [(none)]> CREATE DATABASE phpbb_db;
MariaDB [(none)]> CREATE USER 'phpbb_user'@'localhost' IDENTIFIED BY 'Passw0rd';
MariaDB [(none)]> GRANT ALL ON phpbb_db.* TO 'phpbb_user'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Step 5: Download phpBB forum

The phpBB forum is not available to download or install using the AlmaLinux package repositories. We have to download its files manually from its official website.

The version of phpBB as of this writing is 3.3.8.

Change directory to /tmp directory, you can use any directory:

# cd  /tmp

Use the following command to download phpBB forum:

# wget https://download.phpbb.com/pub/release/3.3/3.3.8/phpBB-3.3.8.zip

Extract file into the folder /var/www/html with the following command,

# unzip phpBB-3.3.8.zip -d /var/www/html

Rename the extracted directory:

# mv /var/www/html/phpBB3 /var/www/html/phpbb

Enable permission for the Apache webserver user to access the phpBB files,

# chown -R apache:apache /var/www/html/phpbb

Step 6: Configure Apache Web Server for phpBB forum

Navigate to /etc/httpd/conf.d directory and run the following command to create a configuration file for your phpBB installation:

# nano /etc/httpd/conf.d/phpbb.conf

Add the following content:

<VirtualHost *:80>

ServerName your-domain.com

ServerAdmin webmaster@your-domain.com
DocumentRoot /var/www/html/phpbb

<Directory /var/www/html/phpbb/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/your-domain.com_error.log
CustomLog /var/log/httpd/your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Restart the Apache web server.

# systemctl restart httpd

Step 7: Install phpBB forum on AlmaLinux 9

Open your browser and complete the final steps e.g http://your-domain.com

To start the installation, click the ‘Install’ tab then click install.

Fill in the details of the Administrator user and password and click on ‘Submit‘.

Fill up the database configuration:

For the server configuration you can just leave the default settings and click ‘Submit’:

 

In this steps you will ask to provide your SMTP settings, if email functionality is not configured, simply click ‘Submit‘ without changing any parameter.

Specify the settings of the Bulletin Board such as the default language, Board Title, and a short description of the board. Then click ‘Submit‘:

Finally, the installation should be complete!

Click on ‘the ACP‘ link provided. This takes you to the Admin panel shown:

Now, delete the ‘Install‘ folder to access the create, delete the posts and access the features of the phpBB forum software.

Go to your server terminal and run this command:

# rm -rf /var/www/html/phpbb/phpbb/install

Comments and Conclusion

That’s it. You have successfully installed phpBB on AlmaLinux 9.

If you have any questions please leave a comment below.

How to Install WordPress on AlmaLinux 9

WordPress is a free, open-source and one of the most popular Content Management System (CMS) written in PHP, combined with MySQL/MariaDB database. Millions of websites are currently running on it and remains perhaps the most popular CMS for blogging, which was its original use case.

In this tutorial we’ll show you how to setup a LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack and install WordPress on AlmaLinux 9 OS.

Step 1: Update Operating System

Update your AlmaLinux 9 operating system to make sure all existing packages are up to date:

$ sudo dnf update && sudo dnf upgrade -y

Also, install:

$ sudo dnf install nano wget unzip

Step 2: Install Apache web server on AlmaLinux 9

You can install Apache via dnf package manager by executing the following command.

$ sudo dnf install httpd

You can start the httpd service and configure it to run on startup by entering the following commands:

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

Verify the status of the httpd service using systemctl status command:

$ sudo systemctl status httpd

Output:

● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
     Active: active (running)
       Docs: man:httpd.service(8)
   Main PID: 10643 (httpd)
     Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec:   0 B/sec"
      Tasks: 213 (limit: 5738)
     Memory: 28.9M
        CPU: 198ms
     CGroup: /system.slice/httpd.service
             ├─10643 /usr/sbin/httpd -DFOREGROUND
             ├─10644 /usr/sbin/httpd -DFOREGROUND
             ├─10645 /usr/sbin/httpd -DFOREGROUND
             ├─10646 /usr/sbin/httpd -DFOREGROUND
             └─10647 /usr/sbin/httpd -DFOREGROUND

If firewalld is enabled consider allowing HTTP and HTTPS services:

$ sudo firewall-cmd --permanent --add-service={http,https}
$ sudo firewall-cmd --reload

You can test to make sure everything is working correctly by navigating to:

http://your-IP-address

If everything is configured properly, you should be greeted by the default Apache2 Page, as seen below.

Step 3: Install PHP and PHP extensions for WordPress

You can install PHP and other supporting packages using the following command:

$ sudo dnf install php php-curl php-bcmath php-gd php-soap php-zip php-curl php-mbstring php-mysqlnd php-gd php-xml php-intl php-zip

Verify if PHP is installed.

php -v

Output:

PHP 8.0.13 (cli) (built: Nov 16 2021 18:07:21) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

Step 4: Install MariaDB and create a database

You can install MariaDB with the following command:

$ sudo dnf install mariadb-server mariadb

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

$ systemctl start mariadb
$ systemctl enable mariadb

Verify the status of the MariaDB service using systemctl status command:

$ sudo systemctl status mariadb

Output:

● mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
     Active: active (running)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 13088 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 11 (limit: 5738)
     Memory: 73.5M
        CPU: 390ms
     CGroup: /system.slice/mariadb.service
             └─13088 /usr/libexec/mariadbd --basedir=/usr

Once the database server is installed, run the following command to secure your MariaDB server:

$ sudo mysql_secure_installation

Use the following options for the prompt.

Enter current password for root (enter for none): Just press the Enter
Set root password? [Y/n]: Y
New password: Enter your password
Re-enter new password: Repeat your password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y

Restart the database server for the changes to take effect.

$ sudo systemctl restart mariadb

Login to MariDB shell using the following command:

$ sudo  mysql -u root -p

To create a database, database user, and grant all privileges to the database user run the following commands:

MariaDB [(none)]> CREATE DATABASE wordpress_db;
MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'PaSSw0rd';
MariaDB [(none)]> GRANT ALL ON wordpress_db.* TO 'wordpress_user'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Step 5: Download WordPress on AlmaLinux 9

We will now download the latest version of WordPress from the WordPress Official site.

Use the following command to download WordPress:

$ sudo wget https://wordpress.org/latest.zip

Extract file into the folder /var/www/html/ with the following command,

$ sudo unzip latest.zip -d /var/www/html/

Change the permission of the website directory:

$ sudo chown -R apache:apache /var/www/html/wordpress/
$ sudo chcon -t httpd_sys_rw_content_t /var/www/html/wordpress -R

Step 6: Configure Apache Web Server for WordPress

Navigate to /etc/httpd/conf.d directory and run the following command to create a configuration file for your installation:

$ sudo nano /etc/httpd/conf.d/wordpress.conf

Add the following content:

<VirtualHost *:80>

ServerAdmin webmaster@your-domain.com

ServerName your-domain.com
ServerAlias www.your-domain.com
DocumentRoot /var/www/html/wordpress

<Directory /var/www/html/wordpress/>
        Options FollowSymlinks
        AllowOverride All
        Require all granted
</Directory>

ErrorLog /var/log/httpd/your-domain.com_error.log
CustomLog /var/log/httpd/your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Restart the Apache web server.

$ sudo systemctl restart httpd

Step 7: Access WordPress Web Installer

Open your browser type your domain e.g http://your-domain.com  and click on the Let's go! button to complete the required steps:

Provide the requested database information and click on the Submit button:

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

Provide the requested information and click on the Install WordPress button:

Once the WordPress is installed, enter your administrator user, password and click on the Log In button:

You will get the dashboard in the following screen:

Comments and Conclusion

That’s it. You have successfully installed WordPress CMS (Content Management System) on AlmaLinux 9 OS.

If you have any questions please leave a comment below.

How to Install NextCloud on AlmaLinux 8

NextCloud provides reliable self-hosted cloud services and comes off as a good substitute for platforms such as Box and DropBox. It runs on your own server, protecting your data and giving you access from your desktop or mobile devices. You can synchronize everything between your devices and share files with others as well.

Update Operating System

Update your AlmaLinux 8 operating system to make sure all existing packages are up to date:

$ sudo dnf update

Also, install:

$ sudo dnf install wget nano unzip

Install Apache web server

To install Apache web server, run the following command:

$ sudo dnf install httpd

Apache does not start automatically when it is installed, you need to start it:

$ sudo systemctl start httpd

Then enable it to start on boot time.

$ sudo systemctl enable httpd

Install PHP 8.1 and required PHP modules

Currently, PHP 8.1 is not featured in AlmaLinux’s AppStream. However, you can install PHP from (Remi) repository, a free-to-use third-party repository that deploys the latest PHP 8.0 builds.

To install EPEL, use the following (dnf) terminal command:

$ sudo dnf install epel-release

Now that you have added the EPEL repository, enable (Remi repository) with the following command:

$ sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Use the (dnf) command to update your repository list:

$ sudo dnf update

Next, enable PHP 8.1 with the following command:

$ sudo dnf module enable php:remi-8.1

Now that you have added the Remi PHP repository and enabled PHP 8.1 to be the default version on your system, you can install PHP 8.1 with the following command:

$ sudo dnf install php

For NextCloud to seamlessly work some additional PHP modules are required, install them with the following command:

$ dnf install php-mysql php-fpm php-gd php-zip php-intl php-bcmath php-gmp

Increase PHP Memory limit:

$ sudo nano /etc/php.ini

Find memory_limit and set the value to 512M

memory_limit = 512M

Install MariaDB and create a database

MariaDB 10.7 is the latest release version for this relational database system. To be able to install MariaDB 10.7 on AlmaLinux 8 you need to add the MariaDB YUM repository:

$ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
$ sudo bash mariadb_repo_setup --mariadb-server-version=10.7

Once the repository has been added to the system, installing MariaDB is an easy task that can be accomplished with the following command:

$ sudo dnf install MariaDB-server MariaDB-client

Once the installation is complete, verify the installed version of MariaDB.

$ sudo systemctl status mariadb

Output:

 mariadb.service - MariaDB 10.7.1 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running)
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 1450 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 1000 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status>
Process: 987 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 1017 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 8 (limit: 11234)
Memory: 89.1M
CGroup: /system.slice/mariadb.service
└─1017 /usr/sbin/mariadbd

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb

Once the database server is installed, log into the MariaDB prompt:

$ sudo  mysql -u root -p

To create a database, database user, and grant all privileges to the database user run the following commands:

MariaDB [(none)]> CREATE DATABASE nextcloud_db;
MariaDB [(none)]> CREATE USER 'nextcloud_user'@'localhost' IDENTIFIED BY 'Passw0rd';
MariaDB [(none)]> GRANT ALL ON nextcloud_db.* TO 'nextcloud_user'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Installing NextCloud

Use the following command to download NextCloud 23:

$ sudo dnf -y install wget
$ sudo wget https://download.nextcloud.com/server/releases/nextcloud-23.0.2.zip

Extract file into the folder /var/www/ with the following command,

$ sudo dnf -y install unzip 
$ sudo unzip nextcloud-23.0.2.zip -d /var/www/

Create a directory to store the user data,

$ sudo mkdir -p /var/www/nextcloud/data

Enable permission for the Apache webserver user to access the NextCloud files,

$ sudo chown -R apache:apache /var/www/nextcloud/

Open port 80 on the webserver:

$ sudo firewall-cmd --add-port=80/tcp --zone=public --permanent

$ sudo firewall-cmd --reload

Configure Apache Web Server for NextCloud

Navigate to /etc/apache2/sites-available directory and run the following command to create a configuration file for your NextCloud installation:

$ sudo nano /etc/httpd/conf.d/nextcloud.conf

Add the following content:

<VirtualHost *:80>

ServerName cloud.your-domain.com

ServerAdmin webmaster@your-domain.com
DocumentRoot /var/www/nextcloud

<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/cloud.your-domain.com_error.log
CustomLog /var/log/httpd/cloud.your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Restart the Apache web server.

$ sudo systemctl restart httpd

Access your NextCloud Application

Open your browser and complete the final steps at http://cloud.your-domain.com

Click the Install button, you will see the Web interface of NextCloud.

Comments and Conclusion

That’s it. You have successfully installed NextCloud on AlmaLinux 8.

If you have any questions please leave a comment below.

How to Install LAMP Stack on AlmaLinux 8.5

LAMP is a popular open-source software stack that is mostly used for testing and hosting web applications. It’s an acronym for Linux Apache MariaDB / MySQL and PHP.

Apache is a popular open-source and widely used web server. MariaDB is a free and open-source, commercially supported relational database management system, and PHP is a server-side scripting language used for developing dynamic web pages.

In this tutorial, we will show you how to install LAMP stack on AlmaLinux 8.

Update Operating System

Update your AlmaLinux 8 operating system to make sure all existing packages are up to date:

$ sudo dnf update

Install Apache webserver

Well, like most of the Linux operating systems, we don’t have to add any third-party Repos to install Apache- HTTPd server.

You can install Apache via dnf package manager by executing the following command.

$ sudo dnf install httpd

Apache does not start automatically when it is installed. You can start the Apache service and configure it to run on startup by entering the following commands:

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

Verify the status of the Apache service using systemctl status command:

$ sudo systemctl status httpd

Output:

 httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running)
Docs: man:httpd.service(8)
Main PID: 36360 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 11221)
Memory: 38.6M
CGroup: /system.slice/httpd.service
├─36360 /usr/sbin/httpd -DFOREGROUND
├─36375 /usr/sbin/httpd -DFOREGROUND
├─36376 /usr/sbin/httpd -DFOREGROUND
├─36378 /usr/sbin/httpd -DFOREGROUND
└─36405 /usr/sbin/httpd -DFOREGROUND

If firewalld is enabled consider allowing HTTP and HTTPS services:

$ sudo firewall-cmd --permanent --add-service={http,https}
$ sudo firewall-cmd --reload

You can test to make sure everything is working correctly by navigating to:

http://your-IP-address

If everything is configured properly, you should be greeted by the default AlmaLinux Test Page, as seen below.

AlmaLinux Test Page

Install MariaDB 10.7

MariaDB 10.7 is the latest release version for this relational database system. To be able to install MariaDB 10.7 on AlmaLinux 8 you need to add the MariaDB YUM repository:

$ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
$ sudo bash mariadb_repo_setup --mariadb-server-version=10.7

Once the repository has been added to the system, installing MariaDB is an easy task that can be accomplished with the following command:

$ sudo dnf install MariaDB-server MariaDB-client

Once the installation is complete, verify the installed version of MariaDB.

$ sudo dnf info MariaDB-server

MariaDB 10.7 on AlmaLinux 8.5

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

$ systemctl start mariadb
$ systemctl enable mariadb

Check the status of the service:

$ systemctl status mariadb

Example output:

$  mariadb.service - MariaDB 10.7.1 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) 
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 35787 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 13 (limit: 11221)
Memory: 68.0M
CGroup: /system.slice/mariadb.service
└─35787 /usr/sbin/mariadbd

Secure MariaDB

Run mariadb-secure-installation script which helps you secure your MariaDB database server:

$ sudo mariadb-secure-installation

You can set a root password for MariaDB along with removing empty databases, restricting remote access except for localhost, removing anonymous users, and more:

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Install PHP 8.1

Currently, PHP 8.1 is not featured in AlmaLinux’s AppStream. However, you can install PHP from (Remi) repository, a free-to-use third-party repository that deploys the latest PHP 8.1 builds.

To install EPEL, use the following (dnf) terminal command:

$ sudo dnf install epel-release

Now that you have added the EPEL repository, enable (Remi repository) with the following command:

$ sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Use the (dnf) command to update your repository list:

$ sudo dnf update

Next, enable PHP 8.1 with the following command:

$ sudo dnf module enable php:remi-8.1

Now that you have added the Remi PHP repository and enabled PHP 8.1 to be the default version on your system, you can install PHP 8.1 with the following command:

$ sudo dnf install php

You can check your PHP version using the following command:

$ php -v

Example output:

PHP 8.1.1 (cli) (built: Dec 15 2021 02:00:45) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.1, Copyright (c) Zend Technologies
with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies

If you would like to install the most commonly used extensions for PHP 8.1, use the following command:

$ sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imap php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-dom php-redis php-memcached php-memcache

You can check your PHP modules using the following command:

$ php -m

Example output:

[PHP Modules]
..............
igbinary
imagick
imap
intl
json
libxml
mbstring
memcache
memcached
msgpack
mysqli
mysqlnd
openssl
..............

[Zend Modules]
Zend OPcache

Comments and Conclusion

In the tutorial, you have learned how to install LAMP stack on AlmaLinux 8.

If you have any questions please leave a comment below.