I have to confess I messed up, I installed the wrong version of Memcached for PHP on my OSX 10.8.5 machine. Basically I used
brew install php54-memcached
After using brew install memcached. My apache won't start up and then I realised I have PHP5.5 ... :(
UPDATE: I tried to remove php 5.4 which I think brew has installed as a dependancy which is causing a conflict. I did sudo rm -rf /usr/local/etc/php/5.4/
Restarted Apache but no cigar.
Any help would be appreciated I tried brew rm php54-memcached but obviously this was no help.
Thanks,
Stefan
Try using:
brew uninstall php54-memcached --force
More tips here.
Ok after hours of digging I think I found it...
Basically Brew had installed 5.4 alongside but changed something in 5.5, it might even have been the self installed PHP (not brew). When I switched the module in the http.conf to point to the 5.4 installation libphp5.so it worked and then when I switched it to the apparent 5.5 version it failed again.
So I just unlinked both and cleared it via homebrew and then effectively reinstalled PHP5.5 via homebrew.
Ideally the php.ini that is used by the Brew installation is the same as the one I was using before so that was nice when I got it back up and running.
I double checked to see if I needed to remove any old files. I only needed to remove the old 5.5 version folder.
One thing to that baffles me though is that when I went into http.conf to change the PHP module link I'm pretty sure it wasn't linking to the Brew version of my PHP5.5 installation but instead to "/usr/libexec/apache2/libphp5.so". This would suggest I was never using the brew version... I'm so confused.
Perhaps when I installed php5.4 by accident it change the bash path... either way everything looks in shape just now so fingers crossed.
Some points to help others:
I followed this to make sure I set it up right
I made sure to link http.conf to the Brew install libphp5.so
I made sure my LaunchAgents plist was the right one
I made sure to update the $PATH (no idea what that really does and welcome any explanations - I've always wondered)
I realise this is terribly formatted and a rambling, but I'm exhausted :)
Related
I'm trying to set up my linux environment to use PHP for my job. I'll spare you most of the details, but one extension I need is ImageMagick. I'm using Homebrew to help me install stuff. I'm using PHP 7.4. The commands I've run based on what I've read are as follows:
brew install php#7.4
brew install imagemagick
pecl install imagcik
However, when running the last command, I get this error, saying pcre2.h not found:
error image
I've done a lot of googling and haven't been able to find anything that helps with this specific issue. I don't know what I'm doing wrong. Everything is currently done through homebrew, but if it helps my linux distro is OpenSUSE Tumbleweed. Thanks!
Assuming that you did install pcre2 (if you didn't, run the command below and try again).
$ brew install pcre2
If that does not work, the issue is probably that the file exists, but in the wrong spot. A quick Google search shows that creating a symlink can resolve this issue.
$ ln -s <path to package> /home/linuxbrew/.linuxbrew/Cellar/php#7.4/7.4.27/include/php/ext/pcre/pcre2.h
If you're unsure where the package is currently installed. You should be able to find it with this command.
$ brew info pcre2
This is something i've met while trying to install PHP-GMP extension.
What i was trying to do is:
Downloaded gmp with brew using brew install autoconf gmp
Downloaded PHP (i'm using version 7.3.24) from source to extract the GMP extension
Copied Gmp directory to /Applications/MAMP/bin/php/php7.3.24/include/php/ext
Entered that dir and launched phpize
Launched `./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.24/bin/php-config
As soon as i hit enter it starts doing it's stuff until it says:
configure: error: GNU MP Library version 4.2 or greater required.
Once i managed to solve this somehow but i really don't know how i did it. I can only remember of downloading the gmp .tar from the official website https://gmplib.org/#DOWNLOAD but then nothing works.
Let me say that i'm a total noob with those ./configure, make and make install stuff. I don't even know what is going on so all i did was random launching hoping something good could happen:
What i've tried after downloading the official .tar is entering the folder and go with:
./configure
make && make check && make install
I've also tried to do:
export CPPFLAGS="-I/usr/local/Cellar/gmp/include"
export LDFLAGS="-L/usr/local/Cellar/gmp/lib"
as suggested here but nothing changed. I even tried to add --prefix=/usr/local/Cellar to the ./configure command but no luck.
This all story is related to this other question of me where i was trying to go on with the issue when the ./configure was still working. Now it's like i went backwards.
Sidenote: i guess it all changed when i fired brew doctor, and brew cleanup. It must have destroyed something i made that brought me back to this state
Update 23/08/2022:
As i had to go throughout all over this again i think i have some more hint to give you for future reference, here's the list:
Install GMP via homebrew (if you have an old version of homebrew or you migrated datas between Intel Mac and M1 Mac then you need to UNINSTALL homebrew and INSTALL it all over again with all the libraries)
brew install autoconf gmp
Downloading php from source is necessary, so that you can grab the /ext/gmp directory and copy inside your current PHP version folder (for me it is currently Applications/MAMP/bin/php/php8.1.0/include/php/ext/)
You need to enter inside the gmp folder that you just copied inside Applications/MAMP/bin/php/php8.1.0/include/php/ext/gmp
The command i've launched that didn't give any errors about missing GMP was:
./configure
--with-php-config=/Applications/MAMP/bin/php/php8.1.0/bin/php-config CXXFLAGS="-I/opt/homebrew/Cellar/gmp/6.2.1_1/include
CPPFLAGS="-I/opt/homebrew/Cellar/gmp/6.2.1_1/include
LDFLAGS="-L/opt/homebrew/Cellar/gmp/6.2.1_1/lib"
launch make
launch make install
IMPORTANT NOTE: M1 is arm64 architecture and if you've installed brew correctly you should have a folder /opt/homebrew/Cellar/. Instead Intel is x86_64 and the brew folder was /usr/local/Cellar/
Old answer
Ok this was quicker then i thought but i should leave it here as a reference for everyone else which will hit the same issue.
TLDR;
You need to reinstall brew for the new architecture using this arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" and then install packages with this arch -x86_64 brew install <package>.
Credits to emonz
Long version answer:
This issue all starts with brew, i don't even know why it wasn't giving me hints about this issue until just today. When i launched brew install gmp it printed this error:
which lead me to this answer from emonz. After i finally reinstalled brew i could finally get the ./configure command to work using additional args:
./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.27/bin/php-config CC="gcc -arch x86_64" CXX="g++ -arch x86_64"
So basically it is all related to the new M1 chip i guess. I still don't know what i did in the past to solve this issue w/o upgrading brew to the new arch but somehow i did it. I'll leave the question and this answer more like a guide for future comers and give them hints of what they can try to solve the issue, i wish nobody go past this pain ever again.
it seems like a little bit stupid question, but Google for one hour and cannot find it:
How to install php on macOS via brew and use in in shell.
Install is simple (if you have brew already installed):
brew install php
But after installation, when i use php -v i still see default php on mac os and not the brew's one. Shoud I Add brew php binary into PATH, bash profile, or what?
Thank you!
homebrew creates symbolic links in /usr/local/bin to pretty much every binary it installs. So the answer to your question is to add that to your path in your login profile. That will probably be $HOME/.profile and you can add a line like:
export PATH=/usr/local/bin:$PATH
Then it will be set each time you login or open a new Terminal.
So in my case, the trouble was with some access permissions on specific folders on my Mac OS, so just sharing what I learned: if it's not working, carefully examile log / error feed, there can be a hint for you!
On April 1, 2018 Homebrew discontinued the Homebrew/php tap and went with a core install approach, which means many of the extensions now must be installed with PECL. I have written a two part blog series to help with installing Apache and PHP w/ PECL on later versions of MacOS. You can find it at the link below, I hope it helps!
https://medium.com/#crmcmullen/how-to-install-php-on-macos-10-13-high-sierra-and-10-14-mojave-using-homebrew-and-pecl-ef2276db3d62
Step 1: Install Homebrew
The first step is to install Homebrew and this is a tool (package manager for macOS) that will allow us to install easily PHP and basically any other package/tools.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install PHP
To install PHP we can use the command below. The first command will automatically install the latest version of PHP which is at the current moment of writing this post version 8.
brew install php
If other versions may be preferred we can specify the PHP version and the code will look like the following.
brew install php#7.4
Step 3: The php.ini Config
The default PHP configuration should be sufficient to get started but if there are any other configurations, we can change them through the php.ini located on this path. Do note the PHP version number which in this case is version 8.
/usr/local/etc/php/8.1/php.ini
Step 4: Check if PHP is running
To check if PHP is already running we can make use of the brew services command. First, we can list the services that we have installed.
brew services list
If PHP is not started we can then run the command below to start the service in the background.
brew services start php#8.1
Step 5: Checking PHP Version
Lastly to check the PHP version do run:
php -v
By now you will have PHP running on the background process and every time you logged in to the system it will start by default. Thanks for reading and have a good try.
I used Pear to install PHP CodeSniffer, and something went terribly wrong. It seems like most of the files weren't copied over. Perhaps I should have installed it with root privileges. It doesn't work, it's a mess, and I want to uninstall it and reinstall it, but I don't know how to uninstall it and I can't find any information about this. The Pear script is long and complicated. I tried:
pear uninstall PHP_CodeSniffer-3.2.3
It says that it's not installed.
But when I try to reinstall over the existing installation, it says I can't because it's already installed.
I found the answer. I'm posting it despite the -1 score I got for my question - up from -2. I'm sure I'm not the only one who had this problem, and it took hours of searching to find the solution. I'm not a pear expert. I only just installed it to use PHP_CodeSniffer.
The pear uninstall command didn't work because the cache needed to be cleared. These commands worked, when logged in as root. I then reinstalled as root.
pear clear-cache
pear uninstall PHP_CodeSniffer
I've installed php-cs-fixer via composer tonight.
But when testing again a php file I'm getting the following error:
[Symfony\Component\Process\Exception\RuntimeException]
The process has been signalled with signal "6".
I've tried removing it and re-installing it to the same effect.
Your help here would be greatly appreciated.
New to laravel PHP programming but enjoying it!
Worked it out guys/girls.
Was a version issue with php. Not sure how it happened as I'd installed php71 via homebrew but when doing.
php -v it was pointing to the pre-installed version of php on my mac.
PLUS I had a version of mampstack installed on my machine. I removed that.
Reinstalled php71 and did a
php -v
and sure enough, the correct version of php is now running.
The php-cs-fixer is now working as expected.
This was question was my first post to stack overflow :-)
Looking forward to contributing more!
Take care.
You need updates or install some dependencies as follows:
$brew install svn
$brew link --overwrite subversion