UPDATED-V2 : COMPILE AND BUILD APACHE2 AND PHP-FPM FROM SOURCE ON LINUX (PART 2)
Download or copy PHP.
Current Directory ~ src https://www.php.net/downloads.php wget https://www.php.net/distributions/php-7.3.27.tar.gz sudo gunzip php-7.3.27.tar.gz or gzip -d php-7.3.27.tar.gz tar -xvf php-7.3.27.tar.gz
First Install PHP dependencies
- CURL
- Libjpeg
- Libpng
- FreeType2
- Iconv
- GD (Optional)
- icu
- Tidy
- Libxml2
- GMP
- Openldap
- LibDb
- Cmake
- LibZip
Download and install Openssl if not installed already with Apache2
wget https://www.openssl.org/source/openssl-1.1.1.tar.gz ./configure --prefix=/app/system/opt/lib/openssl make && make install
For CURL
wget https://curl.se/download/curl-7.75.0.tar.gz tar -xvf curl-7.75.0.tar.gz cd curl-7.75.0 ./configure --prefix=/app/system/opt/lib/curl make && make install or make install PREFIX=/app/system/opt/lib/curl
GD jpeg/For Libjpeg
https://www.ijg.org/files/ wget https://www.ijg.org/files/jpegsrc.v9d.tar.gz tar -xvf jpegsrc.v9d.tar.gz cd jpeg-9d ./configure --prefix=/app/system/opt/lib/jpeg-9d make && make install
FOR Libpng
ftp://ftp.simplesystems.org/pub/libpng/png/src/ wget https://sourceforge.net/projects/libpng/files/libpng15/older-releases/1.5.15/libpng-1.5.15.tar.gz wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng15/libpng-1.5.30.tar.gz tar -xvf libpng-1.5.30.tar.gz cd libpng-1.5.30 export CPPFLAGS="-I/app/system/opt/lib/zlib/include" export LDFLAGS="-L/app/system/opt/lib/zlib/lib" ./configure --prefix=/app/system/opt/lib/libpng --disable-shared ./configure --prefix=/app/system/opt/lib/libpng --disable-static make && make install
For FreeType2 – 2.9
https://sourceforge.net/projects/freetype/files/freetype2/ wget https://sourceforge.net/projects/freetype/files/freetype2/2.9/freetype-2.9.tar.gz tar -xvf freetype-2.9.tar.gz cd freetype-2.9 ./configure --prefix=/app/system/opt/lib/freetype-2.9 make && make install
For Iconv
wget https://ftp.gnu.org/gnu/libiconv/libiconv-1.16.tar.gz tar -xvf libiconv-1.16.tar.gz cd libiconv-1.16 ./configure --prefix=/app/system/opt/lib/iconv make && make install
For GD (Optional)
wget https://github.com/libgd/libgd/releases/download/gd-2.3.1/libgd-2.3.1.tar.gz tar -xvf libgd-2.3.1.tar.gz cd libgd-2.3.1 ./configure --prefix=/app/system/opt/lib/libgd \ --with-libiconv-prefix=/app/system/opt/lib/iconv \ --with-zlib=/app/system/opt/lib/zlib \ --with-png=/app/system/opt/lib/libpng \ --with-freetype=/app/system/src/lib/freetype-2.10.4 \ --with-jpeg=/app/system/opt/lib/jpeg-9d
For icu
wget https://github.com/unicode-org/icu/releases/download/release-68-2/icu4c-68_2-src.tgz tar -xvf icu4c-68_2-src.tgz cd icu/source ./configure --prefix=/app/system/opt/lib/icu make && make install
For Tidy
wget https://github.com/downloads/petdance/tidyp/tidyp-1.04.tar.gz tar -xvf tidyp-1.04.tar.gz cd tidyp-1.04 ./configure --prefix=/app/system/opt/lib/tidyp make && make install
For Libxml2
ftp://xmlsoft.org/libxml2/ wget ftp://xmlsoft.org/libxml2/libxml2-2.9.10.tar.gz tar -xvf libxml2-2.9.10.tar.gz cd libxml2-2.9.10 ./configure --prefix=/app/system/opt/lib/libxml2 make && make install cmake .. -DCMAKE_INSTALL_PREFIX=/app/system/opt/lib/libxml2
For GMP
wget https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz tar -xvf gmp-6.2.1.tar.xz cd gmp-6.2.1 ./configure --prefix=/app/system/opt/lib/gmp make && make install
For Openldap
Ldap Client Only
Doc: http://www.linuxfromscratch.org/blfs/view/8.3/server/openldap.html ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/ wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.4.56.tgz tar -xvf openldap-2.4.56.tgz cd openldap-2.4.56 ./configure --prefix=/app/system/opt/lib/openldap \ --sysconfdir=/etc \ --disable-static \ --enable-dynamic \ --disable-debug \ --disable-slapd make depend make make install or ./configure --prefix=/app/system/opt/lib/openldap --disable-slapd --disable-slurpd make depend make make install
For LibDb -> for Openldap Dependencies
git clone https://github.com/berkeleydb/libdb.git cd libdb or http://www.linuxfromscratch.org/blfs/view/8.3/server/db.html wget http://anduin.linuxfromscratch.org/BLFS/bdb/db-5.3.28.tar.gz tar -xvf db-5.3.28.tar.gz cd db-5.3.28 ./dist/configure --prefix=/app/system/opt/lib/libdb \ --enable-compat185 \ --enable-dbm \ --disable-static \ --enable-cxx make && make install
For Cmake
wget https://cmake.org/files/v3.19/cmake-3.19.6-Linux-x86_64.tar.gz tar -xvf cmake-3.19.6-Linux-x86_64.tar.gz # save it in .bashrc if needed export PATH="`pwd`/cmake-3.19.6-Linux-x86_64/bin:$PATH" export PATH="/app/system/src/lib/cmake-3.19.6-Linux-x86_64/bin:$PATH" > which cmake /.../cmake-3.19.6/bin/cmake > which cmake-gui /.../cmake-3.19.6/bin/cmake-gui
For LibZip
https://libzip.org/download/ wget https://libzip.org/download/libzip-1.7.3.tar.gz tar -xvf libzip-1.7.3.tar.gz cd libzip-1.7.3 mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=/app/system/opt/lib/libzip \ -DBUILD_SHARED_LIBS=OFF \ -DZLIB_LIBRARY=/app/system/opt/lib/zlib/lib/libz.so \ -DZLIB_INCLUDE_DIR=/app/system/opt/lib/zlib/include make make test make install
Now Download and install PHP 7.3
Current Directory ~ src wget https://www.php.net/distributions/php-7.3.27.tar.gz tar -xvf php-7.3.27.tar.gz "./configure" \ "--enable-shared" \ "--prefix=/app/system/opt/php-7.3" \ "--enable-fpm" \ "--with-fpm-user=daemon" \ "--with-fpm-group=daemon" \ "--with-libxml-dir=/app/system/opt/lib/libxml2" \ "--with-apxs2=/app/system/opt/apache2/bin/apxs" \ "--enable-mbstring=all" \ "--enable-soap" \ "--enable-bcmath" \ "--enable-ftp" \ "--with-xmlrpc" \ "--enable-cgi" \ "--with-curl=/app/system/opt/lib/curl" \ "--with-zlib-dir=/app/system/opt/lib/zlib" \ "--with-gd" \ "--with-jpeg-dir=/app/system/opt/lib/jpeg-9d" \ "--with-png-dir=/app/system/opt/lib/libpng" \ "--with-freetype-dir=/app/system/opt/lib/freetype-2.9" \ "--enable-exif" \ "--with-openssl=/app/system/opt/lib/openssl" \ "--enable-calendar" \ "--enable-ctype" \ "--enable-pcntl" \ "--with-libzip=/app/system/opt/lib/libzip" \ "--enable-session" \ "--enable-zip" \ "--without-libzip" \ "--enable-sockets" \ "--with-icu-dir=/app/system/opt/lib/icu" \ "--with-tidy=/app/system/opt/lib/tidyp" \ "--with-iconv=/app/system/opt/lib/iconv" \ "--enable-mbstring" \ "--with-gmp=/app/system/opt/lib/gmp" \ "--with-gettext" \ "--with-ldap=/app/system/opt/lib/openldap" \ "--disable-huge-code-pages" \ "--with-pdo-mysql" \ "--with-mysql-sock" \ "--with-mysqli" \ "--enable-mysqlnd" \ "--enable-phar"
# Minimal Configuration PHP 7.3 './configure' \ '--enable-shared' \ '--prefix=/app/system/opt/php-7.3' \ '--enable-fpm' \ '--with-fpm-user=www-data' \ '--with-fpm-group=www-data' \ '--with-libxml-dir=/app/system/opt/lib/libxml2' \ '--enable-sysvshm' \ '--enable-sysvsem' \ '--enable-sysvmsg' \ '--enable-sockets' \ '--enable-soap' \ '--with-pdo-mysql' \ '--with-mysql-sock' \ '--with-mysqli' \ '--enable-mbstring' \ '--with-zlib-dir=/app/system/opt/lib/zlib' \ '--with-png-dir' \ '--enable-ftp' \ '--enable-exif' \ '--enable-bcmath' \ '--enable-calendar' \ '--with-gettext' \ '--enable-mysqlnd' \ '--with-libzip' \ '--with-apxs2=/app/system/opt/apache2/bin/apxs' \ '--with-openssl=/app/system/opt/lib/openssl' \ '--enable-zip' \ '--without-libzip' \ '--enable-phar' \ '--enable-gd-imgstrttf' \ '--enable-gd-native-ttf' \ '--with-ttf' \ '--with-gd' \ '--with-freetype-dir=/app/system/opt/lib/freetype-2.9' \ '--with-jpeg-dir=/app/system/opt/lib/jpeg-9d' \ '--with-png-dir=/app/system/opt/lib/libpng'
Additional Configuration
'--with-oci8=instantclient,/app/bin/oracle/instantclient_12_2'
Copy essential file after compile complete
cd /app/system/src/php-7.3.27 cp php.ini-production /app/system/opt/php-7.3/lib/php.ini cp /app/system/opt/php-7.3/etc/php-fpm.conf.default /app/system/opt/php-7.3/etc/php-fpm.conf cp /app/system/opt/php-7.3/etc/php-fpm.d/www.conf.default /app/system/opt/php-7.3/etc/php-fpm.d/www.conf
To change php-fpm port and user and group edit /app/system/opt/php-7.3/etc/php-fpm.d/www.conf
To start PHP- fpm version
/app/system/opt/php-7.3/sbin/php-fpm --fpm-config /app/system/opt/php-7.3/etc/php-fpm.conf
Check php-fpm is running
netstat -tapn | grep -E ".*9000.*php-fpm"
Stop php-fpm listener
lsof -t -i tcp:9000 | xargs kill -9
Part 1
http://tuts.raihanchow.com/2020/02/12/building-apache2-from-source-on-linux/
