- 开发环境
ubuntu16.04
编译安装前
apt-get install \
build-essential \
gcc \
g++ \
autoconf \
libiconv-hook-dev \
libmcrypt-dev \
libxml2-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libjpeg8-dev \
libpng12-dev \
libfreetype6-dev \
openssl \
libssl-dev
- 编译
编译前可以通过 ./configure --help 查看帮助信息
tar -zxvf php-5.6.29.tar.gz
cd php-5.6.29/
./configure --prefix=/usr/local/php \
--with-config-file-path=/etc/php \
--enable-fpm \
--enable-pcntl \
--enable-mysqlnd \
--enable-opcache \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-shmop \
--enable-zip \
--enable-soap \
--enable-xml \
--enable-mbstring \
--disable-rpath \
--disable-debug \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pcre-regex \
--with-iconv \
--with-zlib \
--with-mcrypt \
--with-gd \
--with-openssl \
--with-mhash \
--with-xmlrpc \
--with-curl \
--with-imap-ssl
make
make install
sudo mkdir /etc/php
sudo cp php.ini-development /etc/php/php.ini
- 将PHP的可执行目录添加到环境变量中
使用Vim/Sublime打开~/.bashrc,在末尾添加如下内容:
export PATH=/usr/local/php/bin:$PATH
export PATH=/usr/local/php/sbin:$PATH
添加完毕后
source ~/.bashrc
此时就可以通过 php --version 查看php版本了。
php -m 查看已安装的扩展