PHP 7.2.10 编译安装

准备环境

1.CentOS 系统

[root@test3 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

2.防火墙

[root@test3 ~]# systemctl stop firewalld
[root@test3 ~]# systemctl disable firewalld
[root@test3 ~]# cat /etc/sysconfig/selinux 
SELINUX=disabled
[root@test3 ~]# setenforce 0
[root@test3 ~]# getenforce 0
Permissive

3.YUM,EPEl源
本地YUM源可以,或者选择其他外部源

[root@test3 ~]# yum -y install epel-release

4.php依赖包

[root@test3 ~]# yum -y install gcc gcc-c++ libmcrypt-devel mcrypt mhash gd-devel ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel openssl-deve python-devel zlib-devel freetype libxslt* bison autoconf re2c

5.php安装包

[root@test3 ~]# wget http://cn2.php.net/distributions/php-7.2.10.tar.gz
[root@test3 ~]# tar xvf php-7.2.10.tar.gz
[root@test3 ~]# cd php-7.2.10/
[root@test3 php-7.2.10]# ./configure \
--prefix=/usr/local/php \
--exec-prefix=/usr/local/php \
--bindir=/usr/local/php/bin \
--sbindir=/usr/local/php/sbin \
--includedir=/usr/local/php/include \
--libdir=/usr/local/php/lib/php \
--mandir=/usr/local/php/php/man \
--with-config-file-path=/usr/local/php/etc \
--with-mysql-sock=/var/run/mysql/mysql.sock \
--with-mhash \
--with-openssl \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-pcntl \
--enable-calendar \
--enable-exif \
--enable-sockets \
--with-xmlrpc \
--with-libxml-dir \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-bz2 \
--enable-opcache \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--without-gdbm \
--enable-fast-install \
--disable-fileinfo
[root@test3 php-7.2.10]# make
······
Build complete.
Don't forget to run 'make test'.
[root@localhost php-7.2.10]# make install
······
/root/php-7.2.10/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/
[root@test3 php-7.2.10]# /usr/local/php/bin/php -v  //版本验证
PHP 7.2.10 (cli) (built: Oct  9 2018 09:59:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

6.编译PHP的选项说明
PHP 7.2.10 编译安装
7.PHP安装后的配置
php.ini文件

[root@test3 php-7.2.10]# useradd nginx
[root@test3 php-7.2.10]#  cp -a php.ini-production /usr/local/php/etc/php.ini
[root@test3 php-7.2.10]#  cp -a php.ini-production /usr/local/php/etc/php.ini
[root@test3 php-7.2.10]#  vim /usr/local/php/etc/php.ini
date.timezone = Asia/shanghai    #指定时区为上海
expose_php = Off      #禁止显示PHP版本
short_open_tag = ON   #支持PHP短标签
opcache.enable=1      #PHP支持opcode缓存
opcache.enable_cli=0
zend_extension=opcache.so     #在最后一行添加,开启opcode缓存功能

8.配置php-fpm和www.conf

[root@test3 php-7.2.10]#  cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@test3 php-7.2.10]#  cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@test3 php-7.2.10]#  cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@test3 php-7.2.10]#  chmod +x /etc/rc.d/init.d/php-fpm
[root@test3 php-7.2.10]#  chkconfig --add php-fpm

9.环境变量

[root@test3 php-7.2.10]#  cat /etc/profile
PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/
[root@test3 php-7.2.10]# source /etc/profile

10.启动 php-fpm

[root@test3 php-7.2.10]# systemctl start php-fpm
[root@test3 php-7.2.10]#  ss -ant|grep 9000
LISTEN     0      128    127.0.0.1:9000                     *:*   

11.创建测试页

[root@test3 php-7.2.10]# yum -y install nginx
[root@test3 ~]# vim /etc/nginx/nginx.conf
#把下面一段插入到server标签内
location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
[root@test3 ~]#  vim /usr/share/nginx/html/index.php
#创建php测试网页
<?php
phpinfo();
?>
[root@localhost ~]# systemctl start nginx

12.测试
PHP 7.2.10 编译安装
PHP 7.2.10 编译安装

转载于:https://blog.51cto.com/13767724/2296152

编译 ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr /i nclude --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=www --with-fpm-group=www --without-gdbm --with-mcrypt=/usr/local/apps/libmcrypt --disable-fileinfo 报错:1, **configure: error: system libzip must be upgraded to version >=**0.11。 使用Yum最新版只到0.10,不足以达到要求。 一、先删除libzip yum remove libzip -y SSH执行以上命令,先删除libzip 和 libzip-devel 二、下载安装并手动编译 wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make && make install 三、(可忽略)另外最新版本请参考官网:https://nih.at/libzip/ 1.5.0的libzip需要cmake wget https://libzip.org/download/libzip-1.5.0.tar.gz tar -zxvf libzip-* cd libzip* mkdir build && cd build && cmake .. && make && make install 报错2: error: off_t undefined; check your library configuration 根据报错信息分析 configure: error: off_t undefined; check your library configuration 未定义的类型 off_t。 off_t 类型是在 头文件 unistd.h中定义的,在32位系统 编程成 long int ,64位系统则编译成 long long int ,这里题主的系统应该是 64位的吧,在进行编译的时候 是默认查找64位的动态链接库,但是默认情况下 centos 的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。 采用下面的方法。 添加搜索路径到配置文件 echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值