1

I want to use Apache on macOS 10.13. I issued "sudo apachectl start" command then it enabled. I confirmed to display "It works" on the browser by http://localhost/ and I could know Apache worked properly.

But recently after I load Server app. Then when I enter http://localhost/, "Welcome MacOS server" display. It means web server is used for App server instead Apache. "Welcome MacOS server" continues to display even when I disabled MacOS web server. How can I switch to Apache?

Regards Simon

2 Answers 2

3

How to deactivate MacOS server apache

This command deactivates web services

$ sudo serveradmin stop web

These commands should unload the launch daemons inside Server app. Following my experience Server Apache takes over as soon as you install server app. Stopping web services in some cases is not sufficient. By unloading the Apache daemon server app is unable to start its Apache.

$ sudo launchctl unload -w /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/com.apple.server.httpd.plist
$ sudo launchctl unload -w /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/com.apple.serviceproxy.plist

When configuring Server’s Apache the following configuration files are used. By uncommenting any listen section Server Apache will not be able to run.

$ nano /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf
$ nano /Library/Server/Web/Config/apache2/services/ACSServer.conf

When Server Apache does not know which ports it has to listen to, it does not run.

Depending from your system some steps or all of them might be necessary to stop Server Apache from running and for your Apache installation to take over. All these steps will only affect your server web services.

With the next Server App web service will be gone.

3
  • Thanks for your info. But the second command shows "Could not find specified service" even though there is com.apple.server.httpd.plist in the document. The third command works, but when I access "localhost" I can't access to localhost. The fourth and fifth command moves to editor, what should I do here?
    – Simon J
    Jun 5, 2018 at 14:00
  • @SimonJ I added some info to my answer. I encountered the same problem when I switched to a Brew installed Apache, when after a restart Server’s Apache was back preventing Brew’s Apache to run.
    – SEJU
    Jun 5, 2018 at 16:32
  • @SimonJ in my answer I reported all the commands I ran in order to get Server’s Apache deactivated. In my case the first command was not sufficient, since it was not consistent after a reboot.
    – SEJU
    Jun 5, 2018 at 16:43
0

You can compile your own httpd version and make a new LaunchDeamon and point Server App to your httpd in the httpd_server_app.conf:

ServerRoot "/usr/local/your-httpd"

Disable the com.apple LaunchDeamon as shown above:

$ sudo launchctl unload -w /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/com.apple.server.httpd.plist

Then load your own LaunchDeamon:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>org.apache.apache2</string>

    <key>EnvironmentVariables</key>
        <dict>
    <key>SERVER_INSTALL_PATH_PREFIX</key>
        <string>/Applications/Server.app/Contents/ServerRoot</string>
    <key>SERVER_INSTALL_PATH_MODULE_PREFIX</key>
        <string>/usr/libexec/your-httpd</string>
        </dict>

    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/your-httpd/bin/httpd</string>
      <string>-D</string>
      <string>FOREGROUND</string>
      <string>-f</string>
      <string>/Library/Server/Web/Config/apache2/httpd_server_app.conf</string> 
    </array>

    <key>StandardOutPath</key>
    <string>/usr/local/var/log/apache.log</string>
    <key>StandardErrorPath</key>
    <string>/usr/local/var/log/apache.log</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
  </dict>
</plist>

Verify that the path prefix keys for the modules are correct. Logs else give you a pretty easy output where to adjust the httpd_server_app.conf. Lazy version: If the prefix is not working or for some apple only modules: copy&paste them to your pointed folder.

Now you can use the Server App interface - including the proxy architecture - with your own httpd.

The httpd_server_app.conf is overwritten when updating the Server App so keep a copy.

Disclaimer: This is just showing up a possibility and is not to be seen as advice by any means on how to run a webserver.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .