PHP does not work after upgrading MacOS to High Sierra

I updated my mac to the newest version of os. When I try to start a PHP project, the browser displays the PHP code instead of interpreting it. I noticed that in the new OS php is in version 7.1. I installed 5.6 (this was required for me) using homebrew and changed the module in httpd.conf to:

LoadModule php5_module / usr / local / Cellar / php 56 / 5.6.31_7 / libexec / apache2 / libphp5.so

Here's the apache error log:

[Tue Sep 26 23: 59: 38.600410 2017] [mpm_prefork: notice] [pid 980] AH00169: caught by SIGTERM, closing [Tue Sep 26 23: 59: 38.622998 2017] [core: notification] [pid 980] AH00060: seg error or a similar nasty error detected in the parent process AH00557: httpd: Error apr_sockaddr_info_get () for MacBook-Pro-Kamil.local AH00558: httpd: Failed to reliably determine the server fully domain name using 127.0.0.1. Set the global "ServerName" directive to suppress this message [Tue Sep 26 23: 59: 48.838005 2017] [mpm_prefork: notice] [pid 991] AH00163: Apache / 2.4.27 (Unix) PHP / 5.6.31 configured - resume normal operations [Tuesday 26 September 23: 59: 48.838097 2017] [main: notification] [pid 991] AH00094: Command line: '/ usr / sbin / httpd -D FOREGROUND'

+5
source share
8 answers

Adding the following lines to the httpd.conf file fixes the problem:

AddType x-httpd-php .php AddHandler application/x-httpd-php .php .php5 

Hope this helps!

Edit: just to provide a little more detailed information, as crmpicco suggests, I also replaced the new High Sierra httpd.conf and httpd-vhosts.conf files with my old Sierra ones, such as:

 mv httpd-vhosts.conf~previous httpd-vhosts.conf mv httpd.conf~previous httpd.conf 

Even after all this and restarting Apache, it still did not work - I had to restart everything in order to take effect.

+4
source

The MacOS update process seems to translate your Apache configuration into ~previous files, creating new, fresh versions. You just need to get them back. This worked for me:

 mv httpd-ssl.conf~previous httpd-ssl.conf mv httpd-vhosts.conf~previous httpd-vhosts.conf mv httpd.conf~previous httpd.conf 

Check the syntax.

 apachectl -S 

Restart Apache.

 apachectl restart 
+1
source

Using PHP5.6 with HighSierra

  • Allow the creation of a general Apache Handler module Make sure that the latest version of PHP56 is installed along with the http parameter (install / update / reinstall if necessary)

    $ brew upgrade php56 --with-httpd

  • Binding a module in the Apache2 configuration file Add the following instruction to the apache2 / etc / apache2 / httpd.conf configuration file

    LoadModule php5_module / usr / local / Cellar / php56 / 5.6.32_8 / libexec / apache2 / libphp5.so

  • Adding a PHP5 configuration file

    Make a copy from php7.conf

    $ cd / etc / apache2 / other; sudo cp php7.conf php5.conf

    Replace php7_module with php5_module

  • Restart apache server

    $ sudo / usr / sbin / apachectl restart

+1
source

This is not like your problem with PHP, but with your domain name. Note the message "It is not possible to reliably determine the fully qualified domain name of the server using 127.0.0.1. Set the global" ServerName "directive to suppress this message." Check the domain settings in the httpd.conf file. You should also check the / etc / hosts file for any conflicts there.

This guide to installing and using Apache / MySQL / PHP through Homebrew was very helpful. It applies to macOS Sierra, but will work with High Sierra as well. It will also show you how to install multiple versions of PHP and a convenient way to switch between them if it interests you (or just save one version of PHP).

I like to go along the Homebrew route, unlike Vagrant or MAMP, because it is closer to the native installation and uses less resources. Hope this helps!

0
source

The same thing here, using MAMP and php 5.6: immediately after upgrading to High Sierra (which is probably Sierra with too much weed ..) Apache2 stops working.

After a few hours, I finally decided this command:

cp /Applications/MAMP/bin/php/php5.6.25/conf/php.ini.temp /Applications/MAMP/bin/php/php5.6.25/conf/php.ini

And reapplied my custom changes to php.ini. (in my case memory_limit and short_open_tag)

Restarting MAMP, and it worked on the first try.

0
source

After adding

 LoadModule php5_module /usr/local/Cellar/php56/5.6.31_7/libexec/apache2/libphp5.so 

you need to add

 <IfModule mod_php5.c> # If php is turned on, we respect .php and .phps files. AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps # Since most users will want index.php to work we # also automatically enable index.php <IfModule mod_dir.c> DirectoryIndex index.html index.php </IfModule> 

to

 /etc/apache2/httpd.conf 

Do not forget

 apachectl restart 
0
source

I also looked at the homebrew option, in the end I decided to use Vagrant. you can leave your project files where they are and use the firewall for local maintenance. I used the laravel / homestead field after the guide https://laravel.com/docs/5.5/homestead and in Homestead.yaml - you can use the same box for laravel and wordpress, etc., this is also a much more promising proof for the next osx update, and you can easily choose the php version on the site based on the site.

 folders: - map: ~/Documents/www/mysite/ to: /home/vagrant/mysite type: "nfs" sites: - map: mysite.app to: /home/vagrant/mysite/dist php: "5.6" 

and in / etc / hosts / add

 192.168.10.10 mysite.app 
-1
source

You can download the version of Xampp that supports PHP 5.6.31 and run the application using Xampp.

If you do not want to do this, I think you need to return to MacOs Sierra, remember that PHP 5.6 is old, new systems come with the latest version!

-2
source

Source: https://habr.com/ru/post/1272141/


All Articles