Installing Apache on CentOS 6 or 7

Installing Apache

Step 1: Install Apache 2 if you haven’t already done so.

yum -y install httpd

Step 2: Verify the installation

httpd -v

Messages similar to the following display to confirm the installation was successful:

Server version: Apache/2.2.15 (Unix)
Server built: Oct 16 2014 14:48:21

Step 3: Open Port in Firewall

Finally open firewall ports for http (80) and https (443) services using following command.

Centos 7:

# firewall-cmd –permanent –zone=public –add-service=http

# firewall-cmd –permanent –zone=public –add-service=https


# firewall-cmd –permanent –add-port=80/tcp

# firewall-cmd –permanent –add-port=443/tcp

Reload the firewall:

# firewall-cmd –reload

Retart Apache:

# systemctl start httpd

Apache starts at boot:

# systemctl enable httpd

To check the status of Apache:

# systemctl status httpd

To stop Apache:

# systemctl stop httpd