[英]How to compile PHP using –with-password-argon2?
I try to use PHP's password_hash()
function with the PASSWORD_ARGON2I
algorithm, however, I get the following error message:我尝试将 PHP 的
password_hash()
函数与PASSWORD_ARGON2I
算法一起使用,但是,我收到以下错误消息:
Warning : Use of undefined constant PASSWORD_ARGON2I - assumed 'PASSWORD_ARGON2I' (this will throw an Error in a future version of PHP) in
some-file.php on line
181
警告:在第
181行的
some-file.php 中使用未定义的常量 PASSWORD_ARGON2I - 假定为“PASSWORD_ARGON2I”(这将在 PHP 的未来版本中引发错误)
Warning : password_hash() expects parameter 2 to be integer, string given in
some-file.php on line
192
警告:password_hash() 期望参数 2 是整数,字符串在第
192行的
some-file.php 中给出
Fatal error : Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'password' cannot be null in some-file.php:232 Stack trace: #0 some-file.php(232): PDOStatement->execute() #1 {main} thrown in
some-file.php on line
232
致命错误:未捕获的 PDOException:SQLSTATE[23000]:违反完整性约束:1048 列“密码”在 some-file.php:232 中不能为 null 堆栈跟踪:#0 some-file.php(232):PDOStatement->execute( ) #1 {main} 在第
232行的
some-file.php 中抛出
I followed the official documentation of the function word by word, but I still faced this error.我是一个字一个字的跟着函数的官方文档,但是还是遇到了这个错误。
Then I made some research and I figured out that "PHP should be compiled using –with-password-argon2
" ( where they refer to this file ).然后我做了一些研究,我发现“PHP 应该使用
–with-password-argon2
” (他们指的是这个文件)。
I have no idea how to do this and I could not find any page which would guide me through the steps or provide me more info.我不知道该怎么做,也找不到任何页面可以指导我完成这些步骤或为我提供更多信息。
The hashing function works perfectly with PASSWORD_DEFAULT
, but that is not what I need at the moment.散列函数与
PASSWORD_DEFAULT
完美配合,但这不是我目前需要的。
I did not know but OSX comes with pre-installed PHP.我不知道,但 OSX 预装了 PHP。 I had a very early version so I needed to upgrade it in order to make Argon2 algorithm work.
我有一个非常早期的版本,所以我需要升级它以使 Argon2 算法工作。 When I checked my version by
php --version
in the command line, I got the following result:当我在命令行中通过
php --version
检查我的版本时,我得到以下结果:
PHP 5.6.30 (cli) (built: Oct 29 2017 20:30:32)
PHP 5.6.30 (cli)(构建时间:2017 年 10 月 29 日 20:30:32)
Copyright (c) 1997-2016 The PHP Group版权所有 (c) 1997-2016 PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend TechnologiesZend Engine v2.6.0,版权所有 (c) 1998-2016 Zend Technologies
So I followed through this guide but I also had to install Argon2 library (which was not mentioned) and use ./configure —with-password-argon2
.所以我按照本指南进行操作,但我还必须安装 Argon2 库(未提及)并使用
./configure —with-password-argon2
。 So here are the steps which solved my problem based on this guide :所以这里是根据本指南解决我的问题的步骤:
brew install libjpeg
, brew install pcre
, brew install libxml2
, etc. in the command line)brew install libjpeg
、 brew install pcre
、 brew install libxml2
等)./configure —with-password-argon2
./configure —with-password-argon2
make test
in the command line (time-consuming process, feel free to drink a beer meanwhile)make test
(耗时过程,同时随意喝啤酒)sudo make install
aftersudo make install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.