Last active
May 3, 2021 14:46
-
-
Save memoryleak/94648a93c0132fc72b2d7fa11bd26c3f to your computer and use it in GitHub Desktop.
Compile PHP on Fedora (7.3, 7.4, 8.0)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
./configure \ | |
--prefix=/usr/local/php/7.3 \ | |
--bindir=/usr/local/bin \ | |
--sbindir=/usr/local/sbin \ | |
--libexecdir=/usr/local/libexec/php/7.3 \ | |
--sysconfdir=/usr/local/etc/php/7.3 \ | |
--sharedstatedir=/usr/local/com/php/7.3 \ | |
--localstatedir=/usr/local/var/php/7.3 \ | |
--libdir=/usr/local/lib/php/7.3 \ | |
--includedir=/usr/local/include/php/7.3 \ | |
--datarootdir=/usr/local/share/php/7.3 \ | |
--with-config-file-path=/usr/local/etc/php/7.3/php.ini \ | |
--with-config-file-scan-dir=/usr/local/etc/php/7.3/conf.d \ | |
--program-suffix=73 \ | |
--enable-bcmath \ | |
--enable-calendar \ | |
--enable-exif \ | |
--enable-fpm \ | |
--enable-intl \ | |
--enable-mbstring \ | |
--enable-mysqlnd \ | |
--enable-pcntl \ | |
--enable-soap \ | |
--enable-sockets \ | |
--with-bz2 \ | |
--with-curl \ | |
--with-enchant \ | |
--with-fpm-group=php \ | |
--with-fpm-systemd \ | |
--with-fpm-user=php \ | |
--with-gd \ | |
--with-gettext \ | |
--with-gmp \ | |
--with-kerberos \ | |
--with-mhash \ | |
--with-mysqli \ | |
--with-openssl \ | |
--with-pcre-regex \ | |
--with-pdo-mysql \ | |
--with-pdo-pgsql \ | |
--with-pear \ | |
--with-pgsql \ | |
--with-readline \ | |
--with-recode \ | |
--with-sodium \ | |
--with-xmlrpc \ | |
--with-xsl \ | |
--with-zlib | |
make clean | |
make -j | |
sudo make install | |
sudo cp php.ini-* /usr/local/etc/php/7.3/ | |
sudo cp php.ini-development /usr/local/etc/php/7.3/php.ini | |
sed -i sapi/fpm/www.conf -e 's/127.0.0.1:9000/\/usr\/local\/var\/php\/7.3\/run\/php-fpm73.sock/g' | |
sudo cp sapi/fpm/www.conf /usr/local/etc/php/7.3/php-fpm.d/ | |
sed -i sapi/fpm/php-fpm.service -e 's/php-fpm /php-fpm73 /g' | |
sed -i sapi/fpm/php-fpm.service -e 's/ProtectSystem=full/ProtectSystem=false/g' | |
sudo cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm73.service | |
sudo chown -R php:php /usr/local/var/php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
make clean | |
./configure \ | |
--prefix=/usr/local/php/7.4 \ | |
--bindir=/usr/local/bin \ | |
--sbindir=/usr/local/sbin \ | |
--libexecdir=/usr/local/libexec/php/7.4 \ | |
--sysconfdir=/usr/local/etc/php/7.4 \ | |
--sharedstatedir=/usr/local/com/php/7.4 \ | |
--localstatedir=/usr/local/var/php/7.4 \ | |
--libdir=/usr/local/lib/php/7.4 \ | |
--includedir=/usr/local/include/php/7.4 \ | |
--datarootdir=/usr/local/share/php/7.4 \ | |
--with-config-file-path=/usr/local/etc/php/7.4/php.ini \ | |
--with-config-file-scan-dir=/usr/local/etc/php/7.4/conf.d \ | |
--program-suffix=74 \ | |
--enable-bcmath \ | |
--enable-calendar \ | |
--enable-exif \ | |
--enable-fpm \ | |
--enable-intl \ | |
--enable-mbstring \ | |
--enable-mysqlnd \ | |
--enable-pcntl \ | |
--enable-soap \ | |
--enable-sockets \ | |
--with-bz2 \ | |
--with-curl \ | |
--with-enchant \ | |
--with-fpm-group=php \ | |
--with-fpm-systemd \ | |
--with-fpm-user=php \ | |
--with-gettext \ | |
--with-gmp \ | |
--with-kerberos \ | |
--with-mhash \ | |
--with-mysqli \ | |
--with-openssl \ | |
--with-pdo-mysql \ | |
--with-pdo-pgsql \ | |
--with-pear \ | |
--with-pgsql \ | |
--with-readline \ | |
--with-sodium \ | |
--with-xmlrpc \ | |
--with-xsl \ | |
--with-zlib | |
make clean | |
make -j | |
sudo make install | |
sudo cp php.ini-* /usr/local/etc/php/7.4/ | |
sudo cp php.ini-development /usr/local/etc/php/7.4/php.ini | |
sed -i sapi/fpm/www.conf -e 's/127.0.0.1:9000/\/usr\/local\/var\/php\/7.4\/run\/php-fpm74.sock/g' | |
sudo cp sapi/fpm/www.conf /usr/local/etc/php/7.4/php-fpm.d/ | |
sed -i sapi/fpm/php-fpm.service -e 's/php-fpm /php-fpm74 /g' | |
sed -i sapi/fpm/php-fpm.service -e 's/ProtectSystem=full/ProtectSystem=false/g' | |
sudo cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm74.service | |
sudo chown -R php:php /usr/local/var/php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
make clean | |
./configure \ | |
--prefix=/usr/local/php/8.0 \ | |
--bindir=/usr/local/bin \ | |
--sbindir=/usr/local/sbin \ | |
--libexecdir=/usr/local/libexec/php/8.0 \ | |
--sysconfdir=/usr/local/etc/php/8.0 \ | |
--sharedstatedir=/usr/local/com/php/8.0 \ | |
--localstatedir=/usr/local/var/php/8.0 \ | |
--libdir=/usr/local/lib/php/8.0 \ | |
--includedir=/usr/local/include/php/8.0 \ | |
--datarootdir=/usr/local/share/php/8.0 \ | |
--with-config-file-path=/usr/local/etc/php/8.0/php.ini \ | |
--with-config-file-scan-dir=/usr/local/etc/php/8.0/conf.d \ | |
--program-suffix=80 \ | |
--enable-bcmath \ | |
--enable-calendar \ | |
--enable-exif \ | |
--enable-fpm \ | |
--enable-intl \ | |
--enable-mbstring \ | |
--enable-mysqlnd \ | |
--enable-pcntl \ | |
--enable-soap \ | |
--enable-sockets \ | |
--with-bz2 \ | |
--with-curl \ | |
--with-enchant \ | |
--with-fpm-group=php \ | |
--with-fpm-systemd \ | |
--with-fpm-user=php \ | |
--with-gettext \ | |
--with-gmp \ | |
--with-kerberos \ | |
--with-mhash \ | |
--with-mysqli \ | |
--with-openssl \ | |
--with-pdo-mysql \ | |
--with-pdo-pgsql \ | |
--with-pear \ | |
--with-pgsql \ | |
--with-readline \ | |
--with-sodium \ | |
--with-xsl \ | |
--with-zlib | |
make clean | |
make -j | |
sudo make install | |
sudo cp php.ini-* /usr/local/etc/php/8.0/ | |
sudo cp php.ini-development /usr/local/etc/php/8.0/php.ini | |
sed -i sapi/fpm/www.conf -e 's/127.0.0.1:9000/\/usr\/local\/var\/php\/8.0\/run\/php-fpm80.sock/g' | |
sudo cp sapi/fpm/www.conf /usr/local/etc/php/8.0/php-fpm.d/ | |
sed -i sapi/fpm/php-fpm.service -e 's/php-fpm /php-fpm80 /g' | |
sed -i sapi/fpm/php-fpm.service -e 's/ProtectSystem=full/ProtectSystem=false/g' | |
sudo cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm80.service | |
sudo chown -R php:php /usr/local/var/php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dnf groupinstall -y c-development | |
dnf install -y \ | |
systemd-devel \ | |
libxml2-devel \ | |
openssl-devel \ | |
bzip2-devel \ | |
curl-devel \ | |
enchant-devel \ | |
libwebp-devel \ | |
libjpeg-devel \ | |
libpng-devel \ | |
gmp-devel \ | |
libicu-devel \ | |
libpq-devel \ | |
readline-devel \ | |
recode-devel \ | |
libsodium-devel \ | |
libxslt-devel \ | |
krb5-devel \ | |
sqlite-devel \ | |
oniguruma-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PHP_73_VERSION="7.3.28" | |
PHP_74_VERSION="7.4.18" | |
PHP_80_VERSION="8.0.5" | |
echo "Clean up existing files..." | |
rm -rf src/ && mkdir -p src | |
# echo "Downloading $PHP_73_VERSION..." | |
# curl -s https://www.php.net/distributions/php-$PHP_73_VERSION.tar.xz -o php-$PHP_73_VERSION.tar.xz | |
# echo "Downloading $PHP_74_VERSION..." | |
# curl -s https://www.php.net/distributions/php-$PHP_74_VERSION.tar.xz -o php-$PHP_74_VERSION.tar.xz | |
echo "Downloading $PHP_80_VERSION..." | |
curl -s https://www.php.net/distributions/php-$PHP_80_VERSION.tar.xz -o php-$PHP_80_VERSION.tar.xz | |
# echo "Extracting $PHP_73_VERSION..." | |
# tar -xf php-$PHP_73_VERSION.tar.xz -C src/ && rm php-$PHP_73_VERSION.tar.xz | |
# echo "Extracting $PHP_74_VERSION..." | |
# tar -xf php-$PHP_74_VERSION.tar.xz -C src/ && rm php-$PHP_74_VERSION.tar.xz | |
echo "Extracting $PHP_80_VERSION..." | |
tar -xf php-$PHP_80_VERSION.tar.xz -C src/ && rm php-$PHP_80_VERSION.tar.xz | |
echo "Installing dependencies (using sudo)..." | |
sudo ./install-deps.sh | |
# echo "Installing $PHP_73_VERSION..." | |
# (cd "src/php-$PHP_73_VERSION" && ./../../install-7.3.sh) | |
# echo "Installing $PHP_74_VERSION..." | |
# (cd "src/php-$PHP_74_VERSION" && ./../../install-7.4.sh) | |
echo "Installing $PHP_80_VERSION..." | |
(cd "src/php-$PHP_80_VERSION" && ./../../install-8.0.sh) | |
echo "Install PHP version switcher (switch-php-version)..." | |
mkdir -p "$HOME/.local/bin" && cp switch-php-version.sh "$HOME/.local/bin/switch-php-version" | |
echo "Add PHP group and user" | |
sudo groupadd -r php | |
sudo useradd -r -g php php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PHP_VERSION="$1" | |
PHP_SUFFIX="${PHP_VERSION//[!0-9]/}" | |
PHP_EXECUTABLES="php php-cgi php-config phpdbg phpize" | |
if [ -z "$HOME" ]; then | |
echo "Could not parse home directory from \$HOME." | |
exit -2 | |
fi | |
if [ "$#" -ne 1 ]; then | |
echo "Please provide version, for example 7.3." | |
exit -1 | |
fi | |
if [[ ! -d "$HOME/.local/bin" ]] | |
then | |
mkdir -p $HOME/.local/bin | |
fi | |
for PHP_EXECUTABLE in $PHP_EXECUTABLES; do | |
ln -fsT "/usr/local/bin/php${PHP_SUFFIX}" "$HOME/.local/bin/$PHP_EXECUTABLE" | |
done | |
ls -las "$HOME/.local/bin/" | grep php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment