Refactor PHP setup on linux

This commit is contained in:
Shivam Mathur 2020-03-28 11:25:48 +05:30
parent 3376371dd8
commit d90cd153ee
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -239,27 +239,23 @@ add_blackfire() {
setup_master() { setup_master() {
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
install_dir=~/php/"$version" install_dir=~/php/"$version"
bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file"
sudo mkdir -m 777 -p ~/php sudo mkdir -m 777 -p ~/php
update_ppa && $apt_install libicu-dev >/dev/null 2>&1 curl -o /tmp/"$tar_file" -sSL "$bintray_url"
curl -SLO https://dl.bintray.com/shivammathur/php/"$tar_file" >/dev/null 2>&1 sudo tar xf /tmp/"$tar_file" -C ~/php
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1
rm -rf "$tar_file"
sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/ sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/
sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
} }
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5 # Function to setup PHP 5.3, PHP 5.4 and PHP 5.5
setup_old_versions() { setup_old_versions() {
( dir=php-"$version"
cd /tmp || exit tar_file="$dir".tar.xz
curl -SLO https://dl.bintray.com/shivammathur/php/php-"$version".tar.xz >/dev/null 2>&1 bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file"
sudo tar xf php-"$version".tar.xz >/dev/null 2>&1 curl -o /tmp/"$tar_file" -sSL "$bintray_url"
cd php-"$version" || exit sudo tar xf /tmp/"$tar_file" -C /tmp
sudo chmod a+x ./*.sh sudo chmod a+x /tmp/"$dir"/*.sh
./install.sh >/dev/null 2>&1 (cd /tmp/"$dir" && ./install.sh && ./post-install.sh)
./post-install.sh >/dev/null 2>&1
)
sudo rm -rf /tmp/php-"$version"
configure_pecl configure_pecl
release_version=$(php -v | head -n 1 | cut -d' ' -f 2) release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
} }
@ -325,9 +321,9 @@ sudo mkdir -p /var/run /run/php
if [ "$existing_version" != "$version" ]; then if [ "$existing_version" != "$version" ]; then
if [ ! -e "/usr/bin/php$version" ]; then if [ ! -e "/usr/bin/php$version" ]; then
if [ "$version" = "8.0" ]; then if [ "$version" = "8.0" ]; then
setup_master setup_master >/dev/null 2>&1
elif [[ "$version" =~ $old_versions ]] || [ "$version" = "5.3" ]; then elif [[ "$version" =~ $old_versions ]] || [ "$version" = "5.3" ]; then
setup_old_versions setup_old_versions >/dev/null 2>&1
else else
update_ppa update_ppa
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1 $apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1