您的位置 首页 php

php7在centos下的编译安装

自从2015年php7发布以来,获得了大家的一直好评,因为一直以来,php让人诟病的一个主要原因就是执行效率问题,而php7的性能得到了很大的提升,另外php7增加了不少新的 特性,也不掉了一些过时的功能,所以php7你值得拥有,经过这几年的不断优化,php7已经很稳定了,新项目可以拿来试一下了。

今天我们就先介绍一下php7的编译安装过程

Php版本7.2.9,下载对应的php安装包源代码文件 php-7.2.9.tar.gz

1. 首先安装依赖库

yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

2. 编译,编译参数如下,根据自己的需要自行修改

./configure \

–prefix=/usr/local/php \

–with-config-file-path=/etc \

–enable-fpm \

–with-fpm-user= Nginx \

–with-fpm-group=nginx \

–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

如果在编译过程中出现错误,可能是依赖库没有装,编译通过,最后显示一行警告信息,

configure: WARNING: unrecognized options: –with-mcrypt, –enable-gd-native-ttf

暂时忽略之。

Make && make install 安装完成

3. 配置

Php的配置

Cp php-fpm .conf.default php-fpm.conf

Cp php-fpm.d/www.conf.default php-fpm.d/www.conf

启动php

./sbin/php-fpm

Nginx的配置

修改nginx的配置文件nginx.conf

location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_paramSCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

启动nginx

./s bin /nginx

4. 测试

在nginx/html 新建一个info.php

<?php echo phpinfo();?>

浏览器访问,正常会显示php的信息。如果看到 Loaded Configuration File 为none,说明没有配置文件,复制源代码的配置文件到安装目录etc,(编译时可配置)

cp php.ini-* /usr/local/php/etc

5. 设置 环境变量

PATH=$PATH:/usr/local/php/bin

export PATH

source /etc/profile

安装php-fpm服务

Cp sapi/fpm/ init.d.php-fpm /etc/init.d/php-fpm

chmod +x /etc/init.d/php-fpm

文章来源:智云一二三科技

文章标题:php7在centos下的编译安装

文章地址:https://www.zhihuclub.com/78625.shtml

关于作者: 智云科技

热门文章

网站地图