Install PECL APC package for PHP
Posted by: Dequ (---.range86-133.btcentralplus.com)
Date: September 11, 2012 01:04AM

I have a specific requirement for Alternative PHP Cache for a Symfony2 project. I am using WAMP for my dev server but cannot get APC to install.

Any help would be much appreciated.

Regards
Neil
DEQU

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Charlie (---.nycmny.east.verizon.net)
Date: September 15, 2012 07:59PM

Hi Neil!

I am facing the same issue here. I need apc with Doctrine 2.

what exactly is the problem you are facing.

i get this error from apache 2.4.2:

PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.4.3/ext/php_apc.dll' - The specified module could not be found.\r\n in Unknown on line 0

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 08:03PM

both of you ... are you using 32 or 64 bit?

did you get the right addon


32 vc9 ts

or

64 vc9 ts

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Dequ (---.range86-138.btcentralplus.com)
Date: September 15, 2012 08:53PM

Hi Steve/Charlie,

I downloaded the 64 vc9 ts version and dropped it into the wamp/bin/php/php5.4.3/ext/ file but I was unsure whether I needed to make any changes to the php.ini file.

Whilst I have some help with you guys online, could somebody please explain dll files to me (what are they and how do they work) and also the significance of "thread safe". I know that this isnt necessarily the place to ask such questions but I always seem to work better with a bit of understanding!

And another quick Q...... The php.ini comes from the Apache folder rather than from the PHP folder (why?) so do I simply replace it with the php.ini.development file from the PHP folder (with a name change of course)?

Many thanks for the replies and I hope that I can quickly get a Symfony2 installation up and running!

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Charlie (---.nycmny.east.verizon.net)
Date: September 15, 2012 10:12PM

Hi Steve

I am using the 64 bit so I downloaded the 64 nts VC9.

apc extension isn't available in the official site so I've been using this source: [www.anindya.com]

Compiling the source myself was just over my head.
1- I added the dll file in "ext" directory
2- Restarted wamp and dll was listed in php extesions so I checked it
3- went to php.ini located in "bin" in apache directory and enabled apc there
4- Once again, restarted wamp. when I run phpinfo() apc isn't listed. apache produced the error i mentioned above.

In the link above, there was a version that wasn't nts so i tried that but wamp would crash on restart.

I am not sure what the problem is. I've been going at this for hours but no luck yet

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 10:23PM

Quote

I downloaded the 64 vc9 ts version and dropped it into the wamp/bin/php/php5.4.3/ext/ file but I was unsure whether I needed to make any changes to the php.ini file.

yes you must make a change to the php.ini if you are adding an extension that is not listed on the
wamp menu

left click wamp icon> php > extensions


place the file into
c:\wamp\bin\php\phpX.X.X\ext

left click wamp tray icon> php > php.ini

find the extentions section at about line 990 and add this line of code
extension=name_of_dll_file.dll

Left click wamp tray icon> Restart all Services

-----------------------------------------------------------


Quote

Whilst I have some help with you guys online, could somebody please explain dll files to me (what are they and how do they work) and also the significance of "thread safe". I know that this isnt necessarily the place to ask such questions but I always seem to work better with a bit of understanding!

Thread Safe and Non Thread Safe are too type of programming architectures that have to do with
how the processor is told to handle the code.

Now that processors have multiple threads, chunks of code that would have been run concurrently is not run simultaneously. Thread Safe code allows for this, and it more complex because you have to remember that shared memory could be written over etc..

So basically it depends how the software is compiled , Apache is compiled into both which both have different advantages/disadvantages depending on the use.


a DLL file is a dynamic link library. its very similar to an exe file, except that it cannot be run separately.
It must be called by an exe file to run. It basically a file full of useful code but that is generally for a specific task. This way we dont need to load millions of lines of code into ram just in case we need to use some function.

So for example APC is not included in the main php.exe because its not required by alot of people , adding it would make php slower.

Generally php dll files are just a bunch of php code that someone has written to make tasks alot easier, and then just compiled into a dll. When you include that dll , new functions can be used.

Again for example echo is part of the main php.exe because its used alot. but if i wanted i could make a echo that would write everything backward and call it becho. it would not be terribly useful, but if some peope wanted it, i could make a dll file with it and now the becho command would work when they add the dll.

This is a stupidly simple example - dll's generally perform a huge amout of work , like the mysql extension - it allows php talk to mysql , and although nowadays its nearly standard in web design to use this extension , its not part of the php.exe because they want to keep this php.exe REALLY small.

if you wanted you can compile php.exe again and include all these dll files into the exe , this would make things faster provided that you do require those extensions you added, because there is a small overhead to loading dll files and not having them static in the exe.

---------------------------------------------------------------------


Quote

And another quick Q...... The php.ini comes from the Apache folder rather than from the PHP folder(why?) so do I simply replace it with the php.ini.development file from the PHP folder (with a name change of course)?



You dont need to make any changes to php.ini names. They are already included in wamp.

Wamp is a little more complex when it comes to php.ini files because wamp has the ability to swap php/apache versions from the menu if you want other versions.

There is 2 php files in each copy of php

php.ini
phpforapache.ini

php.ini is used by the php cli, this is when your not using apache , and only want to run php from the command line .

phpforapache.ini is used when your using apache.
When you select a version of php on the menu, this phpforapache.ini is copied into the selected apache version and renamed php.ini

When you change to another version of php or apache, this file is first copied back into the php folder and then replaced.

So basically, Never edit the php.ini file from the folders. ALWAYS use the wamp menu

left click wamp icon> php > php.ini

This will ensure you are editing the correct php.ini at the time.

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 2 time(s). Last edit at 09/15/2012 10:24PM by stevenmartin99.

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 10:30PM

@Charlie

you need TS for sure

did you try both of these versions

Windows XP , Server 2003 , Vista > [www.mediafire.com]

Windows 7, Server 2008 > [www.mediafire.com]

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 1 time(s). Last edit at 09/15/2012 10:36PM by stevenmartin99.

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Charlie (---.nycmny.east.verizon.net)
Date: September 15, 2012 11:01PM

Yes I did Steven,

Apache crashes on restart and I get the following error:

pid file C:/wamp/bin/apache/apache2.4.2/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?

it's a different error compared to when i use a nts version which is:

PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.4.3/ext/php_apc.dll' - The specified module could not be found.\r\n in Unknown on line 0

Any thoughts on this.

Appreciate the patience

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Dequ (---.range86-138.btcentralplus.com)
Date: September 15, 2012 11:01PM

Thanks for the Info Steve....

Beginning to think I should have stuck to WordPress plugins for additional funtionality!
(Only joking, I am loving getting my head around new stuff and since I have no formal training, it is only by reading or asking daft questions in forums or simply trying stuff that I can learn).

I will try the suggested dll for Windows 7.


I am still a bit confused about the php.ini, sorry.
Let me try to see if I can explain how I understand it now from what you have so helpfully written above.

So I downloaded WAMP with PHP 5.4.3 and whilst I am in CLI, it will use the php.ini that is in the PHP folder of the WAMP.

However, when PHP is "invoked" from Apache, it uses the php.ini file that is in the APACHE folder. That php.ini is specific to the version of PHP that I have specified and if I change to, say, PHP 5.3.17, the WAMPSERVER will install a different php.ini file to work with PHP 5.3.17.

The next step is that I need to set up my WAMP server to be a development machine for Symfony2 and I have the following requirements and recommendations:-

Required
• PHP needs to be a minimum version of PHP 5.3.2
• Sqlite3 needs to be enabled
• JSON needs to be enabled
• ctype needs to be enabled
• Your PHP.ini needs to have the date.timezone setting
Optional
• You need to have the PHP-XML module installed
• You need to have at least version 2.6.21 of libxml
• PHP tokenizer needs to be enabled
• mbstring functions need to be enabled
• iconv needs to be enabled
• POSIX needs to be enabled (only on *nix)
• Intl needs to be installed with ICU 4+
• APC 3.0.17+ (or another opcode cache needs to be installed)
PHP.ini recommended settings
• short_open_tag = Off
• magic_quotes_gpc = Off
• register_globals = Off
• session.autostart = Off

So my plan was to copy the php.ini.development from the wamp/bin/php/php5.4.3 folder over the php.ini file in the Apache folder. But clearly from what you say, this is not correct. I have also complicated things a bit further because I have used the Extensions tab on the Wampserver Control Panel (via left click) to activate some additional extensions as per the lists above! I am assuming that by activatiing these additional extensions, the server is doing overwrites in the "active" php.ini file during the Wamp restart?

So I am guessing that the easiest way for me to proceed is to activate the extensions I require from the Control Panel and then open the php.ini file from the APACHE folder in my IDE (NetBeans) and to do any additional editing (enable xdebug and and point to its dll, plus the changes recommended for a development server, plus anything else in the list above).

You help on this is much appreciated Steve. And the explanation of dll is also a big help.

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 11:11PM

@Dequ

You have the php.ini correctly in your head.

when you want to manually edit it , you must do that from the menu.

left click wamp> php> php.ini


of course if you want it in your own IDE , then yes its the one in the apache folder

I dont see why you want to touch the development php.ini. its just a template and its not filled out correctly to run in wamp, the php.ini and phpforapache.ini are fine to use. Wamps php.ini should be ok for development purposes. and i think xdebug is enabled and can be modified on the wamp> php> php settings menu.

when you swap php versions, the php.ini in the apache folder is copied back into the previous php version phpforapache.ini and then the new php version phpforapache.ini is copied into the apache/bin folder

so if you make changes in php.ini for 5.3.4 you will need to also make these changes in 5.3.11 for example.
you should not just copy the file as i think there is still some hard coded file paths.

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 11:15PM

@Charlie

this is not an error

pid file C:/wamp/bin/apache/apache2.4.2/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?


Apache should still run.

if its not running and not writing anything else into the error log then you might have a syntax error

in cmd navigate to
c:\wamp\bin\apache\apacheX.X.X\bin

run the command
httpd -E log.txt

the log.txt file will be stored in c:\wamp\bin\apache\apacheX.X.X

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 4 time(s). Last edit at 09/15/2012 11:20PM by stevenmartin99.

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Charlie (---.nycmny.east.verizon.net)
Date: September 15, 2012 11:41PM

Thanks

I ran the command.

while executing the command, apache crashed. I restarted again and keeps on crashing.
the file was created in the the bin\apache\apache2.4.2 directory but nothing is being written in it. the error is still logged in apache error log which I point to by left clicking wamp and navigate to apache.

I should mention that when i remove the php_apc.dll file from the "ext" directory in php, the server doesn't crash

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 11:45PM

ok, i guess you will need to switch back to 32bit until that ext works, there is messages on anindya.com about apache crashing with APC further down

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Charlie (---.nycmny.east.verizon.net)
Date: September 15, 2012 11:57PM

very grateful for the guides Steven

I guess that's the only option. I really need to use apc.

I'll get to it right now and reply back here later on how it works out.

Thanks

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Dequ (---.range86-138.btcentralplus.com)
Date: September 16, 2012 12:12AM

Hi Charlie,/ Steve
So 64bit VC9 ts dll doesnt work?
I will look forward to you reporting back on the 32 bit version.

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Charlie (---.nycmny.east.verizon.net)
Date: September 16, 2012 02:06AM

Hello Neil/Steven

I am relieved and happy to inform that I finally got things running. I uninstalled the 64bit version of wamp and used the 32 bit instead. after that, i downloaded the dll file here: [downloads.php.net] (just in case Neil). Everything seems to be running smoothly now. I can finally take a break from this after struggling with it for a whole day.

Steven, I can't thank you enough for the help. I guess what's next is exploring how to use apc efficiently. I hear it could be tricky.

Thanks and keep on helping :-)

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Dequ (---.range86-138.btcentralplus.com)
Date: September 16, 2012 02:30AM

Thanks Charlie and good luck :-) !

Options: ReplyQuote
Re: Install PECL APC package for PHP
Posted by: Dequ (---.range86-133.btcentralplus.com)
Date: September 20, 2012 12:07AM

Hi Steve and Charlie,

Just a quick note to say I switched to 32bit WAMP and it has worked first time. All that remains is a simple Symfony2 install and the dreaded "Compsoer" update to the vendors files! sad smiley
I think my next stop may be the Symfony Forums!

Thanks for all of the help.

Options: ReplyQuote


Sorry, only registered users may post in this forum.