简体   繁体   English

如何使用 –with-password-argon2 编译 PHP?

[英]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 Technologies Zend 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 :所以这里是根据本指南解决我的问题的步骤:

  1. Download the latest PHP source code fe from here (I used this .GZ file , but make some research whether there is a newer version or not)从这里下载最新的 PHP 源代码 fe (我使用了这个 .GZ 文件,但要研究一下是否有更新的版本)
  2. Open the command line打开命令行
  3. Extract the GZ file and navigate to the extracted source code folder in the command line解压 GZ 文件并在命令行中导航到解压的源代码文件夹
  4. You will need Homebrew, install it if you don't have it您将需要 Homebrew,如果您没有,请安装它
  5. Install the dependencies listed in this guide (run brew install libjpeg , brew install pcre , brew install libxml2 , etc. in the command line)安装本指南中列出的依赖项(在命令行中运行brew install libjpegbrew install pcrebrew install libxml2等)
  6. Also install Argon2 library (this is not mentioned in the previous guide, you can use this guide )还要安装 Argon2 库(这个在之前的指南中没有提到,你可以使用这个指南
  7. Now run this in the command line (still same source code folder): ./configure —with-password-argon2现在在命令行中运行它(仍然是相同的源代码文件夹): ./configure —with-password-argon2
  8. run make test in the command line (time-consuming process, feel free to drink a beer meanwhile)在命令行中运行make test (耗时过程,同时随意喝啤酒)
  9. run sudo make install after之后运行sudo make install
  10. I also restarted my computer, not sure if it was necessary but it worked我也重新启动了我的电脑,不确定是否有必要,但它有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM