Install APC on Windows - php

How can I install APC on Windows? I am using PHP 5.3, Windows 7 x64.
I used
pecl install apc
I got
C:\PHP>pecl install apc
downloading APC-3.0.19.tgz ...
Starting to download APC-3.0.19.tgz (115,735 bytes) ............
done: 115,735 bytes 47 source files, building
WARNING: php_bin c:\php\php.exe appears to have a suffix \php.exe, but config
variable php_suffix does not match running: msdev APC.dsp /MAKE "APC - Release"
ERROR: Did not understand the completion status returned from msdev.exe.

Installing an extension with the pecl command means :
downloading the sources
compiling them
And, generally speaking, a windows machine doesn't have what's required to compile software like PHP and/or PHP extensions.
A better / easier solution, in your case, would probably be to find a pre-compiled .dll of the extension, that matches your system and your version of PHP.
With a bit of luck, maybe one of the versions provided on http://downloads.php.net/pierre/ could be OK ?
(It's what kind of acts as replacement of the old pecl4win, until the extensions for windows are available on windows.php.net)
For more informations about which version you should use, take a look at the Which version do I choose? section, in the left side-bar of http://windows.php.net/

It is not really important, whether you are running Windows 32-bit or 64-bit version. What matters is what Apache (webserver) version you have installed (32/64). Since lots of PHP extensions (like APC) are not available for 64-bit systems, most common setup is as follows:
Operating system 32 or 64-bit (not really important). Apache 32-bit will run easily on Windows 64-bit. The difference is, that for 32-bit apache you MUST install PHP 32-bit. Once you install 64-bit PHP, you may find difficult to install some extensions - there are almost no extensions available for 64-bit PHP platform.
therefore your webserver should be 32-bit if you care about special extensions, like APC, Imagick etc... Also you need to know if your apache is thread safe (TS) or not thread safe (NTS) and whether it has been compiled in Visual Studio 6 (VC6) or newser Visual Studio 2008 (VC9). You will easily find all this info from phpinfo() function.
as for the APC, some nice compilation for Windows are available from http://dev.freshsite.pl/php-accelerators/apc.html.

For php 5.3 you use php.net/pierre/php_apc-3.1.10-5.3-vc9-x86.zip.
Download it and copy php_apc.dll to your php ext directory. (I choose the file under ts I have thread safe php installation. There is also an apc dll file for non thread safe.)
Add extension=php_apc.dll into your php.ini file
Restart your web server
Run phpinfo() to see if it's installed or not.
I am using php 5.4 and I downloaded php.net/pierre/php_apc-3.1.10-5.4-vc9-x86.zip and its working fine.
Hope this will help mate.Good luck.

Also, make sure that the compiled version from here http://downloads.php.net/pierre/
matches your php version, otherwise the extension will not load (php v. 5.2.17 requires php_apc.dll v 5.2.17.17 - which doesn't seem to be available as of this writing - I had to downgrade the php version to play with apc).
Another point, pierre's zip packages, at least the one I downloaded, did not include the management script. you can get it from here: http://pecl.php.net/package/APC - select the version you downloaded, then navigate to Browse Source, then find your version in the 'tags' folder. the apc.php script should be there.

There's no available version for php > 5.4.
I'm using APCu instead. Just download the dll and reference it in php.ini.

This website offers updated dll and installers for Apache, PHP and APC compiled to work on windows 64 bit. I've been using it for a while and it works fine. You could an APC version compatible with PHP 5.3.22 here

Related

ioncube installation error on apache 2.4

I'm unable to make ioncube encoder work with Apache 2.4.12 and PHP 5.5.8. So, this is what I've done by now:
1. Installed httpd-2.4.12-win32-VC11 [http://www.apachelounge.com/download/]
2. Installed php-5.5.8-Win32-VC11-x64.zip [http://windows.php.net/downloads/releases/archives/]
Their raw combination works ok - I can run php scripts etc. I then:
3. Installed ioncube for Windows VC11 (64 bits) [https://www.ioncube.com/loaders.php]
I made corrections to php.ini and when I do php -m I see that it loads ioncube extension without any errors. However, when I now start Apache I get an error with a message about zend_get_hash_value and php5ts.dll. (PS. Combination with Apache 2.2, PHP 5.4 and ioncube works for me, but it seems rather outdated).
It seems like you have mismatched the thread-safe version of Apache and the ionCube Loader. PHP extensions have to match exactly the version that they run on, that is PHP with thread-safety enabled has to have a thread-safe Loader.
To confirm this, go to the output of your phpinfo(); and look for the entry Thread Safety. If it says disabled, make sure you have the Non-TS version of the ionCube Loader (Win x64 Non-TS zip). Likewise, if it says enabled, make sure you have to thread-safe version of the Loader (Win x64 TS zip).
Furthermore, please consider using 32bit PHP / Apache on Windows, as PHP 64bit is still marked as experimental and can cause issues with the ionCube Loader:
The x64 builds of PHP for Windows should be considered experimental, and do not yet provide 64-bit integer or large file support (source)

Magic library does not run on wamp server

I am using magic library to change the resolution of the images. But I am getting following error when I am running the Wamp.
I am also sharing links of the website I have followed.
Link
http://www.zoharbabin.com/5-steps-to-get-imagemagick-on-xampp-1-7-3/
These are step by step instructions on how to get ImageMagick running under PHP in a Windows environment. Apache does not provide binaries for Windows and relies upon several sources to do so:
XAMPP
WampServer
Apache Lounge
Bitnami
Apache Haus
It is recommended to download either the XAMPP or WampServer distributions as they are complete packages that contain Apache HTTP server, PHP and MySql known and tested to work together.
Making ImageMagick work was not easy for me. It took two days of trial and error to get this to work. Hopefully this will help you get up and running faster. I have this running on the following:
Windows 7 Home Edition 64-bit
XAMPP 5.6.3
Apache HTTP 2.4.10 (Win32), VC 11
PHP 5.6.3 x86 VC 11, Thread safe
Thus, a 32-bit web framework compiled with VC 11 and thread safety enabled all running on 64-bit Windows 7. You must choose a 32-bit ImageMagick DLL distribution along with a 32-bit VC11 thread safe DLL wrapper to match.
The instructions below should work equally well with WampServer as there is no dependency on the Windows web framework.
The important thing to understand here is that you must know your web server environment and what components are installed and built with. you must match bitness, Visual C runtime, and thread safety configurations together.
Step #1: Install imageMagick to C:\ImageMagick
Go to Link and download the latest release. Use the 32 bit DLL version (ImageMagick-6.9.0.0-Q16-x86-dll.exe)
Install it into C:\ImageMagick directory
Step #2: Get the PHP wrapper from the Windows PECL repository
Go to http://pecl.php.net/package/imagick
Get the latest stable version, 3.1.2. You want the 32-bit, VC 11, thread safe version
php_imagick-3.1.2-5.6-ts-vc11-x86.zip
Step #3: Create distribution directory
Create a /php/ext/imagemagick directory
Copy the ZIP into it and unzip it
Step #4: Make backup copy of DLLs
Make a C:\ImageMagick\Backup directory
Copy DLLs in the C:\ImageMagick directory to the C:\ImageMagick\Backup directory
Step #5: Overwrite DLLs
This is the most important step that if you don't do, will result in the PHP wrapper not loading correctly:
Take all the DLL files in \php\ext\ImageMagick and overwrite those in C:\ImageMagick
If you do a SET on the DOS command line you will see that the ImageMagick installer had created a entry into the system variable environment path (i.e. to C:\ImageMagick). Supporting DLLs will be picked up from there and they will be the Pecl Windows repository DLLs, not the distribution.
Step #6: Set module extension in PHP.INI
First, copy the php extension wrapper php_imagick.dll into the /php/ext directory. Then modify the PHP.INI to do this:
extension=php_imagick.dll
Step #7: Reboot Apache
Reboot Apache
Go to phpinfo and see that imagick is installed as a module.
Here's where you can learn more about your environment.
Pay attention to stuff in phpinfo like:
Compiler: MSVC11 (Visual C++ 2012)
Architecture: x86 (32 bit; as opposed to x64 which is 64 bit)
Thread safety: enabled (TS)
Apache Environment Configuration (PATH should have C:\ImageMagick included)
More gory details: Installing ImageMagick with PHP and Windows

How to install pthreads on a phpfarm php installation

Documenting my struggles to help others and hopefully get some feedback on how I could have done it better.
The command pecl install pthreads fails due to the php installed on my ubuntu 13.04 box not having zts configured.
Options:
1) The ubuntu respository does not have a php package with zts enabled. As of this post, ubuntu only has php 5.4.9 in it's repository (Released: 22 Nov 2012). It is possible to compile a php version from source - which I eventually did (see below), but..
2) I .. ALSO .. wanted to use phpfarm for the ability to run different versions of PHP on my local setup. On github, there is Christian Weiske's original contribution here (phpfarm) and a fork that he has contributed to, by François Poirotte - also called phpfarm. Francois' fork has a few more options to configure ('post-install customization') but I was not able to make that work with a PECL extension. I'm curious to know if misunderstood how to do that, because it looks to me that it just simply does not take PECL commands.
3). Prior to recompiling php from source, I loaded phpfarm (tried both versions), enabled php-fpm (FastCGI) and was able to get my apache2 server to use a phpfarm version (5.5.10) which showed up in a phpinfo() output. But the php-cli always showed the original php version (5.4.9) in the cli (run: php -v). Running (run: php -i | grep php.ini) showed /etc/php5/cli but I had previously removed php5 and aptitude show php5 returned a state of 'not installed.' I even renamed the /etc/php5 directory to see if I could force the system to use the phpfarm php version. Obviously, this is incorrect thinking and I went on to simply compile php 5.6 from source. But, is there something more to do to get a phpfarm php to be used in the cli? I read that the cli loads it's configuration file on a per command basis, unlike the apache2. If I could have run the 5.5.10 version (configured with zts) then I could have then done pecl install pthreads and then re-complied the phpfarm 5.5.10 version with pthreads enabled. Although it appears I will be able to run various versions of php in the apache server, will I ever be able to switch-phpfarm to another version and see it working in the php-cli? Also, I was uncertain on where I could have loaded a pthreads file for the phpfarm compile process to find and use it; could I have done it that way?
4) This stackoverflow post, essentially posted by Joe Watkins - the developer of pThreads is a perfect how-to on getting pThreads installed on a Ubuntu system that has had php configured with zts (Zend Thread Safety). (Thanks Joe!)
A nice tutorial on using phpfarm configured with fast-cgi and the apache server to help run websites under different php configurations.
So what gives with php, php-cli and the phpfarm?
I'm not sure about phpfarm, but do know of another solution ...
Multi
A tool for maintaining multiple installations of PHP in multiple configurations
https://github.com/datingvip/multi
This is a bit more user orientated, will allow you to build many configurations and versions of php, any tagged release of php, and any patched version from any fork of php-src.
In addition, because I wrote it, it will install pthreads for you.
git clone https://github.com/datingvip/multi
cd multi
VERSION=5.5.10 DBG=no-debug ZTS=zts ./php.multi
The above commands will yield an installation of PHP (in one suitable configuration, of one version) in /opt/php.
Look at php.defaults for configuration options and adjust before building
Should configuration fail on, for example, something related to a library like libxml2, it will usually be the case that
sudo apt-get install library-dev
Where library is replaced with the name of the library holding up the build, will fix the problem for you. If it does not, a quick google should get you going again.
Once the build is complete
source /path/to/multi/php.env 5.5.10
Note: multi will always install pthreads for any zts version automatically
I hope that gets you somewhere ...

Compiling a PHP extension as non-thread-safe

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/

WAMPSERVER php_memcache extension

I have a copy of php_memcache.dll (from php_memcache-2.2.6-5.3-nts-vc9-x86.zip) which I have placed in my C:\wamp\bin\php\php5.3.5\ext folder.
In WAMP I can see php_memcache in my extensions list, however whenever I start the extension I get the following warning:
PHP Startup: Unable to load dynamic
library
'C:/wamp/bin/php/php5.3.5/ext/php_memcache.dll'
- The specified module could not be found.
This does not happen for any other extension that I can turn on or off.
Have tried moving php_memcache.dll to C:\windows\system32 but makes no difference.
Any ideas?
Your extension probably not fit the compilation mode of wampserver.
Is it compiled with vc9 (visual 2008) and a non threads safe support ?
My wampserver (latest available) is compiled in VC6 TS.
To know this info check phpinfo() on line :
Compiler
Thread safety
I'd suggest trying other versions of the dll.
2.2.5.0 works for me using WAMP.
The VC9 builds are the only supported builds. VC6 (which is used as convenience builds by Apache) is not supported anymore.
Latest PHP version (and PELC extensions) are only available as VC9 builds. Xamp are already moving their suite to VC9, other already did. You can also do it yourself using apachelounge.com builds, which are the ones we recommend to use with PHP Binaries.

Categories