PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, November 12, 2022

[FIXED] How to load memcached on PHP in Mac OS X Catalina?

 November 12, 2022     macos, macos-catalina, memcached, php     No comments   

Issue

I have tried virtually everything I could for the last 3 hours. I just don't seem to get it to load on PHP. I was able to install it via brew install memcached and successfully make run it as a background service via memcached -d. But that's not really what I am looking for.

I am looking at loading it as one of my PHP modules. Running php -m on the terminal does not list memcached on it at all. Neither looking at phpinfo() or print_r(get_loaded_extensions()); on runtime gave me any luck. I am trying to officially access it in my project via something like extension_loaded('memcached'), of course, this returns a falsy value atm.

I have tried solutions like below:

How to install memcached module for php@7.1 on MacOS High Sierra?

https://donatstudios.com/OS-X-Mavericks-Memcached-PHP-Extension-Installation

Can I install the memcached PHP extension with PECL?

Most of the solutions are similar to the above linked. Unfortunately, this isn't working for me because of an issue similar to this:

Unable to use PHPIZE after update to MacOS Mojave

I also get below error when executing a make command:

make: *** No targets specified and no makefile found. Stop.

And the below error when running ./configure

checking for session includes... configure: error: Cannot find php_session.h

Meanwhile, I also cannot attempt an install via pecl install memcached due to the error below:

configuration download directory "/tmp/pear/install" is not writeable. Change download_dir config variable to a writeable dir to avoid this warning

Basically everything just doesn't work. And honestly, I didn't even know how to start writing this question, so I'm just kinda throwing everything in here.

It doesn't help that there are no recent discussions about installing memcached on PHP since Catalina. A lot of resources are just 5 years old and that's not a good sign, a number of them aren't even valid solutions anymore.

I am losing my mind. Why this thing is so complicated to configure is beyond my comprehension. If someone can point me in the right direction that would be great!


Solution

So I was able to find a solution after 2 working days. What you should do is move away from using built-in Apache/PHP from macOS and use the ones from Homebrew.

Here are the descriptive step-by-step procedure I did:

1) Unload the built-in Apache.

2) Install a new Apache from Homebrew via brew install httpd and then run the service

3) Install PHP via brew install php

4) Configure httpd.conf from /usr/local/etc/httpd/, including loading Homebrew PHP module, mod_rewrite, setting up DirectoryIndex, ServerName, default Listen port, etc.

4.1) If you are using virtual hosts, set this up on /usr/local/etc/httpd/extra/

5) Configure ~/.bash_profile to use the new PHP version (test via php -v or which php)

6) Install PEAR

7) Install memcached via PEAR


I have compiled a list of links that you can use:

Apache & PHP Installation

https://tecadmin.net/install-apache-macos-homebrew/

https://getgrav.org/blog/macos-catalina-apache-multiple-php-versions

https://gist.github.com/DragonBe/0faebe58deced34744953e3bf6afbec7

Follow brew info php to configure Homebrew PHP to Homebrew Apache

Configure bash profile to use homebrew php by default

PHP --version shown incorrectly on osX How to use the php that brew installed?

Install PEAR and configure

https://jasonmccreary.me/articles/install-pear-pecl-mac

Install memcached via PEAR

pecl install memcached then follow instructions

Or

How to install memcached module for php@7.1 on MacOS High Sierra?

https://donatstudios.com/OS-X-Mavericks-Memcached-PHP-Extension-Installation

Can I install the memcached PHP extension with PECL?



Answered By - Abana Clara
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing