• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Apache on CentOS 8

Written by Admin, Updated On December 29, 2019
apache, centos
How to Install Apache on CentOS 8

Apache HTTP server is one of the most popular web servers in the world. It’s free and open-source cross-platform web server software developed and maintained by Apache Software Foundation. Apache is a easy to learn and configure that providing an ability to host websites mainly via HTTP or HTTPS protocols. In RHEL based distribution Apache webserver is know under name httpd. In this article, we’ll explain how to install and manage the Apache webserver on CentOS 8.

Install Apache on CentOS 8#

CentOS default repositories includes Apache package and it’s installation is very straight forward.

To install the Apache run the following command as root or user with sudo privileges:

sudo yum install httpd

Enable and start the Apache server once the installation has been finished:

sudo systemctl enable httpd
sudo systemctl start httpd

Verify the service is running by checking status:

sudo systemctl status httpd

It should look something like below:

● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
     Active: active (running) since Fri 2019-12-29 13:57:28 UTC; 28s ago
     …

Adjust Firewall#

At the time of installation, Apache creates firewalld service files with predefined rules for allowing access to HTTP (80) and HTTPS (443) ports.

If your firewall enabled then you have to open http and https ports. Use below commands to open 80 and 443 ports:

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

Testing Apache Installation#

Finally you installed Apache and adjusted firewall so you can check version of Apache service by type:

sudo httpd -v
Server version: Apache/2.4.37 (CentOS)
Server built:   Jul 30 2019 19:56:12

Afterwards, you can do final testing to know everything is working proper, open browser and browse with your server public ip address. It should show a CentOS Apache default page as below:

http://YOUR_SERVER_IP
CentOS 8 Apache Default Page

Manage Apache Configuration#

Following information shows that how Apache configuration files are structured and managing the Apache web server.

  • The /etc/httpd directory is the default location for the all Apache configuration files.
  • The main Apache configuration file is /etc/httpd/conf/httpd.conf
  • All the files located at /etc/httpd/conf.d directory and ending with .conf are included by default in main Apache configuration file.
  • Various Apache modules configuration files are located in the /etc/httpd/conf.modules.d directory.
  • Apache vhost files must end with .conf and be stored in /etc/httpd/conf.d directory. You can have as many vhosts as you need. Creating a separate configuration file (vhost) for each domain makes the server easier to maintain.
  • Apache vhost files must end with .conf and be stored in /etc/httpd/conf.d directory. You can have as many vhosts as you need. Creating a separate configuration file (vhost) for each domain makes the server easier to maintain.
  • It is good practice to follow naming standard for the configuration files. For example, if the domain name is tecnstuff.net then the configuration file should be named tecnstuff.net.conf
  • The /var/log/httpd/ directory contains the Apache log files (access_log and error_log). It’s also advised to have a different access and error log files for each vhost.
  • You can set any directory as your document root directory. Following are the common and mostly used locations for the webroot:
    • /var/www/html/yourdomain.com
    • /var/www/yourdomain.com
    • /home/username/yourdomain.com

Conclusion#

You have successfully installed Apache on your CentOS 8 server. You can now configure your virtual hosts and can deploy your applications.

If you have any trouble in installing and configuring Apache, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to use Grep Command in Linux
Next Article   How to Install MySQL on CentOS 8

Related Posts

  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04

    How to Set Up Apache Virtual Hosts on Ubuntu 22.04

    March 2, 2023
  • How to Install GCC Compiler on Debian 11

    How to Install GCC Compiler on Debian 11

    December 11, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook