1,下载解压
tar xf php-7.2.0.tar.gz
cd php-7.2.0/
2,安装必要的库
sudo apt-get install libxml2-dev
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install make
sudo apt-get install curl
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev
sudo apt-get install libmcrypt-dev
3,编译
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=ghostwu
make && sudo make install
4,写一个测试文件,测试php
---------------------------------------------------------------------------------------------------------------------------------------------
以上为裸装php
如果需要添加扩展可以重新编译,或者用扩展安装方式,记得重新编译之前要make clean或者重新删除解压
较为基本的扩展安装
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-iconv-dir=/usr/local/lib \
--enable-fpm --with-fpm-user=ghostwu \
--with-iconv-dir=/usr/local/lib \
--enable-mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-zlib