GoAdmio

apache

Switch the server from Nginx to Apache, or rebuild a domain's Apache virtual host

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

/go/apache has two modes, chosen by whether you pass a domain:

[!WARNING] Running /go/apache with no argument reboots the server when it finishes, and sites are unavailable while it runs. Do it in a maintenance window, and only on a server that is running Nginx.


Quick start

# Rebuild the Apache virtual host for one domain
/go/apache example.com

Syntax

/go/apache                # switch the server from Nginx to Apache
/go/apache <domain>       # rebuild one domain's Apache virtual host

The command has no -- options. Run it as root. Only the first argument is read.


Arguments

Argument Mode What it does
(none) Switch mode Converts the server to Apache and reboots it.
<domain> Domain mode Writes the Apache configuration files for that domain.

Output

Message Meaning
Switching from NGINX to Apache... Switch mode has started.
APACHE: Domain Directory /home/<username> not exists. Domain mode stopped. /home/<domain> does not exist. The message shows the account username, which is empty if the domain is not hosted. Exit status 1.

Domain mode prints nothing when it works. Switch mode ends with a reboot and exit status 1.


Examples

# Rebuild one domain's Apache configuration
/go/apache example.com
# Apply the new configuration
/go/reload
# Check the generated files (AlmaLinux, Rocky, CentOS, Red Hat, Fedora)
ls /etc/httpd/vhost/example.com*
# Check the generated files (Debian, Ubuntu)
ls /etc/apache2/vhost/example.com*
# Review the log of past runs
tail -n 20 /var/log/go/apache.log

Troubleshooting

Symptom Likely cause Fix
The server rebooted /go/apache was run with no argument. Expected. Pass a domain to rebuild a single site.
A rebuilt domain does not change Domain mode writes the files but does not reload Apache. Run reload or web.
APACHE: Domain Directory /home/ not exists. The domain is misspelled or not hosted. Check the name with ls /home.
The files exist but nothing uses them The server runs Nginx. Use nginx for Nginx servers, or switch with /go/apache.
No HTTPS configuration was written No certificate was found. See SSL files. Install one with ssl, then run the command again.
An old -le-ssl.conf is still present after a certificate was removed When no certificate is found, the SSL file is left as it was. Delete the file by hand and reload.
The site is on the wrong PHP version The version comes from the site's settings, or the newest installed version if none is set. Change it with multiphp, then run the command again.
Long PHP requests fail with a gateway timeout The PHP-FPM proxy timeout is 30 seconds by default. Put a different number of seconds in /var/go/etc/timeout, then rebuild.
Some visitors get 403 Forbidden Bad-bot blocking is on for the site and their user agent matched. See Bad-bot blocking.

Details

Switch mode

Switch mode runs these steps in order:

# Step
1 Print Switching from NGINX to Apache....
2 Delete the *-le-ssl.conf files in /etc/httpd/vhost/, and run /go/removessl.
3 Delete all rows from the Control table in GoAdmio's control database.
4 Record Apache as the web server, and run installssl.
5 Disable and stop nginx, then enable and start httpd (AlmaLinux, Rocky, CentOS, Red Hat, Fedora) or apache2 (Debian, Ubuntu).
6 Run /go/conf --force to rebuild all configuration. See conf.
7 Run /go/reboot.

The service and web-server changes in steps 4 and 5 happen only on the supported operating systems above.

Domain mode

Domain mode needs /home/<domain> to exist. It reads the domain's settings from GoAdmio's databases and writes two files.

OS HTTP file HTTPS file
AlmaLinux, Rocky, CentOS, Red Hat, Fedora /etc/httpd/vhost/<domain>.conf /etc/httpd/vhost/<domain>-le-ssl.conf
Debian, Ubuntu /etc/apache2/vhost/<domain>.conf /etc/apache2/vhost/<domain>-le-ssl.conf

The files are rewritten from scratch each time. Changes you make to them by hand are lost. The command writes the files only. It does not reload Apache.

Virtual hosts written

File Port Serves Document root
HTTP file 80 <domain>, www.<domain>, and every alias domain The site's folder
HTTP file 80 go.<domain> /usr/local/goadmio/home/go
HTTP file 80 webmail.<domain> /usr/local/goadmio/home/go/webmail
HTTPS file 443 <domain>, www.<domain>, and every alias domain The site's folder
HTTPS file 443 go.<domain> /usr/local/goadmio/home/go
HTTPS file 2021, 2083, 2087 <domain>, www.<domain> /usr/local/goadmio/home/go
HTTPS file 2080 <domain>, www.<domain> /usr/local/goadmio/home/firewall
HTTPS file 443 webmail.<domain> /usr/local/goadmio/home/go/webmail
HTTPS file 2025, 2096 <domain>, www.<domain> /usr/local/goadmio/home/go/webmail

The site's folder is /home/<domain>/www, plus the sub-folder set as the document root in the site's settings (spaces removed). The sub-folder is created if it does not exist.

Every virtual host speaks h2 and http/1.1, and uses webmaster@<domain> as the admin address.

SSL files

The HTTPS file is written only when a certificate is found: at least three .pem files in /etc/ssl/<domain>/ (a paid certificate) or in /etc/letsencrypt/live/<domain>/ (Let's Encrypt). If both exist, the paid certificate is used.

Certificate Files used
Paid /etc/ssl/<domain>/cert.pem, privkey.pem, and bundle.pem
Let's Encrypt /etc/letsencrypt/live/<domain>/cert.pem, privkey.pem, and chain.pem, plus /etc/letsencrypt/options-ssl-apache.conf

Redirects and special rules

Rule When it is added
/go redirects to the server hostname's panel, and /webmail to its webmail Always, on the domain's port 80 and 443 hosts.
HTTP to HTTPS redirect A Let's Encrypt certificate exists and the site's SSLRedirect setting is 1.
HTTPS to HTTP redirect The site's SSLRedirect setting is -1.
Redirect to the server's suspend page The site is suspended.
PHP-FPM handler for .php files The site's FPM setting is 1. See below.
Proxy of /goserver to port 8080 on the server The folder /goserver exists.
Bad-bot blocking See below.

The PHP-FPM handler sends .php files to the socket /run/sock/<version>/<domain>.sock, where <version> is the PHP version without dots, such as 83. If the site's OpenBasedir setting is /, the shared socket /run/sock/<version>/go.sock is used instead. The proxy timeout is 30 seconds, or the number in /var/go/etc/timeout if it holds one.

The PHP-FPM handler lines for the go. and webmail. hosts are switched off inside the script.

Bad-bot blocking

Visitors whose user agent matches a bot are refused with 403 Forbidden. This is added only when the site's Bot setting is 1 and at least two bots are flagged for blocking in the bot database. Bot names that contain a space are not used.

Logging

Every run appends its arguments with a timestamp to /var/log/go/apache.log.

What a run does

flowchart TD
    A["apache [domain]"] --> B{"Domain given?"}
    B -- "No" --> C["Remove SSL configs, update control database"]
    C --> D["Disable Nginx, start Apache"]
    D --> E["conf --force, then reboot"]
    B -- "Yes" --> F{"/home/domain exists?"}
    F -- "No" --> X["Error, exit 1"]
    F -- "Yes" --> G["Read the site's settings"]
    G --> H["Write the HTTP file"]
    H --> I{"Certificate found?"}
    I -- "Yes" --> J["Write the HTTPS file"]
    I -- "No" --> K["Leave the HTTPS file as it is"]

See also

Command Description
nginx Convert a GoAdmio server from Apache to Nginx
conf Rebuild the Apache/Nginx configuration in GoAdmio
checkapache Validate the Apache configuration
reload Reload PHP-FPM and the active web server
web Restart or reload the active web server
ssl Install an SSL certificate for a domain in GoAdmio
multiphp Manage PHP versions per domain
disablefpm Disable PHP-FPM per-domain pools and switch to mod_php (Apache only)
alias Create an alias domain (parked domain) in GoAdmio
default Restore the default Apache/Nginx vhost for a domain