skip to Main Content

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 [email protected] 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!

2

Answers


  1. Chosen as BEST ANSWER

    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 [email protected] on MacOS High Sierra?

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

    Can I install the memcached PHP extension with PECL?


  2. why don’t you try vagrant box. You will get a virtual environment of your choice, install a ubuntu environment in minutes and you can get a LAMP or MEAN / MERN vagrant box ready made.

    Steps :

    1) Download and install virtualbox.
    2) Download and install Vagrant
    3) Go to terminal

    Check if vagrant is installed or not.

    vagrant -v

    In order to get a ubuntu box spinning up, run these commands.

    vagrant init ubuntu/trusty64

    It will download you a ubuntu box in minutes.

    vagrant up
    vagrant ssh

    Have a look at vagrant you will enjoy it.

    Also there are whole lot of ready to use boxes
    Vagrant boxes

    Documentation : [Vagrant Document]

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search