Debian8中用编译方式安装php7

2017-02-10  本文已影响644人  co可丁

php安装步骤:

1. 下载php-7.0.14.tar.gz,并将其解压:
$ tar -zvxf php-7.0.14.tar.gz
2. 安装相关依赖包:
$ apt-get install -y libxml2 libxml2-dev openssl libcurl4-gnutls-dev libjpeg-dev libpng12-dev libfreetype6-dev
3. 执行:ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib

注:否则会报错:configure: error: Cannot find OpenSSL's libraries

4. 编译:
$ cd php-7.0.14
$ ./configure --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-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 --without-gdbm --disable-fileinfo
5. 安装:
$ make && make install

成功:

php安装成功

php-fpm配置

测试是否能解析php文件:

注:先要安装nginx,具体步聚见http://www.jianshu.com/p/6b70db035b95

  1. 在/usr/local/nginx/html/文件夹下创建一个用于测试的php文件,如test.php:
<?php
    phpinfo()
?>
  1. 启动nginx(需要对脚本做修改),在浏览器中输入http://localhost/test.php,看到以下页面即成功。
test.php页面

遇到的问题及解决方法

  1. .编译时报错:configure: error: Cannot find OpenSSL's libraries
    解决方法:
    apt-get install openssl
    apt-get install libssl
    find / -name libssl.so
    输出:/usr/lib/x86_64-linux-gnu/libssl.so
    执行:ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib
  2. 编译时报错:configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/
    解决方法:apt-get install libcurl4-gnutls-dev
  3. 编译时报错:configure: error: jpeglib.h not found.
    解决方法:apt-get install libjpeg-dev
  4. 编译时报错:configure: error: png.h not found.
    解决方法:apt-get install libpng12-dev
  5. 编译报错:configure: error: freetype-config not found.
    解决方法:apt-get install libfreetype6-dev
  6. 执行/web/php/etc/php-fpm -t报错 :
    root@ng1:~/php-7.0.14# /web/php/sbin/php-fpm -t
    [10-Feb-2017 10:29:10] WARNING: Nothing matches the include pattern '/web/php/etc/php-fpm.d/*.conf' from /web/php/etc/php-fpm.conf at line 125.
    [10-Feb-2017 10:29:10] ERROR: No pool defined. at least one pool section must be specified in config file
    [10-Feb-2017 10:29:10] ERROR: failed to post process the configuration
    [10-Feb-2017 10:29:10] ERROR: FPM initialization failed
    解决方法:cd /web/php/etc/php-fpm.d
    cp www.conf.default www.conf
上一篇下一篇

猜你喜欢

热点阅读