喵♂呜 的博客

一个刚毕业就当爹的程序猿 正在迷雾中寻找道路...

PHP7编译安装

PHP7已经出了来了 据说性能提高了不少 最近安装试了一下 这里记录一下遇到的问题

PHP7编译安装流程以及常见问题解决

下载源码

从GIT获取最新的代码 git clone https://git.php.net/repository/php-src.git

安装依赖

提前安装部分依赖 yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel

编译安装

  • 检查配置 执行下列命令
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    ./configure \
    --prefix=/usr/local/php7 \
    --exec-prefix=/usr/local/php7 \
    --bindir=/usr/local/php7/bin \
    --sbindir=/usr/local/php7/sbin \
    --includedir=/usr/local/php7/include \
    --libdir=/usr/local/php7/lib/php \
    --mandir=/usr/local/php7/php/man \
    --with-config-file-path=/usr/local/php7/etc \
    --with-mysql-sock=/var/run/mysql/mysql.sock \
    --with-mcrypt=/usr/include \
    --with-mhash \
    --with-openssl \
    --with-mysql=shared,mysqlnd \
    --with-mysqli=shared,mysqlnd \
    --with-pdo-mysql=shared,mysqlnd \
    --with-gd \
    --with-iconv \
    --with-zlib \
    --with-xmlrpc \
    --with-gettext \
    --with-apxs2 \
    --with-curl \
    --with-jpeg-dir \
    --with-fpm-user=apache \
    --with-fpm-group=apache \
    --without-gdbm \
    --enable-inline-optimization \
    --enable-shared \
    --enable-xml \
    --enable-bcmath \
    --enable-shmop \
    --enable-sysvsem \
    --enable-mbregex \
    --enable-mbstring \
    --enable-ftp \
    --enable-pcntl \
    --enable-sockets \
    --enable-session \
    --enable-opcache=no \
    --enable-fpm \
    --disable-debug \
    --disable-rpath \
    --disable-fileinfo

常见问题

  • Sorry, I cannot run apxs. Possible reasons follow:
    1
    2
    3
    yum install perl
    find / -name apxs 得到路径 /opt/httpd/bin/apxs
    添加参数 --with-apsx2=/opt/httpd/bin/apxs
  • configure: error: jpeglib.h not found.

    1
    yum -y install php-gd
  • configure: error: freetype-config not found.

    1
    yum install freetype-devel
  • configure: error: off_t undefined; check your library configuration

    1
    去掉 --enable-zip 选项

欢迎关注我的其它发布渠道