Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing on Mojave #249

Open
phaistonian opened this issue Jun 5, 2018 · 49 comments

Comments

Projects
None yet
@phaistonian
Copy link

commented Jun 5, 2018

Hello.

This is what I get:

❯ sudo apachectl configtest
httpd: Syntax error on line 545 of /private/etc/apache2/httpd.conf: Syntax error on line 8 of /private/etc/apache2/other/+php-osx.conf: Cannot load /usr/local/php5/libphp7.so into server: dlopen(/usr/local/php5/libphp7.so, 10): no suitable image found.  Did find:\n\t/usr/local/php5/libphp7.so: code signing blocked mmap() of '/usr/local/php5/libphp7.so'\n\t/usr/local/php5/libphp7.so: stat() failed with errno=22

after installing 7.2 on Mojave.

Ideas?

@maxisoft-git

This comment has been minimized.

Copy link

commented Jun 10, 2018

the same problem with me

@phaistonian phaistonian changed the title Installing on Mohave Installing on Mojave Jun 10, 2018

@moosti

This comment has been minimized.

Copy link

commented Jul 7, 2018

the same problem with me

@martinsnajdr

This comment has been minimized.

Copy link

commented Aug 15, 2018

I had the same problem and the only solution was to use the build in PHP library (shipped with macOS). So I changed the path to load php7_module to the default

LoadModule php7_module libexec/apache2/libphp7.so

Hope it will help. It's a temporary solution. The version is 7.1.19 on my laptop (latest public beta of Mojave).

@Vitassam

This comment has been minimized.

Copy link

commented Sep 25, 2018

Same problem after php 5.6 installing:

httpd: Syntax error on line 178 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/php5/libphp5.so into server: dlopen(/usr/local/php5/libphp5.so, 10): no suitable image found. Did find:\n\t/usr/local/php5/libphp5.so: code signature in (/usr/local/php5/libphp5.so) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.\n\t/usr/local/php5/libphp5.so: stat() failed with errno=22

@martinsnajdr

This comment has been minimized.

Copy link

commented Sep 25, 2018

Well, I have similar problems with some php packages (like APCu). There is not much information about it, but I read somewhere that Mojave is somehow more strict about app / script / package signatures. I think that the only thing we can do is to wait... Mojave (not beta) was released yesterday, so I hope the devs are gonna fix this soon.

@chregu

This comment has been minimized.

Copy link
Member

commented Sep 25, 2018

Grr, yes. Does not work in apache right now. No idea how to sign that stuff correctly. Some basic experiments failed, they also showed, that you can't load "foreign" libraries into system process (like httpd). Not sure, if there's a workaround/solution for that. I hope so.

Alternatives right now:

  • Use the apple provided php library (It's php 7.2 after all).
  • Switch to php-fpm, the binary is in /usr/local/php5/sbin/php-fpm - Not much is provided regarding how to set that up, but maybe someone can figure it out and post it here. (If you use some .htaccess apache magic, switching to php-fpm will be more work than maybe expected)
  • Try setting up httpd and php with homebrew: https://gist.github.com/DragonBe/0faebe58deced34744953e3bf6afbec7 (didn't test)

BTW: The php binary on the cli works. As does apparently php-fpm, just loading the library in apache has a "permission" problem.

@Endeauvirr

This comment has been minimized.

Copy link

commented Sep 25, 2018

Unfortunatley similar problem here after installing php7.3 and php7.2

httpd: Syntax error on line 177 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/php5/libphp7.so into server: dlopen(/usr/local/php5/libphp7.so, 10): no suitable image found. Did find:\n\t/usr/local/php5/libphp7.so: code signature in (/usr/local/php5/libphp7.so) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.\n\t/usr/local/php5/libphp7.so: stat() failed with errno=22

@moosti

This comment has been minimized.

Copy link

commented Sep 25, 2018

Problem solved for me, first of all run brew update & brew upgrade then follow steps in this link (It is 3 part)

@Gulivertx

This comment has been minimized.

Copy link

commented Sep 25, 2018

php liip works fine with apache installed from homebrew (brew install https)

Quick steps:

  • sudo apachectl stop <- stop default Apache2 from Apple
  • sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist <- remove default Apache from launchd (autostart)
  • brew install httpd <- install apache2 from homebrew
  • sudo brew services start httpd

Default port for Apache from brew is 8080 you should change it in the config files, also add at the end of the conf file Include /private/etc/apache2/other/*.conf
the config is located in /usr/local/etc/httpd/httpd.conf

@1fifoto

This comment has been minimized.

Copy link

commented Sep 25, 2018

Slightly different error on Mojave when trying to access earlier install and use of php5

httpd: Syntax error on line 545 of /private/etc/apache2/httpd.conf: Syntax error on line 8 of /private/etc/apache2/other/+php-osx.conf: Cannot load /usr/local/php5/libphp5.so into server: dlopen(/usr/local/php5/libphp5.so, 10): no suitable image found.  Did find:\n\t/usr/local/php5/libphp5.so: code signature in (/usr/local/php5/libphp5.so) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.\n\t/usr/local/php5/libphp5.so: stat() failed with errno=22

I really don't want to switch to using homebrew at this time

@suneet64

This comment has been minimized.

Copy link

commented Sep 26, 2018

Works fine with homebrew installed apache

Steps to make it work:

  1. macOS comes with pre-installed apache, following are the commands to stop it and prevent from autostart on boot:
    $ sudo apachectl stop
    $ sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

  2. Install apache through homebrew
    $ brew install httpd

  3. Check apache installation through the following command and the output should be /usr/local/bin/apachectl
    $ which apachectl

  4. Start apache through the following command
    $ sudo apachectl -k start

  5. Set apache to startup on bootload
    $ sudo brew services start httpd

  6. Re-install php from https://php-osx.liip.ch link.

@Endeauvirr

This comment has been minimized.

Copy link

commented Sep 26, 2018

Confirming that @Gulivertx and @suneet64 solutions are correct. I've tested it now with PHP 7.2.9 package.
Homebrew apache have no problems with this - so its currently the best option I think until resolving this issue.

@chregu

This comment has been minimized.

Copy link
Member

commented Sep 28, 2018

I still didn't come up with any solution with using the built-in apache. Maybe the homebrew aproach is the best one. One could also switch totally to homebrew, also for the PHP part. The tutorial over at https://getgrav.org/blog/macos-mojave-apache-multiple-php-versions worked for me at least. It's not a liner apparently ;)

Just to decide about the future of this project, what keeps people using this php binary instead of the one by homebrew? If you have compelling reasons, I will think about some more time consuming (for me/us) solutions to keep it going. But from a quick glance, the homebrew solution (with php from there) seems to be good, too.

(the one-liner installation is of course very useful, the homebrew installation needs quite some working in the config files to get it running)

@lowbatteries

This comment has been minimized.

Copy link

commented Sep 28, 2018

@chregu thanks for you work on this. I for one, prompted by Mojave, have moved to homebrew for my entire stack. I used the same tutorial as you. Since I’m giving up on the built-in Apache, I won’t be needing this package.

@campsoftware

This comment has been minimized.

Copy link

commented Sep 29, 2018

This doesn't help installing, but if you need to get PHP working locally the following worked for me based on https://tobschall.de/2018/08/08/mojave-mamp/ which states that Mojave ships with PHP 7.1.x.

I edited "/etc/apache2/httpd.conf" and added "LoadModule php7_module libexec/apache2/libphp7.so" below all the other LoadModule calls located at the top of the conf file.

Then I added the path to my alias below "" and restarted apache. All good so far!

@sonna1990

This comment has been minimized.

Copy link

commented Oct 1, 2018

Work for me:
vim /etc/apache2/httpd.conf
then remove or comment # in line 545 "Include /private/etc/apache2/other/*.conf"

After that, run
sudo apachectl start

@thefunkyjoint

This comment has been minimized.

Copy link

commented Oct 2, 2018

Works fine with homebrew installed apache

Steps to make it work:

  1. macOS comes with pre-installed apache, following are the commands to stop it and prevent from autostart on boot:
    $ sudo apachectl stop
    $ sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
  2. Install apache through homebrew
    $ brew install httpd
  3. Check apache installation through the following command and the output should be /usr/local/bin/apachectl
    $ which apachectl
  4. Start apache through the following command
    $ sudo apachectl -k start
  5. Set apache to startup on bootload
    $ sudo brew services start httpd
  6. Re-install php from https://php-osx.liip.ch link.

In this case, in which folder are Apache installed ? On 'etc/apache2' ?

@Gulivertx

This comment has been minimized.

Copy link

commented Oct 2, 2018

/usr/local/

It’s call httpd

@thefunkyjoint

This comment has been minimized.

Copy link

commented Oct 2, 2018

Where is the correct httpd.conf after install Apache with 'brew install httpd' ?

@thefunkyjoint

This comment has been minimized.

Copy link

commented Oct 2, 2018

So i could follow the installations steps but now when i go to 127.0.0.1/myapp, the browser shows the php code instead of executing it... any hints ?

@javierojeda94

This comment has been minimized.

Copy link

commented Oct 5, 2018

I think switching to another apache installation is not a suitable solution for everyone... Did someone actually got brew php to work with built-in apache?

@chregu

This comment has been minimized.

Copy link
Member

commented Oct 5, 2018

I think brew php would have the same issue with the permission/security features of the apple provided apache.

@CamJN

This comment has been minimized.

Copy link

commented Oct 5, 2018

Apple is aware of this issue, I just got my radar duped.

@chregu

This comment has been minimized.

Copy link
Member

commented Oct 5, 2018

Oh, good to hear. Hope there will a solution to this

@javierojeda94

This comment has been minimized.

Copy link

commented Oct 5, 2018

So for now the only suitable solution is to reinstall apache via brew?

@chregu

This comment has been minimized.

Copy link
Member

commented Oct 5, 2018

If you can't live with the php module provided by apple, yes, that's the only solution I know of

@javierojeda94

This comment has been minimized.

Copy link

commented Oct 5, 2018

Well... I have some projects that only works on php5.6 so php7 won't work... Unfortunately for me I cannot wait for a solution from Apple :/

@barbhackk

This comment has been minimized.

Copy link

commented Oct 11, 2018

I also encounter the problem. As suggested, I reactivated the PHP 7 extension provided with Mojave.

I still have a problem. How to enable intl.so extension with this PHP Mojave version ?

thank you,

@r-obeen

This comment has been minimized.

Copy link

commented Oct 18, 2018

I also encounter the problem. As suggested, I reactivated the PHP 7 extension provided with Mojave.

I still have a problem. How to enable intl.so extension with this PHP Mojave version ?

thank you,

I would love to know too !

@abbood

This comment has been minimized.

Copy link

commented Oct 20, 2018

I followed the instructions in this link: #249 (comment) and it threw me back right to this post 😂


[WARNING]
Detected macOS Mojave 10.14. There are serious issues with it, due to the original apache not loading
foreign libraries anymore. PHP within apache will most certainly not work anymore if you proceed!
The cli version still will.
See this issue at #249 for details and discussion


Restart this script with
curl -s https://php-osx.liip.ch/install.sh | bash -s force 7.1
to really install it


@Mark-Ming

This comment has been minimized.

Copy link

commented Oct 24, 2018

Works fine with homebrew installed apache

Steps to make it work:

  1. macOS comes with pre-installed apache, following are the commands to stop it and prevent from autostart on boot:
    $ sudo apachectl stop
    $ sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
  2. Install apache through homebrew
    $ brew install httpd
  3. Check apache installation through the following command and the output should be /usr/local/bin/apachectl
    $ which apachectl
  4. Start apache through the following command
    $ sudo apachectl -k start
  5. Set apache to startup on bootload
    $ sudo brew services start httpd
  6. Re-install php from https://php-osx.liip.ch link.

Thank you very much, it works for me!

@mfoote

This comment has been minimized.

Copy link

commented Oct 26, 2018

Works fine with homebrew installed apache

Steps to make it work:

1. macOS comes with pre-installed apache, following are the commands to stop it and prevent from autostart on boot:
   `$ sudo apachectl stop`
   `$ sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null`

2. Install apache through homebrew
   `$ brew install httpd`

3. Check apache installation through the following command and the output should be /usr/local/bin/apachectl
   `$ which apachectl`

4. Start apache through the following command
   `$ sudo apachectl -k start`

5. Set apache to startup on bootload
   `$ sudo brew services start httpd`

6. Re-install php from https://php-osx.liip.ch link.

Not working for me, after following steps, which apachectl still returns...
/usr/sbin/apachectl

@smaier

This comment has been minimized.

Copy link

commented Oct 29, 2018

tho re-enable the built in apache to work with unsigned files one could also disable "SIP"
to do this:

  • reboot holding CMD+R (for recovery mode)
  • start the terminal (via menu on top - utilities > terminal)
  • type csrutil disable; reboot

apple will consider this a security-issue. if you know what you are doing - it's not.

@JeremyXu555

This comment has been minimized.

Copy link

commented Nov 7, 2018

I had the same problem and the only solution was to use the build in PHP library (shipped with macOS). So I changed the path to load php7_module to the default

LoadModule php7_module libexec/apache2/libphp7.so

Hope it will help. It's a temporary solution. The version is 7.1.19 on my laptop (latest public beta of Mojave).

I feel this is the quickest way to make things work again for me. Thank you! @martinsnajdr

Just wanna mention the file is located at /etc/apache2/httpd.conf and for the full command would be sudo vim /etc/apache2/httpd.conf

@Aerendir

This comment has been minimized.

Copy link

commented Nov 16, 2018

Just a note: installing Apache through Homebrew may change the httpd.conf file loaded to this one:

/usr/local/homebrew/etc/httpd/httpd.conf

It also need to be fully configured to support PHP, requires to reconfigure the document root and all other customizations you may have made to your built-in Apache.

@intodevelopment

This comment has been minimized.

Copy link

commented Nov 16, 2018

Works fine with homebrew installed apache

Steps to make it work:

1. macOS comes with pre-installed apache, following are the commands to stop it and prevent from autostart on boot:
   `$ sudo apachectl stop`
   `$ sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null`

2. Install apache through homebrew
   `$ brew install httpd`

3. Check apache installation through the following command and the output should be /usr/local/bin/apachectl
   `$ which apachectl`

4. Start apache through the following command
   `$ sudo apachectl -k start `

5. Set apache to startup on bootload
   `$ sudo brew services start httpd `

6. Re-install php from https://php-osx.liip.ch link.

Thanks! I followed your instructions, yet instead of step 6, I installed php56 using brew. However I got the following error in my apache logs: AH00052: child pid 4540 exit signal Segmentation fault (11).

I found here that it helps to comment out all lines in /usr/local/etc/php/5.6/conf.d/ext-opcache.ini. It worked for me. It might also help someone else.

@kstratis

This comment has been minimized.

Copy link

commented Nov 18, 2018

@intodevelopment

Same problem here.
I installed v7.2.9 but can't find /usr/local/etc/php/5.6/conf.d/ext-opcache.ini.
However I did find and commented out this one: /usr/local/php5/php.d/20-extension-opcache.ini.

Segfaults remain... any further clues?

@PooyaRaki

This comment has been minimized.

Copy link

commented Dec 9, 2018

Any solution to sign new extensions? The built-in package works well but can't get intl to work with it.

Any idea?

@loginov-rocks

This comment has been minimized.

Copy link

commented Feb 21, 2019

Appeared here after googling the error. Got it after trying to launch Apache with PHP 5.6 installed by Homebrew. So I haven't used this tool, I mean just to be clear the issue with PHP package itself.

@CamJN

This comment has been minimized.

Copy link

commented Mar 29, 2019

This should be fixed in 10.14.4

@guenti

This comment has been minimized.

Copy link

commented Mar 29, 2019

Is fixed in Mojava 10.14.4.

@roydukkey

This comment has been minimized.

Copy link

commented Apr 7, 2019

@CamJN and @guenti Can you provide any resources to support your claim that this issue is fixed in 10.14.4?

@CamJN

This comment has been minimized.

Copy link

commented Apr 7, 2019

@roydukkey unfortunately issues in Apple's Radar aren't public, so no there's nothing I can point at. However I can tell you that Apple marked my issue as fixed for 10.14.4 and that in my testing all of my boxes running 10.14.4 can once again load 3rd party modules into Apple's Apache.

@Michelle1502

This comment has been minimized.

Copy link

commented Apr 8, 2019

Is fixed in Mojava 10.14.4.

@roydukkey unfortunately issues in Apple's Radar aren't public, so no there's nothing I can point at. However I can tell you that Apple marked my issue as fixed for 10.14.4 and that in my testing all of my boxes running 10.14.4 can once again load 3rd party modules into Apple's Apache.

Before I set to try installing PHP 7 using homebrew, can someone reconfirm, is it really fixed on the latest version of Mojave 10.14.4 ?

@treken1

This comment has been minimized.

Copy link

commented Apr 10, 2019

I have the Apache / php library signing warning happening... wont load
I have Mojave 10.14.2
I am about to update to 10.14.4
Will report what happens

@treken1

This comment has been minimized.

Copy link

commented Apr 10, 2019

Ok, I have installed 10.14.4
After I fixed up config to get open ssh to allow me in again I can confirm that after commenting out php7_module in httpd.conf and then loading php5_module as per my old config my PHP5 started to work :)

@treken1

This comment has been minimized.

Copy link

commented Apr 10, 2019

So to be more specific

  1. I updated to Mojave 10.14.4 - 2.5GB Download
  2. I opened /private/etc/apache2/httpd.conf
  3. I commented my line 177 to look like
    #LoadModule php7_module libexec/apache2/libphp7.so
    Note:
    At the bottom of the file I have
    Include /private/etc/apache2/other/*.conf
  4. Open /private/etc/apache2/other/php7.conf
    commented all the lines in php7.conf so it looks like
    # <IfModule php7_module>
    # AddType application/x-httpd-php .php
    # AddType application/x-httpd-php-source .phps
    #
    # <IfModule dir_module>
    # DirectoryIndex index.html index.php
    # </IfModule>
    # </IfModule>

*** Dont forget to save changes ***
5. then at the command line
sudo apachectl restart

My PHP5 installation is part of the entropy.ch PHP package for Mac OS X
I have version php5-5.6.31-20170817-164511

In my /private/etc/apache2/other/ folder I have a file like +php5-osx.conf that is a symlink to /usr/local/php5-5.6.31-20170817-164511/entropy-php.conf
this file contains the following content

#
# Additional PHP Apache directives,
# part of the entropy.ch PHP package for Mac OS X
#
# For more information, go to http://www.entropy.ch/software/macosx/php/
#

LoadModule php5_module /usr/local/php5/libphp5.so

<IfModule mod_php5.c>

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>

</IfModule>

So this got my PHP 5 working again on Mojave
I have some old php code using functions no longer in php7 so for me this was a timely update from Apple.

@igorbenic

This comment has been minimized.

Copy link

commented Apr 25, 2019

I have figured it out on Mojave 10.14.4

What I've done to use 7.2.9 is to download it using the instructions on https://php-osx.liip.ch/ and then directly calling the module in /etc/apache2/httpd.conf

#LoadModule php5_module /usr/local/php5/libphp5.so
#LoadModule php7_module libexec/apache2/libphp7.so
LoadModule php7_module /usr/local/php5-7.2.9-20180821-074958/libphp7.so

Saving and then restarting sudo apachectl restart.

I've written about it also on my blog: https://www.ibenic.com/installing-php-mojave/

@thepurpleblob

This comment has been minimized.

Copy link

commented May 5, 2019

@igorbenic - seem to work for me with PHP 7.3. So far, anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.