Last active
October 15, 2020 01:55
-
-
Save lesstif/07e952f613c4d2ef4d4f990f3f252636 to your computer and use it in GitHub Desktop.
compile build script for standalone php 7 on RHEL CentOS Ubuntu
This file contains hidden or 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/sh | |
PHP_VER=7.3.21 | |
#PHP_VER=7.1.20 | |
FMT=.tar.xz | |
MAJOR=`echo ${PHP_VER}|awk -F. '{print $1}'` | |
MINOR=`echo ${PHP_VER}|awk -F. '{print $2}'` | |
### download latest | |
FILE=php-${PHP_VER}${FMT} | |
if [ ! -f ${FILE} ];then | |
curl -L -k -o ${FILE} http://us2.php.net/get/${FILE}/from/this/mirror | |
fi; | |
if [ ! -d php-${PHP_VER} ];then | |
tar xJvf ${FILE} | |
fi; | |
cd php-${PHP_VER} | |
### install dependency | |
if [ ! -f /etc/os-release ];then | |
echo "you need install redhat-release(RedHat) or centos-release(centOS) or base-files(Ubuntu) package."; | |
exit 1; | |
fi | |
# os-release file depends on centos-release package | |
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release) | |
## detect distro and install devel package | |
## See https://stackoverflow.com/questions/229551/how-to-check-if-a-string-contains-a-substring-in-bash | |
if [[ ${OS} == *"Red Hat"* || ${OS} == *"CentOS"* ]]; then | |
sudo yum install gcc gcc-c++ make ; | |
sudo yum install openssl-devel libcurl-devel zlib-devel libxml2-devel \ | |
libcurl-devel gd-devel libzip-devel bzip2-devel \ | |
libicu-devel; | |
elif [[ ${OS} == *"Ubuntu"* ]]; then | |
sudo apt update; | |
sudo apt install gcc g++ make pkg-config unzip; | |
sudo apt install libjpeg9-dev libpng-dev libzip-dev libgdchart-gd2-xpm-dev \ | |
libssl-dev libcurl4-openssl-dev zlib1g-dev libxml2-dev \ | |
libbz2-dev libicu-dev libfreetype6-dev libwebp-dev; | |
else | |
echo "Unknown OS ${OS}" | |
exit 1 | |
fi; | |
### configure | |
make distclean | |
./configure \ | |
--prefix=/usr/local/php-${PHP_VER} \ | |
--with-config-file-path=/usr/local/php-${PHP_VER}/etc \ | |
--with-config-file-scan-dir=/usr/local/php-${PHP_VER}/etc/php.d \ | |
--enable-cli \ | |
--enable-pdo \ | |
--enable-mbstring \ | |
--enable-mbregex \ | |
--enable-ftp \ | |
--enable-gd-native-ttf \ | |
--enable-sockets \ | |
--enable-fpm \ | |
--enable-intl \ | |
--enable-sysvsem \ | |
--enable-sysvshm \ | |
--enable-pcntl \ | |
--with-pdo-mysql \ | |
--with-curl \ | |
--with-zlib \ | |
--disable-rpath \ | |
--with-mhash \ | |
--enable-zip \ | |
--with-pcre-regex \ | |
--with-mysqli \ | |
--with-openssl \ | |
--with-fpm-user=nginx \ | |
--with-fpm-group=nginx \ | |
--with-iconv \ | |
--with-bz2 \ | |
--with-gd \ | |
--with-jpeg-dir=/usr/lib \ | |
--with-png-dir=/usr/lib \ | |
--with-webp-dir=/usr/lib \ | |
--enable-exif \ | |
--with-freetype \ | |
--with-xmlrpc \ | |
--with-libdir=lib64 \ | |
--with-password-argon2 | |
## build & install | |
make | |
sudo make install | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment