v1.0.0

Apache

# Install Apache

Upgrade system

sudo dnf upgrade --refresh -y

Install httpd service

sudo dnf install -y httpd

Create folder config for site

sudo mkdir -p /etc/httpd/sites-available /etc/httpd/sites-enabled

Set Server name and include config folder

sudo nano /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
IncludeOptional sites-enabled/*.conf

Check Apache config

sudo apachectl configtest

Enable and start httpd service

sudo systemctl enable --now httpd

Add service to Firewall

sudo firewall-cmd --permanent --add-service=http

Reload Firewall service

sudo firewall-cmd --reload

# Config Gzip

Config Gzip

sudo nano /etc/httpd/httpd.conf
# Enable gzip with mod_deflate configuration
<IfModule mod_deflate.c>
    # Restrict compression to these MIME types
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/css

    # Level of compression (Highest 9 - Lowest 1)
    DeflateCompressionLevel 9

    # Netscape 4.x has some problems.
    BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>

# Config Virtual host

Create Virtual host config file

sudo touch /etc/httpd/conf.d/{domain}.conf

Content config file for webroot

<VirtualHost *:80>
    ServerAdmin admin@{domain}
    ServerName www.{domain}
    ServerAlias {domain}

    DocumentRoot "/var/www/{domain}/build"
    <Directory "/var/www/{domain}/build">
        Options Indexes FollowSymLinks
        AllowOverride All
        DirectoryIndex index.html index.php
        Require all granted
    </Directory>

    ErrorLog logs/{domain}-error_log
    CustomLog logs/{domain}-access_log common
</VirtualHost>

Content config file for Proxy pass

<VirtualHost *:80>
    ServerAdmin admin@{domain}
    ServerName {domain}
    ServerAlias www.{domain}

    ProxyPreserveHost On
    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>
    ProxyPass / http://localhost:{port}/
    ProxyPassReverse / http://localhost:{port}/

    ErrorLog logs/{domain}-error_log
    CustomLog logs/{domain}-access_log common
    
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =www.{domain} [OR]
    RewriteCond %{SERVER_NAME} ={domain}
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

Create shortcut

sudo ln -s /etc/httpd/sites-available/{site_name}.conf /etc/httpd/sites-enabled

Check Apache config

sudo apachectl configtest

Restart httpd service

sudo systemctl restart httpd