Automator app stopped working after updating to macOS Mojave

apacheautomatorbashmojaveterminal

Today I updated to Mojave because the notifications were killing me.

A script I have in automator to launch apache server on startup stopped working after the update.

enter image description here

This is all this automator app is doing

echo mypassphrase | sudo -S apachectl restart

Strangely, this exact same line works fine if I run it from the terminal

I tried using the following AppleScripts that some people recommend online:

do shell script "echo mypassphrase | sudo -S apachectl restart" with administrator privileges
do shell script "sudo -S apachectl restart" with administrator privileges
do shell script "sudo apachectl restart" with administrator privileges
do shell script "apachectl restart" with administrator privileges

None of them work. Launching the app manually doesn't work either. The script only works if I'm running it from Terminal.app

I've also given this app (autostartapache.app) the permission to control my computer on System Preferences > Security and Privacy. I have also restarted the machine. The app runs on startup but doesn't start apache, running the app manually won't work either, running from Automator doesn't start apache either.

enter image description here

Thinking of downgrading to High Sierra that was working fine, I don't really like this update anyway and there really isn't anything new to the user other than the few apps they added (news, stock, etc). My sister also told me that her Wacom device to do digital art is not working well after the update. This issue seems to be related to the changes they did to security (everything needing permissions now).

Best Answer

The issue seems to be related to running custom PHP + Apache versions on Mojave, there are a lot of issues open on Github regarding problems with PHP, Apache and Mojave on Github, and the solutions wouldn't work for me.

Since what I really wanted to do was to keep having a PHP server to automatically run on startup to later test PHP scripts and websites locally, I decided to fire up the local server using PHP's built-in server command instead of Apache.

I used this bash script on the Automator app, it uses Mojave's preinstalled PHP version (7.1.19) and it authenticates just fine using the same sudo trick:

echo mypassphrase | sudo -S php -S localhost:80 -t <directory to serve from>
killAll ScriptMonitor

The last line killAll ScriptMonitor just gets rid of the spinning cog in the menu bar as soon as the server is created, this won't affect PHP from running in the background and PHP will keep acting as a server until terminated via command line or Activity Monitor or system shut down.