PHP stopped working after MacOS update to High Sierra - php

I recently upgraded to High-Sierra and now my local server won't run PHP (code shows it as text)
To try and solve the issue I removed all php versions with homebrew and installed php 7.2 using homebrew. But the issue remains.
I don't see any error in the local server log files.
P.S.
I do not see attempted to add
LoadModule php7_module /usr/local/opt/php72/libexec/apache2/libphp7.so
But the path seems to be wrong since I get an error..

Turns out I had to reinstall XCode Command Line Tools and this solved the issue

Related

How can I update php through homebrew

My previous php version is 7.3 and it was default in mac os. After installing new PHP version 7.4 with homebrew I update the php path.
When I run php --version it shows me php v7.4.23 but when I run any php code it doesn't work. I think I need to do some configuration in my settings. I follow some tutorial but nothing resolve my issue
Whenever I run any php it gives me this error
Fatal error: require(): Failed opening required '/Users/Raymond Tucker/projects/test/vue-test/foridpur_ict/vendor/autoload.php' (include_path='.:/usr/local/Cellar/php#7.4/7.4.22/share/php#7.4/pear') in /Users/Raymond Tucker/projects/test/vue-test/foridpur_ict/artisan on line 18
This is my output of $ where php
➜ ~ where php
/usr/local/opt/php#7.4/bin/php
/usr/local/opt/php#7.4/bin/php
/usr/local/bin/php
/usr/bin/php
➜ ~
To use the new PHP version you have to edit the Apache file:
Open the httpd.conf file and find the LoadModule. it should have the correct version of the PHP. It will look something like this:-
LoadModule php7_module /usr/local/opt/php#7.3/lib/httpd/modules/libphp7.so
What you have to do is, change this to point to the correct version of the php.
LoadModule php7_module /usr/local/opt/php#7.4/lib/httpd/modules/libphp7.so
I have Mac El Capitan. Nothing worked for me except this article (super fast).
It allowed me to update php5 to php7, I don't know why, and honestly I don't feel it was real, but I don't understand how has the php5 became php7.
Back in the day, I did it with Macports, but I couldn't install Macports this time, so I had to use this new method.
Although not a direct answer to your question Mamp pro enables you to switch PHP versions easily. It made my development life much easier.

Apache not working after macOS Catalina update

Every time macOS is upgraded to a new major version then php, apache or mysql stops working. This happens again with Catalina too. I faced issue in starting apache and mysql. Mysql started to fail as
[ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
I am posting the solution I performed for starting mysql as well as apache, php on macOS Catalina.
First, I have gone through the steps which I have shared earlier for Mojave.
Apache not working after macOS Mojave update
As I am using PHP 5.6 so I needed libphp5.so to make PHP 5.6 work after macOS upgrade. As before installing catalina, apache/php/mysql was working fine so I have the library already alavailable. I found the .so file using below command and updated the same in "/etc/apache2/httpd.conf"
sudo find / -name libphp5.so
after finding the file, I updated the same with path in /etc/apache2/httpd.conf
LoadModule php5_module
/usr/local/Cellar/php#5.6/5.6.25_1/libexec/apache2/libphp5.so
This makes the PHP 5.6 working but still mysql was failing with below error.
"[ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!"
As it is my development area only so I simply did following:
1. goto the mysql installation bin directory
cd /usr/local/mysql-5.6.25-osx10.8-x86_64/bin
run the mysql with root as user.
sudo ./mysqld --user=root
it started the mysql too.

How to configure PHP Intl extension on MacOS Mojave? [duplicate]

I followed a guide which used home-brew to install the lastest version of php (5.4.8) on OSX Mountain Lion.
I then followed a guide which showed me how to setup and use the pre-installed apache on OSX.
However when I try running up a base Symfony 2 project I get a bunch of errors relating to missing date.timezone in the php.ini.
However I have this correctly setup the php.ini but doing a quick phpinfo() in the Symfony project shows that its using the old preinstalled version of php (5.3) rather than the new one.
In terminal if I type which php & php -v, It shows the correct new version is being used.
But the phpinfo() shows
Did you follow all the instructions provided in the Caveats?
Run brew info php54 to see them again.
Especially the line:
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php5_module /usr/local/Cellar/php54/5.4.8/libexec/apache2/libphp5.so
Apache is not aware of the homebrew version of PHP (i.e. /usr/bin/php). You see it on the command line because you've likely modified your PATH (i.e. /usr/local/bin/php).
You can modify this in your httpd.conf file.
I am not a fan of homebrew or other package libraries. Primarily because Mac OS X is built atop Unix. Furthermore, all but MySQL are installed natively. Here's an article on installing Apache, MySQL, and PHP on Mac OS X.
Disclaimer: I wrote that article.
Today I have same issue for updating php 7.2 to 7.3 as requirement of Laravel 6. Here is my solution.
Open your httpd.conf file in "/etc/apache2/http.conf"
Search (Ctrl + w) for "LoadModule php"
Uncomment that row
Restart your apache with "sudo apachectl restart"
Then, your php version in local web server (apache2) will be updated

PHP upgrade issues

I am running a MacBook Air with macOS Sierra 10.12.3. I upgraded my PHP from 5.x to 7.1.1 according to this site and now I am having two issues:
a) The PHP process startup takes around 7 seconds, even for a php -v to print PHP's version. edit: Solved.
b) Apache does not serve my pages anymore locally. Chrome just shows the generic error page with "ERR_CONNECTION_REFUSED". I have restarted the apache service but don't really know what else to do. The apache vhosts config file worked before and still looks good. edit: Also nothing in the apache error logs.
edit: The syslog shows
(org.apache.httpd[71685]): Service exited due to signal: Segmentation fault: 11 sent by exc handler[0]
(org.apache.httpd): Service only ran for 5 seconds. Pushing respawn out by 5 seconds
Does anyone know how to fix this?
Solved it now.
The issue with Apache was that an additional config file in /etc/apache2/other/+php-osx.conf was created that loaded the php7.1 module, but the module loading of php5 in /etc/apache2/httpd.conf was not disabled.
Loading both obviously crashed apache and commenting out the LoadModule in httpd.conf solved it. I have no idea why the installation routine didn't do that though.
Thank you all for helping me.
https://php-osx.liip.ch is a pretty good site, I used to use it before to upgrade my php installations. I found that time to time it would be untrust worthy and sometimes brick my installation. Edit The scripts used on that site usually compile PHP when ran and this can lead to some interesting quirks and inconsistencies. So I switched to using brew.
Brew is a handy tool for Mac that works a lot like apt-get or yum. I would recommend you try this, it adds libraries in a way that allow you to purge them from your machine and reverting to older versions.
$ brew search php71
# lists all the matches for php71, you will find "homebrew/php/php71"
$ brew install homebrew/php/php71
# installs php71, it will give you some good instructions if there are errors
# typically some permission errors, but it gives commands to run too
$ brew link homebrew/php/php71
# overrides the local php command with "homebrew/php/php71"
$ php -v
PHP 7.1.1 (cli) ...
Then I would suggest looking at PHP Local Server that is built in if its still not working. Although I am 99% sure your issues will be resolved.
In future upgrading your php version is as simple as doing the above again where php71 is your new version (example php72 for 7.2). Removing your old version is easy, although does no harm and does allow you to quickly switch your versions around with a single command line option.

Unsuccessful XDebug installation

I'm trying to install XDebug on my local machine with Win 7, Apache 2, PHP 5.3.6 TS VC9 build (server manually installed, no package). I've followed instructions at http://xdebug.org/find-binary.php:
I've downloaded dll, moved to dir with other extensions, added following code to C:\Windows\php.ini, restarted server and - in contrary to my expectations - xdebug is neither installed nor listed in phpinfo page.
zend_extension="E:\www\server\php\ext\php_xdebug-2.1.2-5.3-vc9.dll"
Altough I've gone trough my phpinfo and XDebug site several times I still have no idea what can cause this problem. Do you have any suggestions how to get XDebug working please?
Thank you
According to netbeans manual you have to add the xdebug configuration file to the apache php ini directory and not the local php ini directory to make it work with anykind of wamp.
1) http://wiki.netbeans.org/HowToConfigureXDebug
2) Definition of wamp: http://en.wikipedia.org/wiki/WAMP
try zend_extension**_ts**=...
and the in a console fire php -m to see whats in. No need to restart server
I "solved" the problem by updating from 5.3.6 to 5.3.8. I dont know where the problem was, but update and it will work fine. (I used http://xdebug.org/find-binary.php)

Categories