美文网首页
PHP 源码编译方法(E文)

PHP 源码编译方法(E文)

作者: 小叶与小茶 | 来源:发表于2018-12-14 00:13 被阅读5次

Copy from PHP official community

Compiling PHP on Ubuntu boxes.

If you would like to compile PHP from source as opposed to relying on package maintainers, here's a list of packages, and commands you can run

STEP 1:

sudo apt-get install autoconf build-essential curl libtool \
  libssl-dev libcurl4-openssl-dev libxml2-dev libreadline7 \
  libreadline-dev libzip-dev libzip4 nginx openssl \
  pkg-config zlib1g-dev

So you don't overwrite any existing PHP installs on your system, install PHP in your home directory. Create a directory for the PHP binaries to live

mkdir -p ~/bin/php7-latest/

STEP 2:

Download the latest PHP tarball, decompress it, then cd to the new directory.

STEP 3:

Configure PHP. Remove any options you don't need (like MySQL or Postgres (--with-pdo-pgsql))

./configure --prefix=$HOME/bin/php-latest \
   --enable-mysqlnd \
   --with-pdo-mysql \
   --with-pdo-mysql=mysqlnd \
   --with-pdo-pgsql=/usr/bin/pg_config \
   --enable-bcmath \
   --enable-fpm \
   --with-fpm-user=www-data \
   --with-fpm-group=www-data \
   --enable-mbstring \
   --enable-phpdbg \
   --enable-shmop \
   --enable-sockets \
   --enable-sysvmsg \
   --enable-sysvsem \
   --enable-sysvshm \
   --enable-zip \
   --with-libzip=/usr/lib/x86_64-linux-gnu \
   --with-zlib \
   --with-curl \
   --with-pear \
   --with-openssl \
   --enable-pcntl \
   --with-readline

STEP 4:

Compile the binaries by typing: make
If no errors, install by typing: make install

STEP 5:

Copy the PHP.ini file to the install directory

cp php.ini-development ~/bin/php-latest/lib/ 

STEP 6:

cd ~/bin/php-latest/etc; 
mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.conf

STEP 7:

Create symbolic links for your for your binary files

  cd ~/bin
  ln -s php-latest/bin/php php
  ln -s php-latest/bin/php-cgi php-cgi
  ln -s php-latest/bin/php-config php-config
  ln -s php-latest/bin/phpize phpize
  ln -s php-latest/bin/phar.phar phar
  ln -s php-latest/bin/pear pear
  ln -s php-latest/bin/phpdbg phpdbg
  ln -s php-latest/sbin/php-fpm php-fpm

STEP 8:

Link your local PHP to the php command. You will need to logout then log back in for php to switch to the local version instead of the installed version

# add this to .bashrc
if [ -d "$HOME/bin" ] ; then
 PATH="$HOME/bin:$PATH"
fi

STEP 9: Start PHP-FPM

   sudo ~/bin/php7/sbin/php-fpm

其实,真尼玛是一种折磨……

相关文章

网友评论

      本文标题:PHP 源码编译方法(E文)

      本文链接:https://www.haomeiwen.com/subject/wfbihqtx.html