Fork me on GitHub

php7.3源码编译

前置条件

  • autoconf:2.59+
  • automake:1.4+
  • libtool:1.4.x(除了1.4.2)
  • re2c:0.13.4+
  • bison:建议1.281.35 或 1.75
  • 依赖的库
yum install gcc gcc-c++ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib \
zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel curl curl-devel openssl openssl-devel libzip libzip-devel \
libwebp libwebp-devel
  • 如果需要安装libzip扩展,需要安装libzip libzip-devel库,版本>=0.11,yum仓库自带的版本比较低,需要手动编译libzip
  • 手动编译libzip需要先安装cmake,libzip版本选择跟cmake适配的版本,这里选择1.2.0 libzip版本,libzip手动编译默认安装在/usr/local目录下

环境检查

  • 线程安全版本:--enable-maintainer-zts
  • 多进程方式使用非线程安全版本即可
[root@wadeyu php-7.3.4]# ./configure --prefix=/usr/local/php7.3 --with-config-file-path=/usr/local/php7.3/etc \
--with-mysqli=mysqlnd --with-iconv-dir=/usr --with-gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-webp-dir=/usr \
--with-zlib --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring \
--with-openssl --with-mhash --enable-pcntl --enable-sockets --enable-soap --without-pear --with-libzip=/usr/local --with-bz2 --enable-calendar \
--enable-ftp --enable-ctype --enable-exif --disable-ipv6 --with-sqlite3 --enable-pdo --with-pdo-mysql=mysqlnd --enable-phar --with-curl --with-tsrm-pthreads

编译安装

  • 编译需要比较长的时间,不同硬件配置的机器,编译时间不一样
  • 我的树莓派1G4核的配置,编译了差不多1个半小时 😦
[root@wadeyu php-7.3.4]# make && make install

php配置

  • 源码中包含两个环境的php.ini文件
  • php.ini.development 用于开发环境
  • php.ini.production 用于正式环境
  • 正式需要关注的配置项
;设置php允许操作的目录,多用户共享环境需要设置
open_basedir=

;禁用不安全的函数,多个使用,分隔
disable_functions=

;禁用不安全的类,多个使用,分隔
disable_classes=

;web header是否添加php版本信息,默认是开启
expose_php = On

;脚本执行超时时间,单位秒
max_execution_time = 30

;脚本解析请求数据的超时时间,单位秒
max_input_time = 60

;脚本可使用的最大的内存资源
memory_limit = 128M

;;
;;

;设置错误报告的级别,生产环境默认除了E_DEPRECATED,E_STRICT,其它都包含
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

;php是否可以输出错误,生产环境要关闭
display_errors = Off

;是否输出php启动时的错误,生产环境要关闭
display_startup_errors = Off

;是否开启记录错误日志
log_errors = On

;错误信息是否添加html标签,默认是开启
html_errors = On

;指定报错日志存放的地方,默认未设置
error_log = 

;;
;;

;post方式php可接收的最大数据量
post_max_size = 8M

;;
;;

;允许上传的单个文件大小
upload_max_filesize = 2M

;;
;;

;是否允许远程打开文件
allow_url_fopen = On

;是否允许包含远程文件,线上要关闭,有安全风险
allow_url_include = Off

;socket流默认超时时间,单位秒
default_socket_timeout = 60

;;
;;

;session相关配置,存储支持files, redis, 还可以自定义存储引擎
;session cookie相关配置

;;
;;

;opcache字节码缓存相关的设置

参考资料

posted @ 2019-04-14 21:27  huan&ping  阅读(2218)  评论(0编辑  收藏  举报