Home Blog

How to Install Apache on Rocky Linux 8.

0

The Apache HTTP Server aka Apache is a free and open-source cross-platform web server software released under the terms of Apache Licence 2.0. Being cross-platform, it operates in modern Operating systems including UNIX and Windows. Apache server is one of the most popular and powerful web servers in the world due to its ease of administration and flexibility. It is designed to provide a secure, efficient, and extensible server that provides HTTP service concurring with the current HTTP standards.

As of this article, the stable release available for download is release 2.4.49 released on 16th September 2021.

Features of Apache Webserver.

  • UNIX Threading – Apache Server can now run on UNIX systems with POSIX threads support. It can now run in a hybrid multi-process multi-threaded mode. This makes Apache Server very scalable.
  • Multiprotocol support – Apache HTTP server has some infrastructure in place to support multiple protocols. e.g mod_echo.
  • Better support for non-UNIX users – Apache HTTP Server 2.0 is faster and more stable on non-Unix platforms such as BeOS, OS/2, and Windows.
  • New Apache httpd API – The API for modules has changed significantly for 2.0. This is because module-ordering / priority is automatically done with 2.0. module ordering is now done per-hook to allow more flexibility. new calls have been added that provide additional module capabilities without patching the core Apache HTTP Server.
  • IPv6 Support – On systems where IPV6 is supported, Apache httpd gets IPv6 listening sockets by default.
  • Filtering – Apache httpd modules are now written as filters which act on the stream of content as it is delivered to or from the server.
  • Multilanguage Error Responses – Error response messages to the browser are now provided in several languages, using SSI documents. They are hence easily customizable to achieve a consistent look and feel.
  • Simplified configuration – Many confusing directives have been simplified. The often confusing Port and BindAddress directives have been dropped. Only the listen directive is used for IP Address binding. The server name directive specifies the server name and port number only.
  • Native Windows NT Unicode Support – Apache httpd 2.0 on Windows NT now uses utf-8 for all filename encodings. This provides multilanguage support for all Windows NT-based installations.
  • Regular Expression Library Updated – Apache httpd 2.0 includes the Perl Compatibe Regular Expression Library (PCREL).All regular expression evaluation now uses the more powerful Perl 5 syntax

In this article, I will take you through how to install Apache on Rocky Linux 8.

Step 1 : Install Apache.

To install Apache carry out the following steps.

Clean-up dnf

To clean up dnf, run the command clean all.

sudo dnf clean all

Update and upgrade your system.

As a matter of best practice ensure your system is updated and upgraded before any installation.

sudo dnf -y update 
sudo dnf -y upgrade 

Install Apache

Execute the command below to install Apache Webserver.

sudo dnf -y install httpd

Bravo, you have successfully installed the Apache webserver on your Rocky Linux 8.

Step 2 : Allow Apache through the Firewall

Allow the default HTTP and HTTPS port, ports 80 and 443 through the firewall by running the command below.

sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp

Reload the firewall

sudo firewall-cmd --reload

Step 3 : Configure Apache to start on Boot.

To configure Apache to start on boot, carry the steps below.

Start Apache service.

sudo systemctl start httpd

If the above command throws in an error, ensure you stop the nginx service then execute the command again. To stop the nginx service, simply run the command below.

sudo systemctl stop nginx

After successfully starting the Apache service, enable the Apache service to start on boot by running the command below.

sudo systemctl enable httpd

If successful, you should notice a symbolic link is created as shown on the command output below.

[[email protected] ~]$ sudo systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

Congratulations you have successfully configured the Apache Webserver.

Step 4 : Other useful commands for Apache

To check the Apache Status run the command below.

sudo systemctl status httpd

The command output

[[email protected] ~]$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>
  Drop-In: /usr/lib/systemd/system/httpd.service.d
           └─php-fpm.conf
   Active: active (running) since Thu 2021-09-23 14:57:00 EAT; 9min ago
     Docs: man:httpd.service(8)
 Main PID: 15983 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 48892)
   Memory: 38.7M
   CGroup: /system.slice/httpd.service
           ├─15983 /usr/sbin/httpd -DFOREGROUND
           ├─15990 /usr/sbin/httpd -DFOREGROUND
           ├─15991 /usr/sbin/httpd -DFOREGROUND
           ├─15992 /usr/sbin/httpd -DFOREGROUND
           └─15993 /usr/sbin/httpd -DFOREGROUND

Sep 23 14:57:00 rocky-linux systemd[1]: Starting The Apache HTTP Server...

From the screenshot, our Apache server is loaded, active, and running.

To stop Apache, run the command below.

sudo systemctl stop httpd

Conclusion.

That sums up our article on “How to install Apache in Rocky Linux 8”. We hope the article was helpful to you. Feel free to write a comment below. Keep checking for more articles. Thank you.

How to use find command in Linux

0

The Linux find command is a useful tool for searching through your system. It is used to find files and directories and perform successive operations on them.

The find command is used to search for files in a directory hierarchy based on their type, date, permissions, ownership, size, and many more. It can be used alongside other Linux utilities such as grep and sed.

In this article, we will show you how to use the find command in your Linux system.

find command syntax

The general command syntax is as shown below.

find [options] [path...] [expression]

Description

find – searches the directory tree by evaluating the given expression from left to right.

The options – control the treatment of symbolic links. These options control the behavior of find but are specified immediately after the last pathname.

The path… – defines the starting directory or directories where find will search the files.

The expression attribute is made up of options, search patterns, and actions separated by operators.

To search through a file or a directory the user invoking the find command must have read permissions to that file or directory.

We will now look at how to use the find command in Linux

1.Find files by name.

This is the common way of using the find command. To find a file by its name, employ -name option followed by the name of the file being searched for.

To search for a file named “Businessregistration.pdf” in the My Documents folder.

find /home/Jil/Documents/ -type f -name Businessregistration.pdf

The command execution is as shown below.

[[email protected] ~]$ find /home/Jil/Documents/ -type f -name Businessregistration.pdf
/home/Jil/Documents/Businessregistration.pdf

To search for a case sensitive file replace the -name option with -iname as shown

find /home/Jil/Documents/ -type f -iname Businessregistration.pdf

The command output is as shown below.

[[email protected] ~]$ find /home/Jil/Documents/ -type f -iname Businessregistration.pdf
/home/Jil/Documents/Businessregistration.pdf
/home/Jil/Documents/BUSINESSREGISTRATION.pdf

Notice the output above matches all the files with “Businessregistration.pdf” and “BUSINESSREGISTRATION.pdf”

2. Find files by type.

To search for specific file types, e.g symbolic links, directories, or regular files employ -type option followed by descriptors.

Descriptors define the file type. They include the following:-

  • b: for block devices.
  • c: for character devices.
  • d: for directory.
  • f: for regular file.
  • l: for symbolic link
  • p: for named pipe
  • s: for socket

To find all the directories located in /home/Jil/Documents, execute the command :

find /home/Jil/Documents -type d

The command output looks something like this.

[[email protected] ~]$ find /home/Jil/Documents/ -type d
/home/Jil/Documents/
/home/Jil/Documents/sao tome
/home/Jil/Documents/Philip-published-articles-monthly - Google Drive_files

3. Find files by size.

To find files by size, we employ the -size option followed by the size criteria. Use the following suffixes to specify the file size.

  • b: for 512-byte blocks (this is the default if no suffix is used).
  • c: for bytes
  • W: for two-bytes words
  • K: kilobytes
  • M: for megabytes
  • G: for gigabytes

To find all files greater than 1 Megabyte in /home/Jil/Documents , run the command below.

find /home/Jil/Documents/ -type f -size +1M

The output is as below.

[[email protected] ~]$ find /home/Jil/Documents/ -type f -size +1M
/home/Jil/Documents/sarah passport application.pdf
/home/Jil/Documents/muchiri passport application.pdf
/home/Jil/Documents/receipt - muchiri passport application.pdf
/home/Jil/Documents/George Invoice .pdf
/home/Jil/Documents/receipt - benard .pdf
/home/Jil/Documents/sao tome/INTERIM RETURNS COPY .pdf
/home/Jil/Documents/Philip-published-articles-monthly - Google Drive_files/2947586374-waffle_k_ltr.css

To search for files less than 1 Megabyte in the /home/Jil/Documents run the command below.

find /home/Jil/Documents/ -type f -size -1M

4. Find Files by their permissions.

To search for files by their permissions, we use the -perm option.

find /var/www/html/ -perm 644

This gives the output below.

[[email protected] ~]$ find /var/www/html/ -perm 644
/var/www/html/info.php

The numeric mode can be prefixed with either minus (-) or slash (/)

When the prefix is a / then at least one category (user, group or others ) must have at least the respective bits set for a file to match.

Example to demonstrate the use of /

find . -perm /444

The command above will match all the files with read permissions set for either user, group, or others.

When the prefix is a , for the file to match, at least the specified bits must be set.

Example to demonstrate the use of –

find . -perm -664

The command above will search for files with read and write permissions for owner and group and are readable by others.

5. Find Files by Owner.

To search for files owned by a given user or group, use the -user and -group options.

To search for all files and directories owned by user Jil, run the command below.

find / -user Jil

6. Find and delete files

To find and delete all matching files, append -delete option at the end of the match expression. This option must be used with lots of caution and you must be sure of the files to be deleted as once the files are deleted, they cannot be recovered. Ensure you have a backup before deleting the files.

To delete all files ending with .temp in the /var/log/ execute the command below.

find /var/log/ -name `*.temp` -delete

When used on directories, the find command only deletes empty directories same as rmdir.

7. Find files by extension.

Searching for files by extension is the same as searching files by name.

To search for all files with a .gz extension in the /var/log/nginx/ directory, we run the command below.

sudo find /var/log/nginx -type f -name '*.gz'

The output is as shown below.

[[email protected] ~]$ sudo find /var/log/nginx -type f -name '*.gz'
/var/log/nginx/access.log-20210910.gz
/var/log/nginx/error.log-20210910.gz

Note that you must either quote the pattern or escape the asterisk * symbol with backslash \ so that it doesn’t get interpreted by the shell when you use the wildcard character.

To find files that don’t end in a given expression, i.e files that don’t match an expression, use -not option.

sudo find /var/log/nginx -type f -not -name '*.gz'

The command output.

[[email protected] ~]$ sudo find /var/log/nginx -type f -not -name '*.gz'
/var/log/nginx/access.log
/var/log/nginx/error.log

Conclusion.

That sums up our article on How to use find command in Linux. For more information be sure to check man pages. We are glad you have followed along. We trust the article will be helpful as you practice. For individuals preparing for LPIC 1 certification, this article will be very helpful to you. Thank you.

Formatting and Creating Filesystems in Linux.

1

This article targets individuals preparing themselves to sit for LPIC 1 examinations. This is a key area and fully understanding it will make your LPIC 1 exam worthwhile.

A Filesystem refers to methods and data structures that operating systems use to keep track of files and directories on a disk or a given partition.

Filesystems thus manage data stored in the storage devices. A filesystem maintains a map to locate each file placed in the storage device and shows you how to locate the files and directories contained within it.

Linux filesystem uses a virtual directory structure that contains file paths from all the storage devices installed on the system consolidated into a single directory structure.

In this article, we will narrow down to Formatting filesystems as well as creating them.

Formatting Filesystems.

In this section, we will look at various formatting filesystems that you can choose from. We will not go into much detail but will try and give what is important.

Linux filesystem has the ability to create a filesystem across multiple devices.

Common Formatting Filesystems.

1. btrfs

btrfs supports up to 16 exbibytes ( 1 exbibytes = 1024 pepibytes ) in size and a total file system size of 16 exbibytes.

btrfs performs its own form of RAID as well as LVM and subvolumes.

btrfs filesystem is used to perform several whole filesystem tasks like resizing, space statistics, label setting, and defragmentation.

2. ecryptfs

Enterprise Cryptographic Filesystem (ecryptfs) applies Portable Operating System Interface (POSIX) which is a compliant encryption protocol to data before storing it on the device.

This provides a layer of protection for data stored on the device

ecryptfs is a cryptographic stacked Linux filesystem that can be mounted on any directory and on top of the main filesystem.

3. ext3

This is also referred to as ext3fs

ext3 supports files up to 2 tebibytes (TiB) with a total filesystem of 16 TiB.

ext3 supports journalling, faster startup, and recovery. Journalling is the ability to keep a journal or logs of the changes made to the filesystem.

4. ext4

This is also called ext4fs.

It is the default current Linux Filesystem.

ext4 support files up to 16 EiB with a total filesystem size of 1 EiB.

Like ext3, ext4fs supports journalling.

5. ReiserFS

This filesystem was created before ext3fs.

its commonly used on old Linux systems and is no longer supported.

ReiserFS provides features found in both ext3 and ext4 filesystems.

6. Swap

Swap filesystem allows you to create a virtual memory for your system using space on a physical storage drive. Once created the system can swap data out of normal memory into the swap space thereby providing a method of adding memory to your system.

With the brief overview of the formatting filesystem methods above, we now look at how to create filesystems.

Creating Filesystems

To create a Filesystem use the mkfs command.

The command syntax is as below:

mkfs [options] [-t type fs-options] device [size]

The command options include :

OptionExplanation
-t, –type typeSpecify the type of filesystem to create. If not specified ext4 will be created by default.
fs-optionsThis represents the specific filesystems options passed to mkfs command.
-V, –verboseProduces a verbose output that shows what is happening during the creation of a filesystem.
-V, –versionDisplays version information then exits
-h, –helpDisplay help and exit.

Let’s practically create an ext4 filesystem on a USB.

Step 1 : List all your drives.

To list all your drives in your system, execute the command below.

df -h

The command output.

List-your-Drives

My USB disk is the one marked /dev/sdb1 yours may have a different format.

Step 2 : Un-mounting the USB drive’s partition

Unmounting a device is necessary before formatting it.

To unmount /dev/sdb1 run the command below.

sudo umount /dev/sdb1

Note: The command is umount and NOT unmount.

Step 3 : Erase all the data on your USB drive.

Ensure that your data is backed up prior to following these steps.

To erase your data run the following command.

sudo dd if=/dev/zero of=/dev/sdb1 bs=2M count=2

The command output.

Erase-data-on-your-USB-Drive

Step 4 : Create a new partition table.

This is achieved by issuing the following command.

sudo fdisk /dev/sdb1

The output is as shown in the screenshot.

Create-Partition-Table

Press enter then choose the option ‘o’ for creating an empty partition table as in the screenshot below.

Create-a-new-disklabel

Enter ‘n’ to create a new partition, then ‘p’ to create a primary partition, and finally ‘w’ to write the table and exit.

see the screenshot below.

create-primary-partition

Step 5: View partitions.

To view partitions run the command below.

lsblk

The command output

lsblk-command-to-view-partitions

Step 6 : Format the new volume created.

Our newly created volume is partition sdb1.

To format our new volume using the ext4 filesystem, run the following command.

sudo mkfs -t ext4 /dev/sdb1

The command output.

Format-Drive-With-ext4-Filesystem

Step 7 : Verify your filesystem.

To verify the filesystem, execute this command.

sudo file -sL /dev/sdb1

The command output.

Verify-Filesystem

Step 8 : Eject your drive.

Lastly, eject your USB by running the command below.

sudo eject /dev/sdb1

Conclusion:

The steps explained above describes how to Format and Create a Filesystem. We hope that the article was helpful to you. Please feel free to leave a comment below.

In the next article, we will look at partitioning tools and carry an example to demonstrate their usage. Thank you.