linux下编译安装php5.6 php7

#源码安装
在linux下装了许多遍php后有感而发,有一个归根到底的问题就是,php编译参数一定要写完整,否则接下来你装各种扩展都会遇到很多烦死人的问题……,特别是安装路径乱七八糟的或者缺少各种头文件和扩展。

ok吐槽完了,在开始讲怎么安装之前,先说说我的系统背景。​

系统是Centos6.5,之前是用yum安装了lnmp,由于想把php升级到5.6,所以只能够用yum remove php*把所有的软件管理包卸载掉,重新编译php。​

背景介绍完了,现在开始说安装步骤了。​

​#cd ~

#wget http://mirrors.sohu.com/php/php-5.6.2.tar.gz

#tar xf php-5.6.2​

#yum install gcc gcc-c++ libxml2 libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-devel libcurl-devel libmcrypt-devel

安装php依赖的包​​

#​./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc \
--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 --with-mysqli --with-pdo-mysql \
--with-pcre-regex --with-iconv --with-zlib --with-mcrypt --with-gd --with-openssl --with-mhash --with-xmlrpc --with-curl --with-imap-ssl

重点来了,注意这里的参数(当然也可以不用这里的参数,不过建议新手还是用吧)。-prefix是安装目录,-with-mysql是mysql的安装目录,由于我是用yum装的,所以不需要写-with-mysql=****。

修改后:(请将–替换为减减符号,csdn的markdown不知道怎么打出来)

 ​./configure --prefix=/usr/local/php56
 --with-config-file-path=/usr/local/php56/etc \
 --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-pcre-regex --with-iconv --with-zlib --with-mcrypt --with-gd --with-openssl \
--with-mhash --with-xmlrpc --with-curl --with-imap-ssl --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd

​#make

#make install

若上几步都没报错的话就安装成功,有报错估计是少了点什么,用百度查查后yum一下吧。​

#cp php.ini-production /usr/local/php/etc/php.ini​
#cd /usr/local/php56/etc (config-file-path)
#cp php-fpm.conf.default php-fpm.conf

修改php-fpm.conf

listen.owner = nobody
listen.group = nobody
listen.mode = 0666

#yum安装(推荐)

#查看 删除老php版本的源
yum list installed | grep php  

yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64 

#添加CentOS 7.0的源
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

#追加CentOS 6.5的epel及remi源
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

#查看php56的源资源
yum list --enablerepo=remi --enablerepo=remi-php56 | grep php

#安装
yum install --enablerepo=remi --enablerepo=remi-php56 php php-fpm php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof
yum install | grep php
yum install php72-php.x86_64 php72-php-fpm.x86_64  php72-php-devel.x86_64 php72-php-bcmath.x86_64 php72-php-cli.x86_64 php72-php-common.x86_64 php72-php-gd.x86_64 php72-php-json.x86_64 php72-php-mbstring.x86_64 php72-php-mysqlnd.x86_64  php72-php-opcache.x86_64 php72-php-pdo.x86_64 php72-php-pecl-redis.x86_64 php72-php-pecl-swoole2.x86_64  php72-php-pecl-yaf.x86_64 php72-runtime.x86_64 php72-php-xml.x86_64 php72-php-xmlrpc.x86_64 php72-php-pecl-xdebug.x86_64  

参考:
linux下编译安装php5.6
PHP 编译安装时出现 undefined reference to `libiconv’ 错误的解决方法
简要谈谈php中mysql,mysqli,mysqlnd,pdo到底是什么.
PHP 5.3.0以上推荐使用mysqlnd驱动

Centos 6.x/7.x yum安装php5.6.X(最新版)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值