在centOS6.8上安装php,出各种问题,光是gcc的版本太低,升级gcc这个,就让我气了两天,翻遍了几乎所有相关博客总算解决了。还有mysql安装也没少踩坑,所以大家还是尽量用centOS7吧,少生气能多活几年呢。。。
现在说一下centOS6.8上编译安装php7.2.1吧。
1,安装扩展包并更新系统(我在根目录下开始的):
yum install epel-release -y
yum update
2,安装php依赖组件(一段全复制上去,其实掠过也可能没关系):
yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel
3,下载php安装包并解压:
wget http://am1.php.net/distributions/php-7.2.1.tar.gz
tar xvf php-7.2.1.tar.gz
4,进入解压目录并开始编译(编译千万不能省,运行出错了就不能make了,这是我选出来的最靠谱可行的编译了):
cd /php-7.2.1
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mcrypt=/usr/include --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv -