macOS Server 5.8: Where are my web sites?
I have two early 2009 Xserves (Xserve3,1), which have been running 24 hours/day for several years. Prior to upgrading to macOS Mojave, they were running MacOS High Sierra (thanks to http://dosdude1.com/highsierra) and macOS Server 5.6.1. After upgrading to macOS Mojave (thanks again http://dosdude1.com/mojave), I upgraded to macOS Server 5.8, which has discontinued many services (including web sites) that have macOS or open source alternatives. Yet, the Apache web server bundled and launched with macOS Mojave could not find my web sites.
Extensive Google searches, including this community, failed to directly address this problem. I had precisely followed the steps in the macOS Server Service Migration Guide v1.2 (https://developer.apple.com/support/downloads/macOS-Server-Service-Migration-Guide.pdf), to no avail. At this point, I realized that the Service Migration Guide was written for macOS High Sierra, not macOS Mojave. I reversed all changes and continued my research.
I obtained a firm understanding of the Apache web server and its interactions with macOS Mojave and Server 5.8 (described below). This led to a relatively simple solution that should co-exist with macOS Server 5.8 and other services and applications using Apache web services (such as Profile Manager and Xcode).
Apache v2.4.34 is bundled with macOS Mojave. When macOS Mojave is started, it launches Apache using the "/etc/apache2/httpd.conf" configuration file. The "DocumentRoot" in this configuration file is "/Library/WebServer/Documents". If macOS Server is not installed, this Apache instance will listen on port 80. Otherwise, it listens on port 8080.
macOS Server 5.8, if installed, launches its own instance of Apache using the "/Library/Server/Web/Config/Proxy/apache_serviceproxy.conf" configuration file. The "DocumentRoot" in this configuration file is "/Library/Server/Web/Data/Sites/Default". This Apache instance listens on ports 80 and 443 via virtual hosts. The use of virtual hosts precludes the ability to create Apache user directories, which implies that macOS Server 5.8 should only be run on a dedicated server.
Let me digress a moment to identify two important findings in my research. First, each instance of Apache (httpd) contains only the dynamic modules loaded by LoadModule directives in its own configuration file. For example, if the php7 module is loaded by macOS Mojave's Apache configuration file, it will not be available in macOS Server's instance, unless it is explicitly loaded in macOS Server's Apache configuration file. Second, "apachectl" controls the instance launched by macOS Mojave, not macOS Server 5.8. Unfortunately, macOS Server's "servicectl" also controls the instance launched by macOS Mojave, not macOS Server 5.8, and cannot be used to restart macOS Server's instance after modifying its configuration file. I believe this to be an oversight on the part of Apple. Modifying macOS Server's Apache configuration file requires restarting macOS Mojave to take effect.
Both of my Xserves run the MySQL 5.7 server and phpMyAdmin. The OS resides on the 128GB solid state drive, while service data for macOS Server 5.8 resides on a Raid 1 hard drive array. Recovering access to phpMyAdmin required only two changes:
1.
The following lines are added to the "/Library/Server/Web/Config/Proxy/apache_serviceproxy.conf" configuration file to activate php:
LoadModule php7_module libexec/apache2/libphp7.so
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
2.
To access phpMyAdmin, use the following shell command in Terminal to create a symbolic link in macOS Server's Document Root (/Library/Server/Web/Data/Sites/Default):
ln -s /Volumes/Raid1HD/ServiceData/Web/Documents/phpMyAdmin /Library/Server/Web/Data/Sites/Default/phpMyAdmin
Replace "/Volumes/Raid1HD/ServiceData/Web/Documents" with the actual location of phpMyAdmin.
Consistent with the philosophy of a dedicated server, the "user:group" for Apache instances on my servers remains "_www:_www". The "user:group" for phpMyAdmin files and the symbolic link on my servers is "root:admin".
I have not explored using other modules such as Perl and Python. Although macOS Server 5.8 uses Apache as a reverse proxy, complex configurations leveraging the reverse proxy and/or using custom virtual hosts were not explored. However, multiple web sites may be hosted by placing appropriate symbolic links in the Document Root.
I hope this information is useful and spares others the days of research and experimentation I had endured.