{"id":3492,"date":"2021-01-15T18:10:05","date_gmt":"2021-01-15T18:10:05","guid":{"rendered":"https:\/\/linuxways.net\/?p=3492"},"modified":"2021-01-15T18:10:08","modified_gmt":"2021-01-15T18:10:08","slug":"how-to-install-apache-web-server-on-centos-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-install-apache-web-server-on-centos-8\/","title":{"rendered":"How to Install Apache Web Server on CentOS 8"},"content":{"rendered":"<p>Apache is installed on most commonly Linux based distributions. You can install Apache as part of the LAMP stack (Linux, Apache, MySQL, and PHP) that provides a robust and powerful platform for the development and deployment of web-based applications.<\/p>\n<p>The HTTP Apache web server is an open-source and free web server that transfers the web content over the internet.<\/p>\n<p>We will give you brief detail in this tutorial on how you can install the Apache web server on the CentOS 8 system by using the terminal.<\/p>\n<h2><strong>Prerequisites<\/strong><\/h2>\n<p>You need a user who has \u2018sudo\u2019 command privileges or a root user.<\/p>\n<h2><strong>Installation of Apache on CentOS 8<\/strong><\/h2>\n<p>You can install apache on CentOS 8 system by using the following steps:<\/p>\n<h3><strong>Step 1: update packages repository<\/strong><\/h3>\n<p>Open the terminal from the sidebar of the \u2018Activities\u2019 section and type the \u2018su\u2019 command to login as a root user. Enter the administrative root password as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1102\" height=\"207\" class=\"wp-image-3493\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-229.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-229.png 1102w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-229-300x56.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-229-1024x192.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-229-768x144.png 768w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/p>\n<p>Type the below-given command in order to update the software repository of all packages list:<\/p>\n<pre>$ yum update<\/pre>\n<h3><strong>Step 2: Install apache<\/strong><\/h3>\n<p>In CentOS 8, you can install Apache service with the name \u2018httpd\u2019. The following command you will type on the terminal to install apache on your CentOS system:<\/p>\n<pre>$ yum \u2013y install httpd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"560\" class=\"wp-image-3494\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-230.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-230.png 801w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-230-300x210.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-230-768x537.png 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/p>\n<p>The option \u2018y\u2019 will automatically ignore the user confirmation prompt and select \u2018yes\u2019 in order to complete the installation of Apache on your system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"794\" height=\"500\" class=\"wp-image-3495\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-231.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-231.png 794w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-231-300x189.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-231-768x484.png 768w\" sizes=\"auto, (max-width: 794px) 100vw, 794px\" \/><\/p>\n<h3><strong>Step 3: Manage Apache services<\/strong><\/h3>\n<p>Apache service runs in the background of your system. To enable or configure the Apache services, run the below-mentioned command:<\/p>\n<pre>$ systemctl enable httpd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"798\" height=\"76\" class=\"wp-image-3496\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-232.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-232.png 798w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-232-300x29.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-232-768x73.png 768w\" sizes=\"auto, (max-width: 798px) 100vw, 798px\" \/><\/p>\n<p>Now, start apache services by typing the below-given command on the terminal and then check the running status of apache services as follows:<\/p>\n<pre>$ systemctl start httpd\n\n$ systemctl status httpd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"797\" height=\"402\" class=\"wp-image-3497\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-233.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-233.png 797w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-233-300x151.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-233-768x387.png 768w\" sizes=\"auto, (max-width: 797px) 100vw, 797px\" \/><\/p>\n<p>Here, we have mentioned some commands to manage apache services that are listed below:<\/p>\n<p>Reload services of apache web server by using the below-given command:<\/p>\n<pre>$ systemctl reload httpd<\/pre>\n<p>To restart services again use the following command:<\/p>\n<pre>$ systemctl restart httpd<\/pre>\n<p>You can also stop apache services on your system by running the below-mentioned command:<\/p>\n<pre>$ systemctl stop httpd<\/pre>\n<p>To disable the apache service use the command as follows:<\/p>\n<pre>$ systemctl disable httpd\n\n<\/pre>\n<h2><strong>Step 4: Adjust firewall configurations for Apache<\/strong><\/h2>\n<p>Different kind of traffic uses different ports on web servers. Using the firewall, you can allow HTTP and HTTPS traffic on ports 80 and 443 respectively.<\/p>\n<p>Enter the below-mentioned commands in the terminal as a root user that will open these ports permanently on your system:<\/p>\n<pre># firewall-cmd --permanent --zone=public --add-service=http<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1098\" height=\"132\" class=\"wp-image-3502\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-238.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-238.png 1098w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-238-300x36.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-238-1024x123.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-238-768x92.png 768w\" sizes=\"auto, (max-width: 1098px) 100vw, 1098px\" \/><\/p>\n<pre># firewall-cmd --permanent --zone=public --add-service=https<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1094\" height=\"86\" class=\"wp-image-3503\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-239.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-239.png 1094w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-239-300x24.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-239-1024x80.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-239-768x60.png 768w\" sizes=\"auto, (max-width: 1094px) 100vw, 1094px\" \/><\/p>\n<p>Reload firewall configurations:<\/p>\n<pre># firewall-cmd \u2013reload<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"947\" height=\"52\" class=\"wp-image-3504\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-240.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-240.png 947w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-240-300x16.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-240-768x42.png 768w\" sizes=\"auto, (max-width: 947px) 100vw, 947px\" \/><\/p>\n<p>To verify the firewall configuration run the below-mentioned command:<\/p>\n<pre># firewall-cmd --list-all | grep services<\/pre>\n<p>As you can see in the following screenshot that HTTP and HTTPS are allowed services in the list.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1086\" height=\"97\" class=\"wp-image-3505\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-241.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-241.png 1086w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-241-300x27.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-241-1024x91.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-241-768x69.png 768w\" sizes=\"auto, (max-width: 1086px) 100vw, 1086px\" \/><\/p>\n<h3><strong>Step 5: Test Apache web server in CentOS 8<\/strong><\/h3>\n<p>When you test apache in the web browser the default apache new installation page will display in the browser. Find your system\u2019s IP address by using the following command:<\/p>\n<pre>$ hostname -I<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"799\" height=\"61\" class=\"wp-image-3498\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-234.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-234.png 799w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-234-300x23.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-234-768x59.png 768w\" sizes=\"auto, (max-width: 799px) 100vw, 799px\" \/><\/p>\n<p>Now, type the IP address in the URL of your installed browser. On this system, we are using the default available browser Mozilla firefox. So, enter your system\u2019s IP address and test the installation of apache. The following Apache HTTP test page will display in the web browser:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1196\" height=\"856\" class=\"wp-image-3499\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-235.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-235.png 1196w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-235-300x215.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-235-1024x733.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-235-768x550.png 768w\" sizes=\"auto, (max-width: 1196px) 100vw, 1196px\" \/><\/p>\n<p>If you are not using a graphical interface then, run the following command:<\/p>\n<pre>$ curl [System-IP-address]:80<\/pre>\n<h2><strong>Create an HTML file and test Apache web server<\/strong><\/h2>\n<p>If you want to use a customize Html page instead of displaying the default test page of the Apache web server then, type the following command in the terminal to create an Html index page:<\/p>\n<pre># echo Installation of Apache web server on CentOS 8 &gt; \/var\/www\/html\/index.html<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1097\" height=\"112\" class=\"wp-image-3500\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-236.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-236.png 1097w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-236-300x31.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-236-1024x105.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-236-768x78.png 768w\" sizes=\"auto, (max-width: 1097px) 100vw, 1097px\" \/><\/p>\n<p>Now, again type your system IP address in the URL of your browser. The following message will print in your browser:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1201\" height=\"471\" class=\"wp-image-3501\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-237.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-237.png 1201w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-237-300x118.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-237-1024x402.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-237-768x301.png 768w\" sizes=\"auto, (max-width: 1201px) 100vw, 1201px\" \/><\/p>\n<p>Congratulations! Apache is working correctly on your CentOS system if it prints the customized HTML page in your browser.<\/p>\n<h2><strong>Remove or Uninstall httpd Apache<\/strong><\/h2>\n<p>You can also remove the httpd apache module with all its dependencies from your system by executing the following command:<\/p>\n<pre># yum remove httpd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1105\" height=\"738\" class=\"wp-image-3506\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-242.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-242.png 1105w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-242-300x200.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-242-1024x684.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-242-768x513.png 768w\" sizes=\"auto, (max-width: 1105px) 100vw, 1105px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Using the Apache web server, you can host web pages over the network. We have demonstrated all steps in detail for the installation of the Apache web server on CentOS 8 distribution. We have also created a customized HTML page and test in the browser. After performing the above procedure, the Apache web server should work properly on your system.<\/p>","protected":false},"excerpt":{"rendered":"<p>Apache is installed on most commonly Linux based distributions. You can install Apache as part of the LAMP stack (Linux, Apache, MySQL, and PHP) that provides a robust&hellip;<\/p>","protected":false},"author":2,"featured_media":3507,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[52,93],"class_list":["post-3492","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-apache-web-server","tag-centos-8"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/3492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=3492"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/3492\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/3507"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=3492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=3492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=3492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}