LINUX

linux下编译安装php7

1、从官网下载PHP安装包

wget http://hk2.php.net/get/php-7.1.8.tar.bz2/from/this/mirror

2、下载下来的文件为mirror镜像,通过mv命令重命名成tar.bz2文件 

mv mirror php-7.1.8.tar.bz2

 3、解压压缩文件

tar jxf php-7.1.8.tar.bz2

如果抛出这个异常请安装插件

ar (child): bzip2:无法 exec: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
yum install -y bzip2

4、安装php所需的依赖扩展和程序

yum install gd zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel

5、安装前配置,注意--enable-fpm为必须,在linux系统中php作为一个单独的进程存在 

./configure --prefix=/usr/local/php7.1.8/  --with-gd --enable-gd-native-ttf  --enable-mysqlnd  --with-pdo-mysql=mysqlnd  --with-openssl --enable-mbstring --enable-fpm

如果抛异常

configure: WARNING: unrecognized options: --with-mysql
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for cc... no
checking for gcc... no
configure: error: in `/usr/local/php-7.1.8':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

解决方法安装gcc

yum -y install gcc gcc-c++

6、编译安装

make && make install

7.配置文件

(1)进入安装程序/usr.local/php.7.1.8/etc

 cp php-fpm.conf.default php-fpm.conf

(2).配置conf文件

cd /usr/local/php7.1.8/etc/php-fpm.d/cp www.conf.default www.conf

(3).将php加入全局环境变量

vim /etc/profile在文件最后添加export PATH=$PATH:/usr/local/php7.1.8/bin
保存重新加载source /etc/profile

(4)这个php就配置完成了

php -v
(21)
分享:

本文由:xiaoshu168 作者:xiaoshu发表,转载请注明来源!

标签:

相关阅读