redhat:web-server-redhat:apache:apache24-on-redhat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
redhat:web-server-redhat:apache:apache24-on-redhat [2020/03/05 13:47] – created michaelredhat:web-server-redhat:apache:apache24-on-redhat [2020/03/05 15:02] (current) – [Additional setup] michael
Line 1: Line 1:
-<WRAP center box 100%> +====== How to Install Apache on CentOS 8 ======
-==== Installation von Apache 2.4 mit HTTP/2 und PHP 7.2 ====+
  
-<code> +Apache HTTP server is the most widely used web server in the worldIt is a free, open-source, and cross-platform HTTP server, including powerful features, and can be extended by a wide variety of modules.
-# curl -sSL https://www.blackgate.org/deployment/base_configuration_blackGATE.sh | bash cd /etc/yum.repos.d && wget https://repo.codeit.guru/codeit.el`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo +
-# yum -y install https://mirror.webtatic.com/yum/el7/webtatic-release.rpm+
  
-# yum update +{{:redhat:web-server-redhat:apache:install_apache24_centos.jpg?nolink&400|}}
-# yum install httpd php72w-fpm php72w-cli php72w-common php72w-gd php72w-intl php72w-mbstring php72w-mysql php72w-pecl-geoip php72w-pecl-imagick php72w-process php72w-xml+
  
-# mkdir /var/lib/php/session 
-# chown -R apache:apache /var/lib/php 
  
-# firewall-cmd --permanent --zone=public --add-service=http +===== Installation Tutorial =====
-# firewall-cmd --reload +
-</code>+
  
-<code> +In this tutorial, I explain how to install and manage the Apache webserver on CentOS 8.
-# vim /etc/php-fpm.d/www.conf +
-</code>+
  
-<code> 
-# vim /etc/httpd/conf.d/php.conf 
-</code> 
  
-<code+<WRAP center box 100%
-# systemctl start httpd php-fpm +==== Installing Apache ====
-# systemctl enable httpd php-fp +
-</code>+
  
-<code> +Apache is available in the default CentOS repositories, and the installation is pretty straight forward.
-# vim /var/www/html/info.php +
-</code>+
  
-----+On RHEL based distributions, the Apache package and service are called httpd. To install the Apache run the following command as root or user with sudo privileges:
  
-<WRAP center round alert 60%> +<code># yum install httpd</code> 
-''<wrap em>From here down, is Depricatet!</wrap>''+ 
 +Once the installation is completeenable and start the Apache service: 
 + 
 +<code># systemctl enable httpd --now</code> 
 + 
 +To verify that the service is running, check its status: 
 + 
 +<code># systemctl status httpd</code> 
 + 
 +<sxh bash; gutter: false;> 
 +● httpd.service - The Apache HTTP Server 
 +   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) 
 +   Active: active (running) since Sat 2019-10-12 15:54:58 UTC; 6s ago 
 +  ... 
 +</sxh>
 </WRAP> </WRAP>
  
  
-Apache 2.4 ist bei **Redhat** sowie **CentOS** in den offiziellen Paket quellen **//NUR//** in **Version 2.2** enthalten. Um also die neuste Version Apache 2.4 zu installieren, muss zuerst, dass **''[[redhat:base-redhat:repositories-redhat|Epel Repository]]''** angehängt werden. Das Paket kann anschliessend mittels folgenden Befehl installiert werden:+<WRAP center box 100%> 
 +==== Adjusting the Firewall ====
  
-<code> +FirewallD is the default firewall solution on Centos 8.
-# yum install httpd +
-# rm -f /etc/httpd/conf.d/welcome.conf   +
-</code>+
  
-<WRAP center round important 100%> +During the installation, Apache creates firewalld service files with predefined rules for allowing access to ''HTTP (80)'' and ''HTTPS (443)'' ports. 
-''<wrap em>Achtung!</wrap> Falls später, **[[redhat:web-server-redhat:php-redhat|php-fpm]]** konfiguriert werden soll, muss hier der **httpd24-httpd Webserver** //aus der Software Collection// anstelle des oberen installiert werden! Dazu installiert man wie unten beschrieben das Repo und färht anschliessend **[[redhat:web-server-redhat:php-redhat|HIER]]** weiter.''+ 
 +The following commands will permanently open the necessary ports: 
 + 
 +<code># firewall-cmd --permanent --zone=public --add-service=http 
 +# firewall-cmd --permanent --zone=public --add-service=https 
 +# firewall-cmd --reload</code>
  
-<code> 
-Install the SCL repository for your system: 
-# yum install centos-release-scl 
-# yum update 
-</code> 
 </WRAP> </WRAP>
  
 +
 +<WRAP center box 100%>
 +==== Managing Apache ====
 +
 +This section explains how the Apache configuration files are structured and the best practices for managing the Apache webserver.
 +
 +  * All Apache configuration files are located in the ''/etc/httpd'' directory.
 +  * The main Apache configuration file is ''/etc/httpd/conf/httpd.conf''.
 +  * Configuration files ending with ''.conf'' located in the ''/etc/httpd/conf.d'' directory are included in main Apache configuration file.
 +  * Configuration files that are responsible for loading various Apache modules 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.
 +    * It is a good practice to follow a standard naming convention. For example, if the domain name is mydomain.com then the configuration file should be named mydomain.com.conf
 +  * Apache log files (''access_log'' and ''error_log'') are located in the ''/var/log/httpd/'' directory. It is recommended to have a different ''access'' and ''error'' log files for each vhost.
 +  * You can set your domain document root directory to any location you want. The most common locations for webroot include:
 +    * ''/home/<user_name>/<site_name>''
 +    * ''/var/www/<site_name>''
 +    * ''/var/www/html/<site_name>''
 +    * ''/opt/<site_name>''
 </WRAP> </WRAP>
  
----- 
  
 <WRAP center box 100%> <WRAP center box 100%>
-==== Grund Konfiguration ==== +==== Basic configuration ==== 
-Im folgendenwird der Apache Webserver erst einmal grundlegend konfiguriertDazuwird die ''httpd.conf'' editiert und folgende Änderungen durchgeführt.+In the followingthe Apache web server will be configured in a basic wayTo do thisedit the ''httpd.conf'' and make the following changes.
  
 <code> <code>
Line 70: Line 82:
  
 <sxh bash; first-line: 1> <sxh bash; first-line: 1>
-Zeile 86: setzen der Server-Admin Email Adresse +line 86: set the server admin email address 
-ServerAdmin root@blackgate.org+ServerAdmin root@michu-it.com
  
-Zeile 95: festlegen des Server-Namen +Line 95: set the server name 
-ServerName www.blackgate.org+ServerName www.michu-it.com
  
-Zeile 151: 'none' auf 'All' wechseln+Line 151: Change 'none' to 'All'
 AllowOverride All AllowOverride All
  
-Zeile 164Hinzufügen der üblich gebrauchen DirectoriyIndexen (Wichtig php & html) +The following is entered at the end of the configuration and serves as a hardening purpose:
-DirectoryIndex index.html index.php index.cgi  +
- +
-#Folgendes wird dann noch am Schluss der Konfiguration eingetragen: +
 ServerTokens Prod ServerTokens Prod
 KeepAlive On KeepAlive On
 </sxh> </sxh>
  
-Nun kann der Webserver auch bereits schon gestartet werden:+After each configuration change the apache.service must be reloaded or restarted:
 <code> <code>
-# systemctl start httpd  +# systemctl restart httpd
-# systemctl enable httpd+
 </code>  </code> 
- 
-''**Falls nun auch [[redhat:firewalld-redhat|Firewalld]] aktiv ist**'', müssen noch die Ports für den Webserver freigeschalten werden. Dies wird folgendermassen gemacht: 
- 
-<code> 
-# firewall-cmd --add-service=http --permanent 
-# firewall-cmd --add-service=https --permanent  
- 
-# firewall-cmd --reload  
-</code> 
 </WRAP> </WRAP>
  
Line 108: Line 106:
  
 <WRAP center box 100%> <WRAP center box 100%>
-==== Testseite erstellen ==== +==== Create test page ==== 
-Zum testen, des Apache Webserverskann nun ganz einfach und schnell eine kleine htlm-Datei wie folgt erstellt werden:+To test the Apache web servera small htlm file can now be created quickly and easily as follows:
  
 <code> <code>
Line 120: Line 118:
     <body>     <body>
         <div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">         <div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
-        Test Page+        Test Page - Under Construction.
         </div>         </div>
     </body>     </body>
Line 127: Line 125:
 {{ :redhat:web-server-redhat:html_page.png |}} {{ :redhat:web-server-redhat:html_page.png |}}
 </WRAP> </WRAP>
 +
 +
 +===== Additional setup =====
 +
 +Further documentation can be found under the individual links
 +
 +  * [[redhat:web-server-redhat:apache:letsencrypt-redhat|Secure Apache with Let's Encrypt on CentOS 8]]
 +  * [[redhat:proxy-server-redhat:reverseproxy-redhat|Apache 2.4 als Reverse Proxy Konfigurieren]]
 +  * [[redhat:web-server-redhat:virtual-hosts-redhat|Configure a virtual host directives for your domain in apache.]]
 +  * 
 +
 +
 +
  • redhat/web-server-redhat/apache/apache24-on-redhat.1583412449.txt.gz
  • Last modified: 2020/03/05 13:47
  • by michael