top of page
BlogPageTop

How to Install Apache HTTP Server on CentOS



yum install httpd

Apache is most popular HTTP Server which runs on Linux & Windows based operating system. Let's see how to install and configure Apache HTTP Web Server on CentOS.


 

1. First update yum package

sudo yum -y update


2. Next, install Apache HTTP server

sudo yum install httpd


3. Start & Enable HTTP server (to start automatically on server reboot)

[centos@ ~]$ sudo systemctl start httpd [centos@ ~]$ sudo systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.


 

4. Now check the status of Apache server

[centos@ ~]$ sudo systemctl status httpd

httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Thu 2018-08-02 18:32:00 UTC; 6min ago Docs: man:httpd(8) man:apachectl(8) Main PID: 10235 (code=exited, status=0/SUCCESS) Aug 02 18:32:00 dataneb.com systemd[1]: Starting The Apache HTTP Server... Aug 02 18:32:00 dataneb.com httpd[10235]: httpd (pid 10202) already running Aug 02 18:32:00 dataneb.com kill[10237]: kill: cannot find process "" Aug 02 18:32:00 dataneb.com systemd[1]: httpd.service: control process exited, code=exited status=1 Aug 02 18:32:00 dataneb.com systemd[1]: Failed to start The Apache HTTP Server. Aug 02 18:32:00 dataneb.com systemd[1]: Unit httpd.service entered failed state. Aug 02 18:32:00 dataneb.com systemd[1]: httpd.service failed.


 

5. If server does not start, disable SELinux on CentOS

[centos@]$ cd /etc/selinux [centos@]$ sudo vi config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. # SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted


 

6. Reboot the system to make SELinux changes effective

[centos@ ~]$ sudo reboot debug1: channel 0: free: client-session, nchannels 1 Connection to xx.xxx.xxx.xx closed by remote host. Connection to xx.xxx.xxx.xx closed. Transferred: sent 16532, received 333904 bytes, in 1758.1 seconds Bytes per second: sent 9.4, received 189.9 debug1: Exit status -1


 

7. Now check the status of Apache server again

[centos@ ~]$ sudo systemctl status httpd

httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2018-08-02 18:40:18 UTC; 35s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 855 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─855 /usr/sbin/httpd -DFOREGROUND ├─879 /usr/sbin/httpd -DFOREGROUND ├─880 /usr/sbin/httpd -DFOREGROUND ├─881 /usr/sbin/httpd -DFOREGROUND ├─882 /usr/sbin/httpd -DFOREGROUND └─883 /usr/sbin/httpd -DFOREGROUND Aug 02 18:40:17 dataneb.com systemd[1]: Starting The Apache HTTP Server... Aug 02 18:40:18 dataneb.com systemd[1]: Started The Apache HTTP Server.


 

8. Configure firewalld (CentOS is built by default to block Apache traffic)

[centos@ ~]$ firewall-cmd --zone=public --permanent --add-service=http [centos@ ~]$ firewall-cmd --zone=public --permanent --add-service=https [centos@ ~]$ firewall-cmd --reload


 

9. Test your url by entering Apache server ip address in your local browser


Thank you!! If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Google or Facebook. Refer the links below.


Also click on "Subscribe" button on top right corner to stay updated with latest posts. Your opinion matters a lot please comment if you have any suggestion for me.


 

Learn Apache Spark in 7 days, start today!


 

Comentarios


Want to share your thoughts about this blog?

Disclaimer: Please note that the information provided on this website is for general informational purposes only and should not be taken as legal advice. Dataneb is a platform for individuals to share their personal experiences with visa and immigration processes, and their views and opinions may not necessarily reflect those of the website owners or administrators. 

 

While we strive to keep the information up-to-date and accurate, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability, or availability with respect to the website or the information, products, services, or related graphics contained on the website for any purpose. Any reliance you place on such information is therefore strictly at your own risk. 

 

We strongly advise that you consult with a qualified immigration attorney or official government agencies for any specific questions or concerns related to your individual situation. We are not responsible for any losses, damages, or legal disputes arising from the use of information provided on this website. 

 

By using this website, you acknowledge and agree to the above disclaimer and Google's Terms of Use and Privacy Policy.

bottom of page