So I've installed 64bit Apache/PHP locally. Both Apache and PHP were compiled against the VC11 C++ redistributable.
https://www.apachelounge.com/download/VC11/ and
http://windows.php.net/download/ PHP5.6 (Yes... ) x64 Thread Safe (respectively)
Both work fine! (screenshots with version and architecture info inc.)
I've downloaded multiple varaities of the 1.6.x driver from both PECL and an repo' at Amazon.
https://pecl.php.net/package/mongo/1.6.14/windows
https://s3.amazonaws.com/drivers.mongodb.org/php/index.html
I've made sure they're the x64 Thread Safe variety and added to my ~/php/ext folder.
I've made sure the extension is loaded in php.ini (and that the write .ini file is called):
extension=php_mongo-1.6.8-5.6-vc11-x86_64.dll
But everytime I restart Apache I get this in my PHP error log:
[07-Jun-2017 20:21:20 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'E:\PHP5.6\ext\php_mongo-1.6.8-5.6-vc11-x86_64.dll' - %1 is not a valid Win32 application.
(Apache comes up clean. Error.log clean)
Why is it protesting that this is not a Win32 Application. I don't want it to be. My entire architecture is 64bit and so is the Mongo Driver.
In case anyone else comes across this thread. After hours of trying to get it to run I just downgraded everything to 32-bit. Worked right out the gate.
Despite PECL offering a "64bit" driver - https://pecl.php.net/package/mongo/1.6.14/windows it didn't seem to be compatible with 64bit/VC11/Thread Safe versions of Apache/PHP
I'm not sure if this is an issue with the Mongo driver compilation or something deeper?
Anyway. Downgrade to 32-bit. Mongo 1.6.x drivers will then run.
From php.net
In order for this extension to work, there are DLL files that must be available to the Windows system PATH. For information on how to do this, see the FAQ entitled "How do I add my PHP directory to the PATH on Windows". Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the system's PATH), this is not recommended. This extension requires the following files to be in the PATH: libsasl.dll
http://php.net/manual/en/mongo.installation.php#mongo.installation.windows
Simply copy libsasl.dll from your PHP directory to your Apache\bin directory and restart Apache.
It is possible that a dependency is missing. Where I suspect that to be libsasl as alluded to in the comment at http://php.net/manual/en/mongodb.requirements.php
The libsasl.dll can be found in the PHP distribution.
Related
Today I was doing updates in my WAMPP stack. So, I downloaded a new version of PHP, 7.3.33.
I replaced the PHP directory on Apache to use the new PHP cgi-bin.
But Postgresql started complaining about cram-256-sha and libpq version lower then 10.
I tried to copy the libpq.dll and his dll dependencies libcrypto-1_1-x64.dll, libintl-8.dll and libssl-1_1-x64.dll to extension_dir of PHP installation.
PHP runs but now the driver is not available for pgsql.
I read some questions here but all seen to be using the PHP as an Apache module in spite of cgi-bin.
Someone knows how to do this? Expected that any program linked with pgsql should be able to connect to the database.
I'm having trouble installing Zend Debugger on Windows 10 64-bit. I have PHP 8.0.1 installed, 64-bit version.
I have downloaded the ZendDebugger.dll from Zend (also 64-bit) and placed in my "ext" folder, and the php.ini file updated accordingly.
When I try running php from the command-line I get:
PHP Warning: Failed loading Zend extension 'ZendDebugger.dll' (tried: ext\ZendDebugger.dll (%1 is not a valid Win32 application), ...
This indicates that it has found the file, but cannot utilise it as it is the wrong architecture. This error message implies the .dll file is indeed 64-bit, but I do not understand why a 32-bit version is expected. Running php -i from command-line, and phpinfo() under Apache both suggest everything is 64-bit.
I have trawled the internet for an answer but have turned up nothing.
What am I missing?
I dont know if you have solved the problem.
I solved this moving the ZendDebugger.dll to php8.1 folder, not ext folder,
and adding the flowing lines after the "extension=zend_test in the php .ini file.
Windows non-thread safe: zend_extension="D:\wamp64\bin\php\php7.4.26\ZendDebugger.dll"
zend_debugger.allow_hosts=127.0.0.1
**Change the ip address if you debug in remote server.
I'm currently setting up a Windows 10 Pro x64 machine to work with Apache, PHP and its oci8 extension.
I successfully managed to get oci8 working on OSX 10.11 and Windows 2012 Server before, so I thought I knew what to do. But this was 32bit – now it's 64.
The software now installed is:
Apache 2.4.18 x64
PHP 7.0.3 TS x64
Oracle Instant Client x64 (instantclient-basic-windows.x64-12.1.0.2.0)
oci8 2.1.0 TS x64
I don't get it to work. The error message is:
Warning: PHP Startup: Unable to load dynamic library
'ext\php_oci8_12c.dll' - Das angegebene Modul wurde nicht gefunden. (Module not found.)
in Unknown on line 0
Extension 'oci8' not present.
I installed the Oracle Instant Client by writing its directory into the PATH variable and copied the php_oci8_12c.dll file to the PHP ext dir and uncommented the corresponding line in the php.ini. Shouldn't that be enough?
I've read many postings here on Stackoverflow and other websites about similar problems, things I've tried:
Moving all DLLs to C:\Windows\system32
Include the PHP extension dir in the PATH variable
Re-checked that every component is 64bit
Created ORACLE_HOME and ORACLE_BASE variables (which shouldn't be necessary)
If I change the php_oci8_12c.dll x64 to the 32bit one, I get a different error message:
Warning: PHP Startup: Unable to load dynamic library 'ext\php_oci8_12c.dll' - %1 ist keine zulässige Win32-Anwendung. (%1 is not a valid Win32 program.)
in Unknown on line 0
Extension 'oci8' not present.
Any ideas what's wrong with all that?
Thank You!
To sum it all up,
One more thing... NTS assumes that PHP does not run as Apache module,
is that correct? Are you using FastCGI? – Álvaro González
was the way to go. If anyone's having troubles with the same, here are the exact steps I took:
PHP 7.0.3 VC14 x64 Thread Safe from windows.php.net/download/
Apache 2.4.18 x64 from apachehaus.com/cgi-bin/download.plx
Oracle Instant Client 12.1.0.2.0 x64 from oracle.com/technetwork/topics/winx64soft-089540.html
(Get the current Thread Safe oci8 DLL from pecl.php.net/package/oci8, but PHP comes with a version of it - worked with either for me)
Install PHP as an Apache module. Unzip the Instant Client and move it to your desired location. Add this location to your PATH system variable. Restart your machine and it should show up under 'PATH' in your phpinfo().
Then I had to make the PHP extension_dir an absolute path. So no 'ext', but 'C:/Program Files/php-7.0.3/ext'. With only 'ext' set to the extension_dir I could connect to a remote Oracle DB via 'php.exe filename.php'. But Apache would throw me an error in error.log that it cannot find the DLL.
No DLL copying is needed if you choose to keep the oci DLL that comes with PHP. No more environment variables than PATH have to be changed/created.
At least in my case :-)
I am trying to compile the imagemagick (imagick) extension to use in a non-thread-safe environment on windows.
I am using PHP 5.3.10 and have set up Visual C++ express as my compiling environment.
The problem is that I am using a non-thread-safe version of PHP as a FCGI module in Apache 2.2.
Thus, my PHP is supplied with a php5.lib and not a php5ts.lib. I believe this is the reason why I am getting these errors:
imagick.obj : error LNK2019: unresolved external symbol __imp__tsrm_mutex_alloc referenced in function _zm_startup_imagick
I have only ever built and compiled things on linux, so am not too sure how to do this on a windows environment.
How can I compile the extension so that it is non-thread-safe?
I downloaded the threadsafe binary of PHP 5.3.10 to get a copy of php5ts.lib. I was then able to compile the extension.
I am guessing that setting the ZTS preprocessor directive to either 1 or 0 would cause the extension to compile as either threadsafe or non-thread-safe. (Not too sure about this, so if someone could let me know if this is correct or not, it would be much appreciated. :) )
I then set up a virtual machine running Windows 7 and installed the latest version of WAMP. Reason being that it used a threadsafe version of PHP.
I placed the dll in the ext folder in the PHP installation and enabled it in php.ini. However, even after trying both the ts and nts version in WAMP, I would get:
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.3.10/ext/imagick.dll' - The specified module could not be found.
in Unknown on line 0
But the thing is that c:/wamp/bin/php/php5.3.10/ext/imagick.dll' does exist, and yes I have checked this a lot of times.
I then downgraded ImageMagick to 6.6.2-10-Q16, but still see the same problem.
The same issue occurs on my dev machine running a nts version of PHP 5.3.10 on Apache 2.2 (all installed manually).
Looks like I could be wrong regarding the ZTS preprocessor. If I set ZTS=0 and compile, using dependency walker on the compiled dll still shows that it requires php5ts.dll which is only present on threadsafe versions of PHP.
I did more tinkering with dependency walker and found that I had to statistically link to msvc100d.dll. I then removed ZTS in the preprocessor definition and was able to compile using php5.lib instead of php5ts.dll. I think this should get me a non-ts dll.
However, when loading the extension, I am still getting:
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'imagick.dll' in Unknown on line 0
And errors from dependency walker:
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
Installed visual c++ express 2008 and compiled using platform toolkit v90, but still facing the same issues.
Any tips appreciated :)
Solution Found! See my answer.
Got it! I hope this can help those compiling php extensions on windows in the future. What I have done is based on: https://wiki.php.net/internals/windows/stepbystepbuild
Note: I read an answer on this site that said compiling PHP extensions by itself on windows is unsupported. Based on my experiments yesterday, it seems to be a lot of work as well, so I am using the PHP build process.
The best way is to use the PHP build process.
Install Visual C++ Express 2008 (any version will do, but express is free) and Windows SDK 6.1 (note that we want the 6.1 version not anything older or newer).
Install the SVN client tools if you haven't done so and restart for your PATH variable to take effect.
Get the PHP SDK binary tools and extract it to C:\php-sdk.
Start the CMD Shell under Microsoft Windows SDK v6.1 in your start menu and run cd C:\php-sdk.
Run setenv /x86 /xp /release this creates a 32-bit release. You can use /x64 to build a 64-bit release (I have not tried this).
run bin\phpsdk_setvars.bat
run bin\phpsdk_buildtree.bat php53dev
Download the PHP source code and extract it to C:\php-sdk\php53dev\vc9\x86 so that you end up with C:\php-sdk\php53dev\vc9\x86\php5.3-xyz
Download the latest deps and extract everything to C:\php-sdk\php53dev\vc9\x86. You may be prompted to overwrite any existing folders, so press yes.
run cd C:\php-sdk\php53dev\vc9\x86
Check out the latest version of your extension from the svn repository: svn co http://svn.php.net/repository/pecl/imagick/trunk pecl/imagick I am checking out imagick here.
Install any dependencies. In my case, I need to install ImageMagick, so I downloaded the latest recommended windows binary. You will need to restart after installation to update your PATH variable, but you can do this after you have compiled. Make sure you install the C/C++ headers and includes as well.
Copy the contents of the includes directory from the ImageMagick install directory to C:\php-sdk\php53dev\vc9\x86\deps\include.
Copy the contents of the lib directory from the ImageMagick install directory to C:\php-sdk\php53dev\vc9\x86\deps\lib
Now, let's build: run cd C:\php-sdk\php53dev\vc9\x86\php5.3-xyz then buildconf then configure --help. Look at the help properly. It will show you all config flags and any avaliable extensions to enabled. In my case, since I added imagick, I had an option called --with-imagick
Run config: configure --enable-cli --with-imagick=shared --disable-zts If you want to build a non-thread-safe binary use --disable-zts, otherwise remove that configuration flag. I am not sure why, but sometimes extensions use the --with-myextension flag and sometimes --enable-myextension, so check configure --help for the flag to use. If you add =shared after the extension flag, it will be compiled as a separate DLL, which si what we want.
Compile: run nmake then nmake snap.
Done :) Check C:\php-sdk\php53dev\vc9\x86\php-5.3.10\Release (non-thread-safe) or C:\php-sdk\php53dev\vc9\x86\php-5.3.10\Release_TS (thread-safe). Your compiled binaries should be in there. The compiled extensions (pecl), should be in a ZIP file similiar to pecl-5.3.10-nts-Win32-VC9-x86.zip. Open this file and extract the extensio DLL to your ext folder in your PHP installation.
Enable the PHP extension and restart your webserver. Run phpinfo() and check that the extension is enabled.
If the extension does not work properly, make sure you reboot to update your PATH variable. In my case, I need to have the imagemagick install directory in my PATH variable.
???
Profit!
Is there a reason you need to compile? Why not download? It's usually much simpler/quicker on Windows.
VC6: http://www.sk89q.com/2010/03/vc6-windows-binaries-for-imagick-2-3-0/
VC9: http://valokuva.org/builds/
I found lots of articles about this problem, however none of them helped me.
Here is a I list of what I 've already tried:
uncomment the semicolon on php.ini
add the dependence file (libmcrypt.dll) on php folder, windows and
windows/system32
I 've restarted the IIS Server after each attempt
I cannot use this method, it was installed with a zip file.
On IIS Manager the extension is shown as enabled but checking the php error log I found this message multiple times:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\v5.3\ext\php_mcrypt.dll' - %1 is not a valid Win32 application. in Unknown on line 0
Here is a the screenshot of phpinfo()
I have Windows Server 2008 R2 64bit with IIS 7.5 and PHP 5.3.10. Maybe the file (php_mcrytp.dll) is not the good one, where can I download it? On php site I cannot find the php_mcrytp.dll file under ext folder.
Thank you
If you downloaded PHP for Windows from php.net and are running the FastCGI version of PHP (as you should with PHP 5.3.x and IIS), mcrypt library is already compiled statically in the PHP engine. You don't need to install any extra DLL.
If you see the mcrypt section in phpinfo's output then it means mcrypt is already enabled (otherwise the mcrypt section would be missing).
And that's also the reason there is no mcrypt DLL.