How to compile PHP using –with-password-argon2? - php

I try to use PHP's password_hash() function with the PASSWORD_ARGON2I algorithm, however, I get the following error message:
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
Warning: password_hash() expects parameter 2 to be integer, string given in some-file.php on line 192
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
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).
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.

I did not know but OSX comes with pre-installed PHP. I had a very early version so I needed to upgrade it in order to make Argon2 algorithm work. When I checked my version by php --version in the command line, I got the following result:
PHP 5.6.30 (cli) (built: Oct 29 2017 20:30:32)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (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. So here are the steps which solved my problem based on this guide:
Download the latest PHP source code f.e. from here (I used this .GZ file, but make some research whether there is a newer version or not)
Open the command line
Extract the GZ file and navigate to the extracted source code folder in the command line
You will need Homebrew, install it if you don't have it
Install the dependencies listed in this guide (run brew install libjpeg, brew install pcre, brew install libxml2, etc. in the command line)
Also install Argon2 library (this is not mentioned in the previous guide, you can use this guide)
Now run this in the command line (still same source code folder): ./configure —with-password-argon2
run make test in the command line (time-consuming process, feel free to drink a beer meanwhile)
run sudo make install after
I also restarted my computer, not sure if it was necessary but it worked

Related

How to fix PHP module problems after update

I think this question is asked already, but with so many different conditions, I think my problem is a bit unique, correct me if I'm wrong.
I have this response after make a PHP update on my old MacBook. Using curl PHP install command:
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3
and this is my result after install and I check my version with "PHP -v" command on terminal
PHP Warning: PHP Startup: curl: Unable to initialize module
Module compiled with module API=20160303
PHP compiled with module API=20180731
These options need to match
in Unknown on line 0
Warning: PHP Startup: curl: Unable to initialize module
Module compiled with module API=20160303
PHP compiled with module API=20180731
These options need to match
in Unknown on line 0
etc
also in the end of the line there is this error:
Deprecated: Directive 'track_errors' is deprecated in Unknown on line 0
PHP 7.3.0beta3 (cli) (built: Sep 3 2018 11:26:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
PHP 7.3.0beta3 is my previous version.
Been tried to re-install the same version of PHP using command line but still doesn't work.
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3.0beta3
I know something un-match with the version. But how exactly I fix it.
I've been search the whole internet, and not found any solution that works well with me. Most question that I search here, is not marked as "worked solution" yet.
Probably I understand it wrong.
Anyone have the solution, please?!
I desperately need the answer. Thank you
FYI:
My MacOS is Yosemite 10.10.5
////////////////////
UPDATE 1:
I've been checked on this solution on THIS LINK
But it's not going to work since the solution require me to install PECL / PEAR, and that installer would work through PHP command. Which is broken for me.
////////////////////
UPDATE 2:
I've checked a shortcut file on 'usr/local/php5' and it's refer to a wrong directory, so I rename it to 'php5-old' and created a new alias from my old php directory and rename it 'php5'.
When I run 'php -v' command, it says a different error:
dyld: Library not loaded: /usr/local/php5/lib/libtidy-0.99.0.dylib
Referenced from: /usr/local/php5-7.3.0beta3-20180903-112811/bin/php
Reason: no suitable image found. Did find:
/usr/local/php5/lib/libtidy-0.99.0.dylib: stat() failed with errno=20
Trace/BPT trap: 5
I don't know what to do. I did check on that "libtidy-0.99.0.dylib" file, and still on the same directory.
////////////////////
UPDATE 3:
This is not the best practice. But I've got temporary solution already. I start to understand that the problem from my UPDATE 2 is from 'usr/local/php5', but instead I create a new alias that doesn't work, I rename the 'php5' refers directory and add "-old" prefix. And the original folder that should work "php5-7.3.0beta3-20180903-112811", I rename into the folder name that 'php5' alias refers to. And the PHP now working.
But still one more problem: "Apache web server" still not running.
So this problem looks like occur when my Mac itself has another problem (which I don't really know what it is).
So the best solution so far (been tried to avoid this from the beginning) is to create a new user and do install it all as a new laptop... And that's it. Works Normal

Postgresql database with PHP server error on MacOS Bash

I ran a PHP server with postgresql on my college computers which works fine, however on my local machine (which runs MacOS), I get the following error message:
Call to undefined function pg_Connect() in /Users/mac/Documents/<... the remaining path to php file>.php on line 2
Now, I thought it's an issue of missing the postgresql packages for php, so I used brew to install the php postgresql packages. I ran the following commands:
brew install postgresql
brew install php55 --with-postgresql
brew install php55-pdo-pgsql
However, even after running these commands I get the same error when running the php server, i.e.
Call to undefined function pg_Connect() in /Users/mac/Documents/<... the remaining path to php file>.php on line 2
The php version I have is 5.5.30:
mac$ php -v
PHP 5.5.30 (cli) (built: Oct 23 2015 17:21:45)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
Please could you suggest what I am doing wrong to install the packages. I read on stack overflow that the packages can be installed with an apt-get command on linux, however I'm not sure as to what the solution is with the Mac operating system.
Thanks in advance.
The solution was edit the php.ini on your server then find this below line and uncomment that line.
extension="pgsql.so"
then restart the server apache and test it out again.
Also, check this link for the steps regarding installation of the postgress to mac OS.

How to install IoncubeLoader on MacOS 10.13

I can not get the IoncubeLoader running on my MacOS 10.13.
First I tried - as recommended - to install via loader-wizard. This fails with the error message:
Warning: Illegal string offset 'errors' in
/Users/johndoe/Sites/ioncube/loader-wizard.php on line 1252
Fatal error: Uncaught Error: Cannot use string offset as an array in
/Users/johndoe/Sites/ioncube/loader-wizard.php:1252 Stack
trace: #0 /Users/johndoe/Sites/ioncube/loader-wizard.php(1294):
scan_inis_for_loader() #1
/Users/johndoe/Sites/ioncube/loader-wizard.php(3291):
find_loader(false) #2
/Users/johndoe/Sites/ioncube/loader-wizard.php(3085):
ini_loader_errors() #3
/Users/johndoe/Sites/ioncube/loader-wizard.php(2908):
loader_not_installed() #4
/Users/johndoe/Sites/ioncube/loader-wizard.php(2712):
default_page() #5
/Users/johndoe/Sites/ioncube/loader-wizard.php(115): run() #6
{main} thrown in /Users/johndoe/Sites/ioncube/loader-wizard.php
on line 1252
Then I tried to copy it manually to the extension folder; this fails because of the missing rights (although I use the admin account):
$ sudo cp ioncube/ioncube_loader_dar_7.1.so
/usr/lib/php/extensions/no-debug-non-zts-20160303/
$ cp: /usr/lib/php/extensions/no-debug-non-zts-20160303/ioncube_loader_dar_7.1.so:
Operation not permitted
Next I installed the IoncubeLoader via homebrew. This seems to have worked at first glance:
$ brew search ioncube
==> Searching local taps...
homebrew/php/php71-ioncubeloader ✔
... but php -v doesn't show any installed IoncubeLoader extension, neither does phpinfo().
What more can I do to get Ioncube Loader running? Is there a reference to the homebrew installed loader missing? I am thankful for every hint!
I just used another way to solve the problem in my case. I am using MacOS High Sierra 10.13
I created a folder under the sudo mkdir /etc/apache2/my_extensions
Then I moved the ioncube extensions downloaded from ioncube.com
I copied the downloaded ioncube extensions to the new folder I created like so
sudo cp /Users/YOUR_USERNAME/Desktop/ioncube/* /etc/apache2/my_extensions
I had already extracted the compressed ioncube package to a folder called ioncube on my Desktop.
After that, I restarted apache using sudo apachectl restart
Then my ioncube issue was solved. Let me know if this helps.

CakePHP 3 Composer Installation Error

I am trying to create a project as shown in the official Bookmarker Tutorial using the following command:
composer create-project --prefer-dist cakephp/app bookmarker
Then I see the following errors:
[RuntimeException]
Could not load package cakephp/migrations in http://packagist.org:
[UnexpectedValueException] Could not parse version constraint >=0.4.2
<1.0: Invalid version string "0.4.2 <1.0"
[UnexpectedValueException]
Could not parse version constraint >=0.4.2 <1.0: Invalid version
string "0.4.2 <1.0"
Then I run bin/cake server and see the following errors:
PHP Warning:
require(/Library/WebServer/Documents/bookmarker/vendor/autoload.php):
failed to open stream: No such file or directory in
/Library/WebServer/Documents/bookmarker/config/bootstrap.php on line
23 PHP Stack trace: PHP 1. {main}()
/Library/WebServer/Documents/bookmarker/bin/cake.php:0 PHP 2.
include() /Library/WebServer/Documents/bookmarker/bin/cake.php:31
Warning:
require(/Library/WebServer/Documents/bookmarker/vendor/autoload.php):
failed to open stream: No such file or directory in
/Library/WebServer/Documents/bookmarker/config/bootstrap.php on line
23
Call Stack:
0.0010 227136 1. {main}() /Library/WebServer/Documents/bookmarker/bin/cake.php:0
0.0021 237624 2. include('/Library/WebServer/Documents/bookmarker/config/bootstrap.php')
/Library/WebServer/Documents/bookmarker/bin/cake.php:31
PHP Fatal error: require(): Failed opening required
'/Library/WebServer/Documents/bookmarker/vendor/autoload.php'
(include_path='.:/usr/local/Cellar/php55/5.5.21/lib/php') in
/Library/WebServer/Documents/bookmarker/config/bootstrap.php on line
23 PHP Stack trace: PHP 1. {main}()
/Library/WebServer/Documents/bookmarker/bin/cake.php:0 PHP 2.
include() /Library/WebServer/Documents/bookmarker/bin/cake.php:31
Fatal error: require(): Failed opening required
'/Library/WebServer/Documents/bookmarker/vendor/autoload.php'
(include_path='.:/usr/local/Cellar/php55/5.5.21/lib/php') in
/Library/WebServer/Documents/bookmarker/config/bootstrap.php on line
23
Call Stack:
0.0010 227136 1. {main}() /Library/WebServer/Documents/bookmarker/bin/cake.php:0
0.0021 237624 2. include('/Library/WebServer/Documents/bookmarker/config/bootstrap.php')
/Library/WebServer/Documents/bookmarker/bin/cake.php:31
My system is OS X Yosemite 10.10.2, my PHP version is 5.5.21 and intl extension is enabled.
Are there anyone who had this issue or similar? Any solutions?
Run following command first (you might need to prepend this with sudo if composer was installed globally)
composer self-update
then again
composer create-project --prefer-dist cakephp/app bookmarker
The latest way to install CakePHP 3.2 is:
curl -s https://getcomposer.org/installer | php
php composer.phar create-project --prefer-dist cakephp/app bookmarker
First find out which version of PHP you are using, and find out where it is located.
> php -v
PHP 5.5.34 (cli) (built: Apr 22 2016 19:16:58)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
> which php
/usr/bin/php
You need to have php version 7 as the primary one. I know of two options for you.
Copy the MAMP php file over to replace your /usr/bin/php file (you may also want to back it up.
(sudo mv /usr/bin/php /usr/bin/php5.5.34; sudo cp /Applications/MAMP/bin/php/php7.0.0/bin /usr/bin/php)
Order your system $PATH variable to the MAMP path for your php7 bin directory. You can also add this line to your ~/.profile so it will load every time you start the terminal.
export PATH="/Applications/MAMP/bin/php/php7.0.0/bin:$PATH";
Once these changes are made, you should be able to install cake without a problem, and your cake bake commands should also work.
if you go into your app folder and run
composer install
it might fix it.
If fix it for me!
Thanks

Cannot install PDO on CentOS

I know there is several instances of this question throughout stackoverflow but I am not finding a solution.
I am running CentOS with Apache and PHP 5.3
A .php script is giving me this error:
Fatal error: Class 'PDO' not found in ...
I ran phpinfo(); and the only place "pdo" exists on the page is in the "Configure Command" '--disable-pdo' line.
I attempted #yum install php-pdo but no packages exist.
I also attempted #pecl install pdo and i get these errors at the end:
/root/tmp/pear/PDO/pdo_dbh.c: In function 'pdo_stmt_instantiate':
/root/tmp/pear/PDO/pdo_dbh.c:410: error: 'zval' has no member named 'refcount'
/root/tmp/pear/PDO/pdo_dbh.c:411: error: 'zval' has no member named 'is_ref'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'pdo_stmt_construct':
/root/tmp/pear/PDO/pdo_dbh.c:435: error: 'zend_fcall_info' has no member named 'object_pp'
/root/tmp/pear/PDO/pdo_dbh.c:458: error: 'zend_fcall_info_cache' has no member named 'object_pp'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'zim_PDO_setAttribute':
/root/tmp/pear/PDO/pdo_dbh.c:752: error: 'zval' has no member named 'refcount'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'zim_PDO_getAttribute':
/root/tmp/pear/PDO/pdo_dbh.c:818: error: 'zval' has no member named 'refcount'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'pdo_hash_methods':
/root/tmp/pear/PDO/pdo_dbh.c:1122: warning: assignment discards qualifiers from pointer target type
/root/tmp/pear/PDO/pdo_dbh.c:1126: warning: assignment discards qualifiers from pointer target type
make: *** [pdo_dbh.lo] Error 1
ERROR: `make' failed
Then on the php.net doc it basically says the package comes standard in php installations since PHP 5.1.
I added the line extension=pdo.so to php.ini and restarted Apache and the problem persists. Any suggestions?
I too have had a similar issue. I am using codeigniter and was getting a "pdo_mysql.so not found" error and tried everything to fix it. I must of searched thru the first 10 pages of google search results for multiple queries. I found tons of people with the same problems but for some reason none of them had an answer/fix. Thru all this reading I learned that "PDO and the PDO_SQLITE driver is enabled by default as of PHP 5.1.0." This got me thinking, "Perhaps I should remove the extension=pdo_mysql.so and pdo.so lines from my php.ini!" I figured php was trying to load an extension that was no longer there since it comes built in now. Sure enough, solved all my php error mess.
PHP 5.4.31 (cli) (built: Aug 19 2014 10:38:48)
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
Server version: Apache/2.2.27 (Unix)
Server built: Aug 19 2014 10:33:30
Cpanel::Easy::Apache v3.26.5 rev9999
I'm pretty sure that you're missing the PHP_PDO package. Try to find the PDO package by running the command bellow:
# rpm -qa| grep "pdo"
Mine shows php53u-pdo-5.3.26-1.ius.el5
If you are using php 5.3 then try
# yum install php53u-pdo
I dont know if it is too late for the answer, but I'll post if someone finds this error.
First, I had installed php-pdo in Centos 7 with yum. I viewed phpinfo and it shows the pdo extension but not pdo-mysql.
So, If you then installs php-mysql (yum install php-mysql) it will install automatically the pdo-mysql extension.

Categories