I had noticed that an application I have setup on heroku only shows sessions variables on random requests when I refresh the browser. I put this down to the fact the application is running on 5 dynos.
I followed the following tutorial to solve this with memcached using memcachedcloud.
https://devcenter.heroku.com/articles/php-sessions#storing-sessions-in-memcached
The issue still remains though. I am using the PHP slim framework, is there any further config I need for this? I cant seem to find anything in the slim docs.
EDIT:
I can not produce the required composer.lock file because when running.
composer update
I get the error
The requested PHP extension ext-memcached * is missing from your system.
But it is in fact installed. I can see the version from typing.
memcached -h
But it is not present when typing
composer show --platform
Depending on what platform you're running, you have to make sure you that composer updates. Even if you have memcached installed, it has to match your PHP version. Then, once installed, run composer update
For example:
If you have PHP5.6.15, get memcached with, either, brew install php56/memcached or sudo apt-get install php56/memcached.
Then run composer update.
If you have an issue installing composer on Mac, you have to enable rootless install. More info can be found here:
https://donatstudios.com/OS-X-Mavericks-Memcached-PHP-Extension-Installation
The gist of the steps to take are:
Restart computer and hold Command + R to get into recover mode
Get into the terminal from Utilities
Run csrutil disable and restart
This should be done prior to installing memcached from Homebrew.
Hope this helps.
I had a similar issue, where I was getting the same "ext-memcached * is missing" error and could not see ext-memcached when running composer show --platform.
I noticed that when I originally installed memcached, homebrew showed me various alternatives. So on Mac OSX El Capitan, I ended up installing the one that matched my PHP version:
brew install homebrew/php/php55-memcached
And then I had to add it to php.ini:
extension=/usr/local/Cellar/php55-memcached/2.2.0/memcached.so
You can get the correct version path with:
brew info php55-memcached
And then I restarted Apache:
sudo apachectl restart
It finally showed up in the composer list and I was able to update composer without error.
Related
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!
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?
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]
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 want to delete PHP 7.2.7 in ubuntu I used:
apt-get purge php7.2.*
I get like around 50 I guess from these message:
Note, selecting 'php7.2-sybase' instead of 'php7.2-pdo-dblib'
Package 'libapache2-mod-php7.2' is not installed, so not removed
However when I want to install magento on the server it says at readiness check:
PHP Version Check
Your PHP version is 7.2.7. The required PHP version is 7.0.2|7.0.4|~7.0.6|~7.1.0. Hide detail
Download and install PHP from www.php.net using this PHP Documentation.
For additional assistance, contact your hosting provider.
I deleted it but there were some errors because of file permissions now I changed it. but I think some remaining files stayed behind.
How can I get rid of them?
try to use sudo command:
sudo apt-get purge php7.2.*
I am trying to set up a web server to host Moodle on and I've been running into problems when trying to install PHP7.
I am currently using VirtualBox to host CentOS 7.4. By default, CentOS comes packaged with PHP 5.4.16. Now, from what I have read, the options for upgrading and installing from scratch are different. I have tried to follow multiple sites that guide towards getting PHP7 but have had no luck. The majority of guides tell you to install two repositories, Remi and EPEL. The main problem I have is that every time I install epel, yum either breaks or prevents me from installing another package.
[root#localhost ~]# yum update
Loaded plugins: fastestmirror, langpacks
Could not retrieve mirrorlist http://mirrorlist.centos.org/?
release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
I have tried many ways of fixing this. Some of the main ways are:
yum clean all
yum --enablerepo=base clean metadata
rm -rf /var/cache/yum
I did get around this once or twice by using
yum --enablerepo=epel clean metadata
and also
sed -i "s/mirrorlist=https/mirrorlist=http/" /etc/yum.repos.d/epel.repo
I know there are more ways that I have tried, but I cannot remember all of them. Moral of the story is that they don't usually help. Sometimes yum works fine and I will run yum clean all, and it stops functioning again.
Method 2:
Another method I tried was installing the rpm packages from their respective websites. I used WinSCP to transfer the files to my VM and then used yum to install them. Everything works well and I got epel and remi to install. But then yum doesn't work properly.
Sometimes it will install packages, but some will not install. I've set the yum timeout value higher and other packages get through, but some still do not. Then I clean up the yum cache and once again I see the message with five options.
Method 3:
I found documentation on installing PHP 7 from https://wiki.centos.org/HowTos/php7 and I thought it must work because this is the supported way.
I followed along right up until the first part.
root # centos7-vm: ~ # yum -y install centos-release-scl.noarch
I will either get the error message stating the package could not be downloaded from a mirror or if yum is already giving me issues, it will show the five options to clean yum.
Method 4:
Building PHP from source was another option I attempted. I navigated to http://php.net/downloads.php and downloaded the tarball and used WinSCP to get it on my machine.
I extracted the files and then navigated into the php directory.
I attempted to get things going by using ./configure, but it stated I needed gcc.
I tried to install gcc with yum install gcc, but could not install all of the packages.
I made a new VM and instantly tried installing gcc, but still not luck.
Summary
Sometimes I understand why yum does not work, other times I'm slamming my head on my desk.
Is there a standardized method of getting PHP 7 on CentOS? Can anyone link an accurate guide?
What is the reason that CentOS comes packaged with PHP 5.4 and not 7?
I feel like I have tried almost everything, but I know there is some webpage that I just haven't found yet. I think I did about all the research I possibly could for today.
I'm sure my question is probably not structured the best and might be a little confusing, but I've been working on this for about 6-7 hours now.
This is my first post, so I apologize if it is not perfect.
in my vps, I just added remi repo,
$ wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
$ rpm -Uvh remi-release-7.rpm
or
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
then you enable on /etc/yum.repos.d/ on remi.repo, and remi-php72.repo files.
later you update, and install php and its libraries.
epel is not necesary, but is in the official repo. you just got to do a
$ yum install epel-release
and enable the file in /etc/yum.repos.d/
have you check some logs files? to see if there's any errors
I changed my default apache server setup on my mac to be able of easily switching between php versions following this guide.
Now, when I return to my project which is based on the CMS TYPO3, I get the error, that "The PHP extension "apcu" must be installed and loaded in order to use the APCu backend.".
So I was following the tutorial (by the same author) to install and enable apcu.
I can sum up the installation process:
$ sphp 5.6
$ brew install autoconf
$ pecl channel-update pecl.php.net
$ pecl install apcu-4.0.11
This actually worked perfectly for php 5.6! But I wanted php 7.2 for my project. The tutorial instructs to do this:
$ sphp 7.2
$ pecl uninstall -r apcu
$ pecl install apcu
No errors here. But the CMS still claims no apcu! Searching for "apc" in phpinfo also returns in no results! Pecl added the extension="apcu.so" line in the loaded php 7.2 ini, so I don't understand what's wrong. Of course I restarted apache every time. Also no errors or warnings here.
Also after googling I have no idea what to do :/
You may try using an absolute path of the apcu.so in php.ini,
Like
extension="/usr/local/Cellar/php/7.3.2/pecl/20180731/apcu.so"
The path depends. Don't know why but this works for me anyway.
You may also need to check the following ini config entry for apcu:
apc.enabled=on
apc.enable_cli=on