Mac OS Mojave downgrade PHP 7.3 to 7.2.14 - apache

I have installed PHP 7.2.14 with brew.
brew install php#7.2
On CLI I have already the 7.2.14 version, but not on Apache.
What should I do, so I can remove 7.3 from my Mac and use only 7.2.14

you need to run
brew link php#7.2
To force the link and overwrite all conflicting files:
brew link --overwrite php#7.2
To list all files that would be deleted:
brew link --overwrite --dry-run php#7.2

The PHP version in your CLI has nothing to do with the version you have on your Apache module.
You need to disable/enable the right modules in apache in order for the right php version to take affect.
For enabling/disabling a mod, you have this nice helper commands:
a2enmod <MOD_NAME> // Enable a mod
a2dismod <MOD_NAME> // Disable a mod
This one is not tested, but you should be able to do:
a2dismod php7.3
a2enmod php7.2
P.S
Not sure the apache helper commands are available in mac so you can do it directly through the httpd.conf file.
checkout /etc/apache2/httpd.conf and make sure the right modules are loaded.
Hope it helps.
Good luck :)

Related

Homebrew PHP Install Breaks Apache 2.4

When I recently installed PHP56 via Homebrew, Apache would no longer start, with this error in the logs:
Cannot load /usr/local/opt/php56/libexec/apache2/libphp5.so into server: dlopen(/usr/local/opt/php56/libexec/apache2/libphp5.so, 10): image not found
Note: I'm running Apache 2.4 on Mac El-Capitan.
How can I resolve this error and get Apache running again?
I've seen this before. If you brew options php56, it says:
With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system
you have to install php with the --with-apache option. See brew options php56 for more details.
Thus, try uninstalling (brew uninstall php56) then reinstalling php56 with the flag --with-apache for Apache v2.4.x (--with-apache22 for Apache 2.2). Generally, you can check your Apache version by typing in command line: httpd -v.
My version is 2.4.18, so I would brew install php56 --with-apache, which creates the proper file path /usr/local/opt/php56/libexec/apache2/libphp5.so.
Now, it is properly compiled with Apache Handler module.
IMPORTANT: installing php56 with this option appears to also install httpd24. From a brew program stance, this makes sense. However, this may break your server set up. If you don't want to use brew's Apache install, do a brew unlink httpd24 after this.
To see additional brew build options, try brew options php56.

Set php7 location to Apache (Macports)

I've installed php7 via MacPorts to the El Capitan using this tutorial.
Is it possible to execute php7 with default OSX Apache (not Apache from MacPorts)? If yes, where should I set php7 location in Apache?
MacPorts will build all modules only for the Apache httpd provided by MacPorts itself and not for the system version.
See the notes for the php70-apache2handler port how you can enable the module:
$ port notes php70-apache2handler
php70-apache2handler has the following notes:
If this is your first install, you need to enable php70-apache2handler in your web server.
To enable php70-apache2handler, run:
cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n php7 mod_php70.so
If someone had the same problem, this tutorial helped to solve my problem.

Laravel valet linked php error

I got an error.
$ valet install
[DomainException]
Unable to determine linked PHP.
install
'which' command returns:
$ which php
/usr/local/Cellar/php70/7.0.6/bin/php
I used Homebrew to instal php7.1 , So I ran this command in terminal
ln -s /usr/local/opt/php71/bin/php /usr/local/bin/php
and everything is done.
if your PHP version 7.x and valet > 2.0.8 update valet
valet stop
valet uninstall
brew install php
composer global require laravel/valet
then valet install
Homebrew creates (or attempts to create) symlinks in /usr/local/bin.
Start by running the following to attempt to create a link.
brew link php70
It'll give you information as to whether or not it was successful. Occasionally permissions are problematic and you can resolve this with
sudo chown -R `whoami`:admin /usr/local/bin
Then try running the brew link command again.
Alternately brew link may give you instructions, or you can use brew doctor to get a report on any problems which exist with your Homebrew installation.
When it's set up properly after running ls -la /usr/local/bin | grep bin/php$ you should see something similar to
lrwxr-xr-x 1 YOURUSER admin 29 10 May 21:40 php -> /usr/local/Cellar/php70/7.0.6/bin/php
I was going to update Laravel Valet from version 1.* to 2 and ran same error like this
Unable to determine linked PHP
The solution was to run
composer global update
before I ran
valet install
This happens when your brew php gets Updated.
If you do brew install php this will work but will install php 7.2 by default.
If you want php#7.1 you have to do brew install php#7.1 this will install php7.1 and now when you restart valet valet restart you might get an error. Unable to determine linked PHP.
To make this work with php7.1 you have make brew link
brew link php71
you may have this error
Warning: php#7.1 is keg-only and must be linked with
to fix this
brew link --force php71
now valet should work on php7.1
I tried all of the suggestions here—and several from elsewhere—before I hit on the solution. This applies to PHP 7.2 (no guarantee for other versions). If you are using the original Larvel Valet, open the file:
~/.composer/vendor/laravel/valet/cli/Valet/Brew.php
...or, if you're using Valet+
~/.composer/vendor/weprovide/valet-plus/cli/Valet/Brew.php
Locate the supportedPhpVersions method. In some versions, it will return an array right in the method:
return ['php72', 'php71', 'php70', 'php56'];
Change this to:
return ['7.2', 'php72', 'php71', 'php70', 'php56'];
In other cases, it'll reference const SUPPORTED_PHP_VERSIONS, and the change will be similar.
Save the file, restart valet, and Bob's your uncle!

Not able to install mod_perl module on the server

In my site I am getting an error : an error occurred while processing this directive
It was working fine before moving to the new server. So when I checked I found that mod_perl module is missing. So I tried to install it by downloading the module to the server and then tried to run using Perl Makefile.pl but it was asking for apache src and I was not able to find it. I can see /usr/bin/apache/ folder but no source file inside the folder.
So I tried to install the module from Cpanel but I got the following error:
The C compiler is not functional and auto repair failed. Perl module installs require a working C compiler. Please repair the C compiler and try again.
Please let me know how to install it as I have tried most of the cases searching the net.
Thanks in advance
It's probably best to use your distro's packaging system to install mod_perl, especially, if apache is installed from a package too.
Yum based systems:
yum install mod_perl
Deb based systems
apt-get install mod_perl
you may need to enable the module using a2enmod
Mostly gcc is either corrupted or not present on your system. Please try to re/install gcc on your system
sudo apt-get update
sudo apt-get install build-essential
On Redhat:
yum update
yum install devtoolset-2-toolchain
It seems like a problem with your installation of gcc. You're using CloudLinux, so you should use yum to reinstall gcc.
$ sudo -i yum install gcc
But you don't need gcc if you install the pre-build packages.
$ sudo -i yum install mod_perl
Either way, you're going to need to get to grips with package installation for your system - and for that you're going to need root access.

How can I get mod_wsgi working on Mac?

I have been trying to install the latest version of mod_wsgi (3.3) since hours on my Mac. I'm on Snow Leopard and I have the versions of Apache (Apache/2.2.15) and Python 2.6.1 (r261:67515) that come with the system.
I downloaded mod_wsgi-3.3.tar.gz from http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-3.3.tar.gz
Extracted the file and executed the following through terminal:
./configure
make
sudo make install
I added LoadModule wsgi_module modules/mod_wsgi.so to my httpd.conf.
Restarted Apache by disabling and enabling Web Sharing from the control panel.
localhost stops working until I remove the line I added httpd.conf :(
Please help. Thanks in advance.
I use the homebrew installed version of mod_wsgi. That gives me a universal version of mod_wsgi that works with the vanilla apache.
➔ file `brew list mod_wsgi`
/usr/local/Cellar/mod_wsgi/3.2/libexec/mod_wsgi.so: Mach-O universal binary with 2 architectures
/usr/local/Cellar/mod_wsgi/3.2/libexec/mod_wsgi.so (for architecture x86_64): Mach-O 64-bit bundle x86_64
/usr/local/Cellar/mod_wsgi/3.2/libexec/mod_wsgi.so (for architecture i386): Mach-O bundle i386
The problem you had was the path to mod_wsgi.so. On OS X the appropriate line is
LoadModule wsgi_module libexec/apache2/mod_wsgi.so
With the latest Mac OS and most recent HomeBrew, the package isn't available on HomeBrew.
However, if you have Python3 and Pip3 installed and configured on your Mac, you can load the package using:
pip3 install mod_wsgi
I had to first run the below command to get mod_wsgi installed
brew tap homebrew/apache
And then run
brew install mod_wsgi
On OS X 10.8 Mountain Lion, brew install mod_wsgi fails. This answer on stackexchange suggests the location of the XCode toolchain has changed. It fixed my problem and hopefully helps other people who end up here on 10.8 trying to install mod_wsgi.
I also encountered this error but I didn't want to use brew.
In my case the cause of the problem was in misconfiguration of python framework used for mod_wsgi that can be checked by
otool -L /usr/libexec/apache2/mod_wsgi.so
In my case it pointed to Python 2.7 framework while I was using Python 3.3 and my
python -> /usr/bin/python
also pointed to python 3.3 version.
In order to fix this, I removed already installed /usr/libexec/apache2/mod_wsgi.so .
Then reconfigured mod_wsgi with command:
./configure --with-python=/usr/bin/python --disable-framework
sudo make
sudo make install
This should work fine.
But in my case after executing make command I've got a warning about non existing Python framework folder. So I checked what was the real path of my Python framework folder and replaced it in the Makefile under LDFLAGS.
Changed from:
-L/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config
to
-L/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config-3.3m
Good way to check the Apache modules if it doesn't work, is:
apachectl -M
If some module causes the error, it will print it.
The below solution works for me for MacOS BigSur and Monterey:
Install MacPorts from https://www.macports.org/install.php
sudo port install mod_wsgi --> installs apache2, python3 among other things
apachectl location after install: /opt/local/sbin/apachectl
apache2 modules location: /opt/local/lib/apache2/modules/
httpd config location: /opt/local/etc/apache2/httpd.conf
Add this line to httpd.conf: LoadModule wsgi_module lib/apache2/modules/mod_wsgi.so
I wrote two tutorials about how to install Apache + MySQL + Python in Mac OS and Windows.
Maybe you can take a look.
[Tutorial] install Apache + MySQL + Python on Mac OS
http://fstoke.me/blog/?p=3583
[Tutorial] install Apache + MySQL + Python on Windows
http://fstoke.me/blog/?p=3600
Mac OS X comes with apache 2, to install mod_wsgi just install homebrew and run the following command.
*brew install homebrew/apache/mod_wsgi*
go to apache2/modules/ and search for mod_wsgi.so
after this goto apache2/conf/ and do
*sudo vim http.conf*
and add the following line
LoadModule wsgi_module modules/mod_wsgi.so
I was having trouble getting mod_wsgi to work as well even using different peoples advice and it wasn't working, so I finally used this website: https://pypi.python.org/pypi/mod_wsgi
Downloaded the mod_wsgi 4.5.15 file
Opened the file in a location I liked
Went to folder location in terminal
Did python3 setup.py install (or python if you're using a different version)
I have a MacBook Pro Version 10.12.5 in case this helps anyone.