本篇内容主要讲解“CentOS7怎么安装PHP7.1”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“CentOS7怎么安装PHP7.1”吧!

1.首先安装依赖包:

yuminstalllibxml2libxml2-developensslopenssl-develbzip2bzip2-devellibcurllibcurl-devellibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-develgmpgmp-devellibmcryptlibmcrypt-develreadlinereadline-devellibxsltlibxslt-develzlibzlib-develglibcglibc-develglib2glib2-develncursescurlgdbm-develdb4-devellibXpm-devellibX11-develgd-develgmp-develexpat-develxmlrpc-cxmlrpc-c-devellibicu-devellibmcrypt-devellibmemcached-devezlibzlib-develglibcglibc-develglib2glib2-develncursescurlgdbm-develdb4-devellibXpm-devellibX11-develgd-develgmp-develexpat-develxmlrpc-cxmlrpc-c-devellibicu-devellibmcrypt-devellibmemcached-devel2.下载PHP压缩包并解压:

1wgethttp://php.net/distributions/php-7.1.0.tar.gz2tar-zxvfphp-7.1.0.tar.gz3cdphp-7.1.03.编译安装,编译的时候可能会出现各种报错情况:

./configure\--prefix=/usr/local/php\--with-config-file-path=/etc\--enable-fpm\--enable-inline-optimization\--disable-debug\--disable-rpath\--enable-shared\--enable-soap\--with-libxml-dir\--with-xmlrpc\--with-openssl\--with-mcrypt\--with-mhash\--with-pcre-regex\--with-sqlite3\--with-zlib\--enable-bcmath\--with-iconv\--with-bz2\--enable-calendar\--with-curl\--with-cdb\--enable-dom\--enable-exif\--enable-fileinfo\--enable-filter\--with-pcre-dir\--enable-ftp\--with-gd\--with-openssl-dir\--with-jpeg-dir\--with-png-dir\--with-zlib-dir\--with-freetype-dir\--enable-gd-native-ttf\--enable-gd-jis-conv\--with-gettext\--with-gmp\--with-mhash\--enable-json\--enable-mbstring\--enable-mbregex\--enable-mbregex-backtrack\--with-libmbfl\--with-onig\--enable-pdo\--with-mysqli=mysqlnd\--with-pdo-mysql=mysqlnd\--with-zlib-dir\--with-pdo-sqlite\--with-readline\--enable-session\--enable-shmop\--enable-simplexml\--enable-sockets\--enable-sysvmsg\--enable-sysvsem\--enable-sysvshm\--enable-wddx\--with-libxml-dir\--with-xsl\--enable-zip\--enable-mysqlnd-compression-support\--with-pear\--enable-opcache

全部复制以上代码一次执行。

4.编译成功后安装:

make&&makeinstall

注意:编译时可能会出现 make : ***[sapi/cli/php] error 1 报错,解决方法:

1).$vimMakefile打开,Makefile文件,在EXTRA_LIBS最后面增加-liconv如:XTRA_LIBS=-lcrypt-lz-lresolv-lcrypt-lreadline-ltermcap-lmcrypt-lltdl-lpng-lz-ljpeg-lcurl-lz-lrt-lm-ldl-lnsl-lxml2-lssl-lcrypto-lcurl-lxml2-lssl-lcrypto-lfreetype-lz-lpng12-lxml2-lxml2-lcrypt-lxml2-lxml2-lxml2-lxml2-lssl-lcrypto-lcrypt-liconv按Esc,按:wq保存退出。2).$makeclean&&make&&makeinstall重新执行编译。5.安装成功后配置环境变量:

1vim/etc/profile

在 /etc/profile文件末尾添加php环境变量 :

source/etc/profile

查看环境变量:

echo$PATH

看到php环境变量的路径后,以后就可以直接使用php命令了,查看php版本:

php-v6.现在的PHP没有.ini文件和配置文件,还需要配置php-fpm:

1cpphp.ini-production/etc/php.ini2cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf3cp/usr/local/php/etc/php-fpm.d/www.conf.default/usr/local/php/etc/php-fpm.d/www.conf4cpsapi/fpm/init.d.php-fpm/etc/init.d/php-fpm5chmod+x/etc/init.d/php-fpm

php-fpm的启动、停止和重启:

1servicephp-fpmstart#启动2servicephp-fpmstop#停止3servicephp-fpmrestart#重启

到此,相信大家对“CentOS7怎么安装PHP7.1”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!