-
-
Save popovserhii/0f6dd84afcad503ba70d908fb4b299d3 to your computer and use it in GitHub Desktop.
Install libxl, php_excel extension on PHP7 (main interpretator) on CentOS7 (ondrej/ppa)
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 | |
# | |
# ilia/php_excel extension example install script for PHP7+ on CentOS 7+ as base interpreatator | |
# | |
# usage: | |
# > ./install_phpexcel_php7.sh | |
# > (optionally) sudo service php7.0-fpm restart) | |
# | |
# requirements: | |
# - Ubuntu 64bits (trusty/xenial) | |
# - sudo access | |
# - php7.0 from ondrej/php ppa | |
# - unzip, wget | |
# | |
# PHP7 install example : | |
# > sudo add-apt-repository -y ppa:ondrej/php; | |
# > sudo apt-get update; | |
# > sudo apt-get install php7.0 php7.0-dev php7.0-cli php7.0-xml php7.0-fpm php7.0-opcache php7.0-common | |
# | |
# (optionally) | |
# php7.0-bcmath php7.0-mbstring | |
# php7.0-pgsql php7.0-soap php7.0-zip php7.0-json php7.0-mysql php7.0-bz2 php7.0-curl | |
# php7.0-gmp php7.0-ldap php7.0-mcrypt php7.0-readline php7.0-sqlite3 | |
# php7.0-gd php7.0-intl php7.0-xmlrpc | |
# php-imagick php-memcached | |
# | |
TMP_DIR=/tmp | |
# Params for php extension php-excel | |
PHP_EXCEL_URL=https://github.com/iliaal/php_excel/archive/Excel-1.0.2-PHP7.zip | |
PHP_EXCEL_ARCHIVE_DIR=php_excel-Excel-1.0.2-PHP7 | |
# Johmue php7 branch (older) | |
#PHP_EXCEL_URL=https://github.com/johmue/php_excel/archive/php7.zip | |
#PHP_EXCEL_ARCHIVE_DIR=php_excel-php7 | |
# LibXL params | |
LIBXL_VERSION=3.6.5 | |
LIBXL_ARCHIVE_VERSION=3.6.5.0 | |
LIBXL_INSTALL_PATH="/opt/libxl-$LIBXL_VERSION" | |
LIBXL_URL="http://www.libxl.com/download" | |
LIBXL_ARCHIVE="libxl-lin-$LIBXL_VERSION.tar.gz" | |
# PHP params | |
PHP_VERSION=7.0 | |
PHP_CONFIG=`which php-config` | |
PHPIZE=`which phpize` | |
PHP_MODS_AVAILABLE_PATH=/etc/php.d | |
set -e | |
install_libxl() { | |
echo "Installing LIBXL v$LIBXL_VERSION" | |
wget -O $TMP_DIR/$LIBXL_ARCHIVE $LIBXL_URL/$LIBXL_ARCHIVE | |
tar zxvf $TMP_DIR/$LIBXL_ARCHIVE --directory $TMP_DIR | |
sudo mkdir -p $LIBXL_INSTALL_PATH | |
sudo cp -r $TMP_DIR/libxl-$LIBXL_ARCHIVE_VERSION/* $LIBXL_INSTALL_PATH | |
} | |
install_phpexcel_extension() { | |
echo "Download and compling PHP_EXCEL extension for libxl" | |
wget -O $TMP_DIR/php_excel.zip $PHP_EXCEL_URL | |
if [ -d $TMP_DIR/$PHP_EXCEL_ARCHIVE_DIR ]; then | |
# REMOVE eventual previous buils | |
rm -r $TMP_DIR/$PHP_EXCEL_ARCHIVE_DIR/* | |
fi | |
unzip -o $TMP_DIR/php_excel.zip -d $TMP_DIR | |
cd $TMP_DIR/$PHP_EXCEL_ARCHIVE_DIR/ | |
eval "$PHPIZE" | |
./configure --with-php-config=$PHP_CONFIG --with-libxl-incdir=$LIBXL_INSTALL_PATH/include_c/ --with-libxl-libdir=$LIBXL_INSTALL_PATH/lib64/ --with-excel=$LIBXL_INSTALL_PATH | |
make | |
#make test | |
echo "Installing php extension (need sudo)" | |
sudo make install | |
echo "Install succeed, please add extension=20-excel.ini in your php.ini" | |
} | |
register_php_extension() { | |
echo "Registering available extension in $PHP_MODS_AVAILABLE_PATH/20-excel.ini" | |
echo "extension=excel.so" > $TMP_DIR/excel.ini | |
sudo cp $TMP_DIR/excel.ini $PHP_MODS_AVAILABLE_PATH/20-excel.ini | |
} | |
install_libxl; | |
install_phpexcel_extension; | |
register_php_extension; | |
echo "Install successfull" | |
echo "Optionally you can restart your fpm daemon" | |
echo "to reflect changes:" | |
echo " sudo systemctl restart php-fpm"; |
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 | |
# | |
# ilia/php_excel extension example install script for PHP7+ on CentOS 7+ as base interpreatator | |
# | |
# usage: | |
# > ./install_phpexcel_php7.sh | |
# > (optionally) sudo service php7.0-fpm restart) | |
# | |
# requirements: | |
# - Ubuntu 64bits (trusty/xenial) | |
# - sudo access | |
# - php7.0 from ondrej/php ppa | |
# - unzip, wget | |
# | |
# PHP7 install example : | |
# > sudo add-apt-repository -y ppa:ondrej/php; | |
# > sudo apt-get update; | |
# > sudo apt-get install php-devel php-cli php-xml php-fpm php-opcache php-common | |
# | |
# (optionally) | |
# php7.0-bcmath php7.0-mbstring | |
# php7.0-pgsql php7.0-soap php7.0-zip php7.0-json php7.0-mysql php7.0-bz2 php7.0-curl | |
# php7.0-gmp php7.0-ldap php7.0-mcrypt php7.0-readline php7.0-sqlite3 | |
# php7.0-gd php7.0-intl php7.0-xmlrpc | |
# php-imagick php-memcached | |
# | |
TMP_DIR=/tmp | |
# Release 1.0.2 contains a bug regarding license | |
# see https://github.com/iliaal/php_excel/issues/163 | |
# So we use the master branch instead | |
# Once the release 1.0.3 is available, uncomment the two | |
# following lines and comment the master ones | |
#PHP_EXCEL_URL=https://github.com/iliaal/php_excel/archive/Excel-1.0.2-PHP7.zip | |
#PHP_EXCEL_ARCHIVE_DIR=php_excel-Excel-1.0.2-PHP7 | |
PHP_EXCEL_URL=https://github.com/iliaal/php_excel/archive/php7.zip | |
PHP_EXCEL_ARCHIVE_DIR=php_excel-php7 | |
# LibXL params | |
LIBXL_VERSION=3.8.0 | |
LIBXL_ARCHIVE_VERSION=3.8.0.0 | |
LIBXL_INSTALL_PATH="/opt/libxl-$LIBXL_VERSION" | |
LIBXL_URL="http://www.libxl.com/download" | |
LIBXL_ARCHIVE="libxl-lin-$LIBXL_VERSION.tar.gz" | |
# PHP params | |
PHP_VERSION=7.1 | |
PHP_CONFIG=`which php-config` | |
PHPIZE=`which phpize` | |
PHP_MODS_AVAILABLE_PATH=/etc/php.d | |
set -e | |
install_libxl() { | |
echo "Installing LIBXL v$LIBXL_VERSION" | |
wget -O $TMP_DIR/$LIBXL_ARCHIVE $LIBXL_URL/$LIBXL_ARCHIVE | |
tar zxvf $TMP_DIR/$LIBXL_ARCHIVE --directory $TMP_DIR | |
sudo mkdir -p $LIBXL_INSTALL_PATH | |
sudo cp -r $TMP_DIR/libxl-$LIBXL_ARCHIVE_VERSION/* $LIBXL_INSTALL_PATH | |
} | |
install_phpexcel_extension() { | |
echo "Download and compling PHP_EXCEL extension for libxl" | |
wget -O $TMP_DIR/php_excel.zip $PHP_EXCEL_URL | |
if [ -d $TMP_DIR/$PHP_EXCEL_ARCHIVE_DIR ]; then | |
# REMOVE eventual previous buils | |
rm -r $TMP_DIR/$PHP_EXCEL_ARCHIVE_DIR/* | |
fi | |
unzip -o $TMP_DIR/php_excel.zip -d $TMP_DIR | |
cd $TMP_DIR/$PHP_EXCEL_ARCHIVE_DIR/ | |
eval "$PHPIZE" | |
./configure --with-php-config=$PHP_CONFIG --with-libxl-incdir=$LIBXL_INSTALL_PATH/include_c/ --with-libxl-libdir=$LIBXL_INSTALL_PATH/lib64/ --with-excel=$LIBXL_INSTALL_PATH | |
make | |
#make test | |
echo "Installing php extension (need sudo)" | |
sudo make install | |
echo "Install succeed, please add extension=20-excel.ini in your php.ini" | |
} | |
register_php_extension() { | |
echo "Registering available extension in $PHP_MODS_AVAILABLE_PATH/20-excel.ini" | |
echo "extension=excel.so" > $TMP_DIR/excel.ini | |
sudo cp $TMP_DIR/excel.ini $PHP_MODS_AVAILABLE_PATH/20-excel.ini | |
} | |
install_libxl; | |
install_phpexcel_extension; | |
register_php_extension; | |
echo "Install successfull" | |
echo "Optionally you can restart your fpm daemon" | |
echo "to reflect changes:" | |
echo " sudo systemctl restart php-fpm"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment