0

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).

  • Is autostartapache.app added to "Full Disk Access"? – Wowfunhappy Nov 16 '18 at 18:44
  • Is it added to Automation? That's where my scripts have to be to work. I have appleeventsd & Automator & Automator Runner in Full Disk Access, but the individual scripts are in Automation. – Tetsujin Nov 16 '18 at 18:46
  • @Wowfunhappy I didn't have autostartapache.app on Full Disk Access (or any other app), but I have just given it permissions there, and it still won't work via shell script nor AppleScript. – David Lopez Nov 16 '18 at 19:02
  • I would downgrade. Mojave sounds like it's causing misery to many users, especially for anything scripting-related. Instead, silence the bothersome notifications using this method here – CJK Nov 16 '18 at 23:01
  • Hi guys, I answered my question with another solution. I still don't understand what was blocking me from using the same app I used before, but modifying the bash script a little bit did it, also used a native PHP server instead of using Apache. Thanks for your help! – David Lopez Nov 17 '18 at 0:54
1

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.

You must log in to answer this question.

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