amazonlinux / amazon-linux-2023

Amazon Linux 2023
https://aws.amazon.com/linux/amazon-linux-2023/
Other
538 stars 40 forks source link

[Package Request] - php-pecl-redis #328

Open arayutw opened 1 year ago

arayutw commented 1 year ago

What package is missing from Amazon Linux 2023? Please describe and include package name. php-pecl-redis It would be even better to have all the php-pecl packages. We need this package to connect with our Redis ElasticCache Instances.

Is this an update to existing package or new package request?

Is this package available in Amazon Linux 2? If it is available via external sources such as EPEL, please specify. Yes.

Any additional information you'd like to include. (use-cases, etc) If there is another way to use SESSION with Elasticache in php, no problem.

aran112000 commented 1 year ago

Any news on support for pecl / phpredis being added? Was initially raised a year ago under: https://github.com/amazonlinux/amazon-linux-2023/issues/121

limmike commented 1 year ago

Install php-redis including serializer and compression support in my LAMP stack CloudFormation userdata as follows

dnf install -q -y php-cli php-fpm php-devel php-pear gcc
pear update-channels
pecl update-channels

/usr/bin/yes 'no' | pecl install igbinary
echo 'extension=igbinary.so' > /etc/php.d/30-igbinary.ini

/usr/bin/yes 'no' | pecl install msgpack
echo 'extension=msgpack.so' > /etc/php.d/30-msgpack.ini

dnf install -q -y libzstd-devel
/usr/bin/yes 'no' | pecl install zstd
echo 'extension=zstd.so' > /etc/php.d/40-zstd.ini

/usr/bin/yes 'no' | pecl install --configureoptions 'enable-lzf-better-compression="no"' lzf
echo 'extension=lzf.so' > /etc/php.d/40-lzf.ini

dnf install -q -y redis6-devel lz4-devel
/usr/bin/yes 'no' | pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-lzf="yes" enable-redis-zstd="yes" enable-redis-msgpack="yes" enable-redis-lz4="yes" with-liblz4="yes"' redis
echo 'extension=redis.so' > /etc/php.d/41-redis.ini

systemctl restart php-fpm

Note: run the above commands as root. phpinfo output as below image

Was able to use this as Moodle 4.2.2 session handler with igbinary serializer and zstd compression

Edit: the above use liblz4 and do not require php-lz4. If you want to compile php-lz4 which can be used by php-apcu

              # php-lz4: https://github.com/kjdev/php-ext-lz4
                dnf install -q -y git lz4-devel
                git clone --recursive --depth=1 https://github.com/kjdev/php-ext-lz4.git
                cd php-ext-lz4
                phpize
                ./configure --with-lz4-includedir=/usr
                make
                make install
                echo 'extension=lz4.so' > /etc/php.d/40-lz4.ini
katzueno commented 10 months ago

I want php-pecl-redis support, too!

I ended up compiling from the source code by myself

# Install php-devel, gcc, make and git
sudo dnf install php8.2-devel gcc make git
# Git clone phpredis repo
cd
git clone https://github.com/phpredis/phpredis.git
cd phpredis
# Checkout the latest stable version of 6.0.2
git checkout tags/6.0.2
# Run phpize
phpize
# Run configure
./configure
# Run compile
make && sudo make install
# Adding extention to PHP config
sudo echo "extension = redis.so" >  /etc/php.d/50-redis.ini

But I think it should include in Amazon repo because of ElastiCache!

andyexeter commented 2 months ago

Would be great to get this as an installable package. We currently install it using pickle which is a bit easier than compiling from source:

# .platform/hooks/prebuild/10_install_redis.sh

if ! [ -f /bin/pickle ]; then
  wget https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar -O /bin/pickle
  chmod +x /bin/pickle
fi

if ! php -r 'exit(extension_loaded("redis") ? 0 : 1);'; then
  pickle install redis --no-interaction --no-ansi
  echo 'extension=redis.so' > /etc/php.d/50-redis.ini
fi