32

I'm trying to view php files locally on my mac.

I'm running Yosemite.

I have MAMP installed on my computer. When I press start the MySQL server starts but Apache doesn't. An error message appears saying 'Error. Apache couldn't be started. Please check your MAMP installation'

I've gone through the internet typing stuff into terminal and changing 'envvars' to '_envvars' but nothing works.

I reinstalled OSX and that worked but when I shut down the computer the problem occurs again.

Can anyone help?

Thanks

Apache9019
  • 369
  • 1
  • 3
  • 5
  • Last time I used MAMP was with Mavericks. Which version did you use? – qwerty_so Jan 31 '15 at 13:44
  • I'm having the same problem – OS X Yosemite 10.10.2 and MAMP PRO 2.1.1. There's a link here which describes the solution mentioned in the question (which also doesn't work for me): https://stackoverflow.com/questions/25139599/mamp-pro-3-05-on-mavericks-updated-to-yosemite-apache-does-not-start/25141849#25141849 I should also add that the apache error log file is empty, despite the error message saying, "Apache wasn't able to start. Please check log for more information." – geoidesic Feb 02 '15 at 19:18
  • 2
    If I try launch apache from the command line: "/Applications/MAMP/Library/bin/apachectl start" then I get the following error message: "httpd: Syntax error on line 132 of /Applications/MAMP/conf/apache/httpd.conf: Cannot load /Applications/MAMP/bin/php/php5.4.4/modules/libphp5.so into server: dlopen(/Applications/MAMP/bin/php/php5.4.4/modules/libphp5.so, 10): Library not loaded: /Applications/MAMP/Library/lib/libfreetype.6.dylib\n Referenced from: /Applications/MAMP/bin/php/php5.4.4/modules/libphp5.so\n Reason: image not found" – geoidesic Feb 02 '15 at 19:40

14 Answers14

40

Check if you changed the Document Root Location or Renamed it. At least this was my mistake.

MAMP > Preferences > Web Server > Document Root

Victor Rius
  • 4,566
  • 1
  • 20
  • 28
  • 2
    I know this is an old question but I experienced this issue today running Sierra and it was imply that my document root was no longer a folder so this fixed my issue! – Eli Nathan Feb 09 '17 at 12:36
  • 2
    April 4, 2019 - 3.5 years later and this answer STILL pointed me in the right direction. :) OSX 10.14.4 (Mojave) updated today and MAMP would no longer start apache. Thanks to this answer I found that the mamp -> htdocs folder was gone. simply recreating the folder solved the issue for me. – Joel Apr 05 '19 at 00:29
  • I wish they'd specify the error, saving all of us the trouble. "Hey! The document root can't be found." – Kalnode Apr 26 '20 at 22:30
31

I didn't get it working with port 8000 or the default 8888, but did get it working with port 80 per the suggestion here: http://forums.macrumors.com/showthread.php?t=1744944

That didn't work after all, but it didn't error out. However I manually ran the following at the command line (because log file was empty):

sudo /Applications/MAMP/Library/bin/apachectl start

Only to find that after upgrading I was missing the mod_example.so

httpd: Syntax error on line 83 of /Applications/MAMP/conf/apache/httpd.conf: Cannot load /Applications/MAMP/Library/modules/mod_example.so into server: dlopen(/Applications/MAMP/Library/modules/mod_example.so, 10): image not found

Copied it from my old install and I was good to go.

the_dillio
  • 534
  • 5
  • 8
  • 1
    this helped me to diagnose a hardcoded value in my httpd.conf that was referencing an old version of php that no longer existed. Updated that line and things started working again – haxxxton Aug 05 '16 at 00:59
  • Just updated to macOS Sierra, and running your first command highlighted an error in my httpd.conf as well, as it did for @haxxxton. Thanks! – Design by Adrian Sep 22 '16 at 10:42
19

If you try to start the server from the terminal, likely that will tell you what is wrong e.g.

sudo /Applications/MAMP/bin/startApache.sh

Password:

(48) Address already in use: make_sock: could not bind to address [::]:8888 (48) Address already in use: make_sock: could not bind to address 0.0.0.0:8888

no listening sockets available, shutting down

Unable to open logs

What you can do in this case, I was inadvertently running a Blockstack browser out of 8888, so changing MAMP to 8887 allowed it to start. [Your mistake might be different.]

Community
  • 1
  • 1
Martin Frické
  • 191
  • 1
  • 2
  • This should probably be marked as the correct answer, as it's a way to diagnose the issue. The reason the user may be running into the problem can vary and this solution is a way to diagnose that and is thus specific to the user. – logos_164 Oct 14 '19 at 19:28
  • I looked at a dozen different pages, all of which either suggested that apache was already running or that my startup folder was wrong - and neither fit my situation. This worked beautifully - it reported the exact location of the error in the httpd.conf file. – Tom Bisciglia Nov 24 '19 at 22:01
8

Had the same problem, nothing in the logs. After trying the_dillio's suggestion:

sudo /Applications/MAMP/Library/bin/apachectl start

I got an error that pointed back to my vhosts file. It turns out I had an extra /VirtualHost tag. Removed it and it started working again.

Cipher
  • 321
  • 3
  • 9
8

i've solved this issue using this command in the terminal :

sudo apachectl stop
mehdigriche
  • 444
  • 1
  • 4
  • 14
4

I think I've found the solution.

It was the wrong port. I altered the .conf file in the Apache folder. I changed all instances of port 8888 to 8000. When I run MAMP now it all seems to work fine.

Thanks for your help

Apache9019
  • 369
  • 1
  • 3
  • 5
  • Mine was working on port 8888, then it stopped when I tried to switch from `PHP 7` to `PHP 8`. To get it working again, I switched apache to 80 and mysql to 3306 – Logan Dec 03 '22 at 00:32
4

Also be aware that if you by any chance deleted the folder that was set as Document Root the last time you were using MAMP, you will get this error. Simply open MAMP again, change Document Root to a location that does exist and start the servers.

Alen Šimunic
  • 555
  • 1
  • 7
  • 19
1

I received the same error but interestingly it was caused simply because I renamed the root folder and didn't realize it. Sounds like you have a different issue but for anyone else who gets this error message, make sure you haven't renamed the root!

1

Absolutely bizarre behavior for MAMP PRO (paid license too btw...)

In my case I had to change the location of the log file in order to get it to work...

Click on Mysql icon then the little folder to the right of the path and try changing it to something else.

enter image description here

Robert Sinclair
  • 4,550
  • 2
  • 44
  • 46
1

For MAMP :

You can open the terminal and write:

ps aux | grep mysql
lsof -i
killall -9 mysqld

I hope is good for you!

Bye

Brydenr
  • 798
  • 1
  • 19
  • 30
David
  • 11
  • 1
0

I had this experience when upgrading to V4. It tried to used the files from my previous installation and it just never worked. The workaround was to RENAME the original MAMP installation to something different than "MAMP", install brand new version and then copy files you may need like VHOST configs and DATABASES. After all this it worked just fine.

pdolinaj
  • 1,087
  • 13
  • 21
0

My Apache server problem arose after I enabled SSL. So if this is your case, check your https-ssl.conf file (Applications -> Mamp -> conf -> apache -> extra). The Document Root under the Virtual Host settings had a different file path for htdocs than where it was actually located (easily overlooked). I changed this to "/Applications/MAMP/htdocs" and problem solved. Perhaps also check Document Root in your https.conf file (Applications -> Mamp -> conf -> apache) to see if it has the correct file path to htdocs too.

elarcoiris
  • 1,914
  • 4
  • 28
  • 30
  • When you set Document Root in MAMP it changes the httpd.conf file for you. But it is possible to get it wrong in the vhosts file, as you say. – David Rhoden Dec 30 '21 at 00:41
0

These are the steps I used to solve this issue.

  1. Checking vcredist that are required and installing them. to check which are the missing vcredist I used a tool called "check_vcredist" from wamp.
  2. I also installed latest Microsoft Visual C++ Redistributable x64.

Doing this steps solved my issue of Apache server not running

Siddhant
  • 71
  • 1
  • 4
0

Just a little tidbit here for Windows users as the original question didn't specify OS.

I had the same issue, and it has always perplexed me why you get the standard MAMP along with MAMP Pro when you upgrade.

On Windows, MAMP consumes a good deal, so I took it out of the Startup Programs litany. When I went to run JUST MAMP Pro, I kept getting the "Apache cannot start" error.

On a lark, I started up the standard MAMP and Apache ran and I could get to localhost. I ran MAMP Pro on top of that, and all was rectified.

Hope this helps Win users who've turned off auto-start on the application.

rob - not a robber
  • 508
  • 1
  • 4
  • 15