How to Install Apache Web Server on CentOS 7
Apache is a cross-platform, open-source web server that is one of the most widely used. It’s fairly simple to set up and configure to host one or more websites. The Apache Web server is available for use on UNIX, Linux, and Windows systems.
This tutorial will show you how to use command line to install, configure, and operate the Apache HTTP web server on a CentOS 7 server.
Prerequisites:
- A user account with sudo privileges
- A server (or two) with CentOS 7 installed
- Patience
Installing Apache Web Server on CentOS
Step 1: Update Software Version
— Update the system software packages to the latest version using command:
sudo yum update
Step 2: Install Apache HTTP server
— This command will install Apache from the software repositories
sudo yum install httpd
Step 3: Start Apache
— Once the install has complete, you will be able to start, enable, and check the status of Apache using these command lines:
systemctl start httpd
systemctl enable httpd
systemctl status httpd
Step 4: Install Firewalld
— This command will install firewalld from the software repositories
sudo yum install firewalld
— Once the install has complete, you will be able to start, enable, and check the status of Firewalls using these command lines:
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo systemctl status firewalld
Step 5: Configure Firewall to Allow Web Traffic
— CentOS 7’s built-in firewall is configured to restrict Apache traffic by default, which blocks HTTP (port 80) and HTTPS (port 443). To update this setting to allow the “three-way handshake” to occur, you’ll need to run these command lines:
sudo firewall-cmd --zone=public --permanent --add-service=http
sudp firewall-cmd --zone=public --permanent --add-service=https
To save your firewall changes, use command line:
sudo firewall-cmd --reload
Step 6: Test Apache HTTP Server
— This is how you verify all your hard work is complete. Go to the following URL
http://[insert your service ip address]
You should see the default Apache HTTP server testing page