Why?
- Minimal PHP system needed to run CRUD symfony app
- Better understanding of PHP configurations
- Newer sqlite support, like window functions and JSON1 extension
Adapted from
- http://www.phpinternalsbook.com/php7/build_system/building_php.html
- https://github.com/gitKearney/php7-from-scratch
- https://mac-dev-env.patrickbougie.com/php/
sudo apt-get install build-essential \
autoconf \
libtool \
bison \
re2c \
libxml2-dev \
libonig-dev \
libssl-dev \
libargon2-0-dev \
libsodium-dev \
libcurl4-openssl-dev \
libreadline-dev \
libyaml-dev \
libgmp-dev
Download sqlite3 from https://www.sqlite.org/download.html. Download the source code with -autoconf
file which contains the configure scripts. Extract and cd into the extracted directory
./configure --prefix=$HOME/package/sqlite-3.32.2
make
make install
Download PHP https://www.php.net/distributions/php-7.4.6.tar.xz, then adjusting the sqlite pkg-config and ldflags as needed
PKG_CONFIG_PATH="$HOME/package/sqlite-3.32.1/lib/pkgconfig" \
LDFLAGS="-L/$HOME/package/sqlite-3.32.1/lib" \
./configure \
--prefix=$HOME/package/php-7.4.6 \
--enable-bcmath \
--enable-calendar \
--enable-opcache \
--enable-mbstring \
--enable-intl \
--enable-mysqlnd \
--disable-cgi \
--with-readline \
--with-zlib \
--with-curl \
--with-openssl \
--with-password-argon2 \
--with-sodium \
--with-pear \
--with-gmp \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd
make -j 4
make install
./libtool --finish $HOME/source/php-7.4.6/libs
brew install icu4c \
oniguruma \
openssl@1.1 \
libsodium \
argon2 \
libiconv \
readline \
libyaml \
gmp
For now, use macos built in sqlite
Finally, install php-7.4.6, adjusting the sqlite pkg-config and ldflags as needed
PKG_CONFIG_PATH="$(brew --prefix openssl@1.1)/lib/pkgconfig:$(brew --prefix icu4c)/lib/pkgconfig:$HOME/package/sqlite-3.32.1/lib/pkgconfig" \
LDFLAGS="-L$(brew --prefix openssl@1.1)/lib:-L$(brew --prefix icu4c)/lib:-L/$HOME/package/sqlite-3.32.1/lib" \
./configure \
--prefix=$HOME/package/php-7.4.6 \
--enable-bcmath \
--enable-calendar \
--enable-opcache \
--enable-mbstring \
--enable-intl \
--enable-mysqlnd \
--disable-cgi \
--with-readline=$(brew --prefix readline) \
--with-iconv=$(brew --prefix libiconv) \
--with-zlib \
--with-curl \
--with-openssl \
--with-password-argon2 \
--with-sodium \
--with-pear \
--with-gmp \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd
make -j 4
make install
./libtool --finish $HOME/source/php-7.4.6/libs
Then, add the $HOME/package/php-7.4.6/bin
to your PATH
Finally:
rizalp@desktop:~$ symfony check:requirements
Symfony Requirements Checker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> PHP is using the following php.ini file:
/home/rizalp/package/php-7.4.6/lib/php.ini
> Checking Symfony requirements:
.............................
[OK]
Your system is ready to run Symfony projects