Atlantic.Net Blog

How to Install and Configure Apache Webserver on Oracle Linux 8

Hitesh Jethva
by Atlantic.Net (414 posts) under Tutorials, VPS Hosting
0 Comments

Free, open-source Apache is one of the most popular web servers on the internet. It was developed and maintained by the Apache Software Foundation. Apache is reliable, secure, fast, and can be customized using extensions and modules. Due to its stability, efficiency, and popularity, it is used by many web hosting companies worldwide. It supports all major operating systems including Linux, Windows, macOS, Solaris, and more.

In this post, we will explain how to install an Apache web server on Oracle Linux 8.

Prerequisites

  • A server running Oracle Linux 8 on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Oracle Linux 8 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install Apache on Oracle Linux 8

By default, the latest version of Apache is available in the Oracle Linux default repository. You can install it by running the following command:

dnf install httpd -y

Once the Apache package is installed, verify the package information using the following command:

apachectl -V

You will get the following output:

Server version: Apache/2.4.37 (Oracle Linux)
Server built:   May 11 2022 05:39:03
Server's Module Magic Number: 20120211:83
Server loaded:  APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

Step 3 – Manage Apache Service

By default, the Apache webserver service is managed by systemd. You can manage it easily using the systemctl command-line utility.

To start the Apache service, run the following command:

systemctl start httpd

To restart the Apache service, run the following command:

systemctl restart httpd

To enable the Apache service, run the following command:

systemctl enable httpd

To check the status of the Apache service, run the following command:

systemctl status httpd

You will get the following output:

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2022-06-08 11:41:51 EDT; 25min ago
     Docs: man:httpd.service(8)
 Main PID: 3745 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 23694)
   Memory: 25.2M
   CGroup: /system.slice/httpd.service
           ├─3745 /usr/sbin/httpd -DFOREGROUND
           ├─3760 /usr/sbin/httpd -DFOREGROUND
           ├─3765 /usr/sbin/httpd -DFOREGROUND
           ├─3766 /usr/sbin/httpd -DFOREGROUND
           └─3767 /usr/sbin/httpd -DFOREGROUND

Jun 08 11:41:51 oraclelinux8 systemd[1]: Starting The Apache HTTP Server...

Step 4 – Configure Firewall

By default, Apache listens on ports 80 and 443. If a firewall is installed and configured to your server, then you will need to allow both ports via firewalld. You can allow them with the following command:

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

Next, reload the firewalld to apply the changes:

firewall-cmd --reload

Step 5 – Access Apache Default Web Page

At this point, the Apache web server is installed and listens on port 80. You can now open your web browser and access the Apache test page using the URL http://your-server-ip. You should see the Apache default page on the following screen:
Apache test page

Step 6 – Host a Simple Website with Apache

First, create a directory to hold the website data with the following command:

mkdir /var/www/html/web.example.com

Next, create a simple HTML file inside the website directory:

nano /var/www/html/web.example.com/index.html

Add the following HTML code:

<html>
<h1>Welcome to the Apache Webserver!</h1>
</html>

Save and close the file, then change the ownership and permissions of the website directory:

chown -R apache:apache /var/www/html/web.example.com/
chmod -R 775 /var/www/html/web.example.com/

Next, create an Apache virtual host configuration file to define your website directory:

nano /etc/httpd/conf/example.conf

Add the following configuration:

<VirtualHost *:80>
    ServerAdmin web.example.com
    DocumentRoot /var/www/html/web.example.com
    DirectoryIndex index.html
    ErrorLog /var/log/httpd/error.log
    CustomLog /var/log/httpd/access.log combined
</VirtualHost>

Save and close the file, then restart the Apache service to apply the configuration changes:

systemctl restart httpd

Now, open your web browser and verify your website using the URL http://web.example.com. You should see your website page on the following screen:
Apache test page

Conclusion

In the above post, we explained how to install an Apache webserver on Oracle Linux 8. We also explained how to create a new website and host it using the Apache virtual host. Try it on VPS hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Top 10 Best Cybersecurity Training Services
How to Install Ansible on Oracle Linux 8
How to Install LEMP Server on Oracle Linux 8
How to Install and Configure Apache Webserver on Oracle Linux 8
How to Install and Configure Nginx Webserver on Oracle Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Dallas, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources