Ubuntu 编译安装PHP
1.编译环境:
sudo 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 \
2.编译安装php
cd php-5.6.22/
./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 \
--disable-fileinfo \
--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
sudo make sudo make install sudo mkdir /etc/php sudo cp php.ini-development /etc/php/php.ini
注意,以上PHP编译选项根据实际情况可调整。
3.将PHP的可执行目录添加到环境变量中,使用Vim/Sublime打开~/.bashrc,添加以下内容。
export PATH=/usr/local/php/bin:$PATH export PATH=/usr/local/php/sbin:$PATH
保存后,终端输入命令:
source ~/.bashrc
此时即可通过php --version
查看php版本。