cd php-5.5.10/
./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-ftp --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
--with-apxs2=/usr/local/apache2/bin/apxs
sudo make sudo make install sudo cp php.ini-development /etc/php/
至此,PHP已经成功安装,但是此时在终端里是无法直接通过php --version查看php版本的。还需要将PHP的可执行目录添加到环境变量中。 使用Vim/Sublime打开~/.bashrc,在末尾添加如下内容:
export PATH=/usr/local/php/bin:$PATH export PATH=/usr/local/php/sbin:$PATH
保存后,终端输入命令:
source ~/.bashrc
此时即可通过php --version查看php版本,看到如下内容:
PHP 5.5.10 (cli) (built: Apr 26 2014 09:46:14) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
即说明安装成功。