How to install custom PHP extensions?

Post your questions about Web Server usage and Apache + PHP + MySQL/SQLite web applications.
ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

How to install custom PHP extensions?

Post by ghis123 » Sun Nov 24, 2013 4:56 am

Hello,

I'm looking into compiling/installing custom PHP extensions, which took me few days just to finally be able to compile them successfully (I'm not good with Linux) and I now even though I tried adding 1 extension apc.so into my modules folder and editing my php.ini, it never shows up in my phpinfo??? Ok then I found another caching module I could try, I compiled it and again copied the file into the /usr/local/apache/modules/, but still it does not work.

I found another topic here which is about installing an extension as well, and read that we can't install custom build extensions by default...really????

Please help, I just want a decent caching module!!! No... eAccelerator is not decent one, since it doesn't work with anonymous functions, hence my Laravel framework does not work with it.

Thanks for help

ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

Re: How to install custom PHP extensions?

Post by ghis123 » Mon Nov 25, 2013 1:11 am

Hello Philippe,

Thanks for your help and then yes I will keep this thread over the French one since there is probably more people interested in this, I never imagined that someone could actually answer on both hehe... but since I'm dying to fix this problem, I asked on both forums.. :S

So let's start, well first of all I am trying to install a caching extension/module called APC (Alternative PHP Cache) and all the process I went through was described on another topic on this forum.. http://forum.qnap.com/viewtopic.php?f=32&t=8390
I had lot of help from another user Teracow, he helped me a lot with compiling the thing...
Basically I had to start by installing a bunch of GNU Tools, like (grep, libtool, perl, autoconf, m4, php-dev, pcre-dev ...)

Code: Select all

# ipkg install grep
# ipkg install libtool
# ipkg install perl
# ipkg install autoconf
# ipkg install automake
....etc...

Please note that as per Teracow indication, I also had to change my $PATH to be /opt/bin and /opt/sbin should now come before /bin and /usr/bin

Then after this I went and download and install the module

Code: Select all

# wget http://pecl.php.net/get/APC-3.1.13.tgz
# tar -xzf APC-3.1.13.tgz
# cd APC-3.1.13
# phpize
# ./configure --enable-apc --enable-apc-mmap --with-php-config=/opt/bin/php-config
# make
# make install


Then the final step is to take the compiled apc.so and move it into the modules directory of our actual PHP, so I then open my php.ini file and get the path of the extension directory to be

Code: Select all

extension_dir = /usr/local/apache/modules



I might as well, add this piece of code at the end of my php.ini since I will need it later to activate the APC extension.

Code: Select all

[APC]
extension=apc.so
apc.enabled=1
apc.shm_size=32M


Then afterward I am doing the copy of the apc.so file

Code: Select all

[~/APC-3.1.13] # cp /opt/lib/php/extensions/apc.so /usr/local/apache/modules/



Then I check with the software WinSCP and I do see the file showing up in the folder, so I restart the server:

Code: Select all

/etc/init.d/./Qthttpd.sh restart


So that's it, those were a resume of all my steps needed to compile and install.
But the thing is that, it seems the install of PHP on QNAP does not take any external modules, because I also tried installing another caching module I found (Xcache) and I had the same results, which means nothing showing in phpinfo

Thanks a lot for the help
Ghislain

ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

Re: How to install custom PHP extensions?

Post by ghis123 » Mon Nov 25, 2013 8:20 am

Hmm if I read correctly, you are saying that I should do this on another Linux box? Then I do not have access to any... and I am not good at all with Linux Shell, I just manage to pass through the compilation process because I got help and instructions... and unfortunately, you are really losing me with your explanations, I don't know what is a cross-compilation and all that... This is kinda really going deep to just have 1 simple caching module activated... I wish someone could make an QPKG or at least something easier... Is there a simple way to do with just the NAS Linux? I'm on M$ Windows here, and that is what I'm familiar with... I use putty and WinSCP to connect to the NAS

ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

Re: How to install custom PHP extensions?

Post by ghis123 » Mon Nov 25, 2013 9:40 pm

Thanks I would gladly appreciate

Ghis

ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

Re: How to install custom PHP extensions?

Post by ghis123 » Tue Nov 26, 2013 10:34 am

Yes it works...finally :D

By the way, I do not know the ipcs commands, but I'll look into it..

and for the future, if I find a friend with a Linux box, the process would be to install the SDK of ARM and compile the way I wrote with wget, and the rest of my procedure but on a that box instead of my NAS, is that it?

Thanks a lot for your help Philippe, I can finally go back to coding =)

ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

Re: How to install custom PHP extensions?

Post by ghis123 » Tue Nov 26, 2013 11:29 am

Actually I don't see the difference either, it doesn't seem to cache anything even if it shows as online.. I got the apc.php from this site http://jesin.tk/apc-php-download/ so that we can see the usage and logs of it...but it always stays at 0 cache files, 0 used, etc... I'll have to dig more into the configuration to put in the php.ini and I used the configuration found on this site http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/#lightbox/0/ but I'm not sure about where it caches it

ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

Re: How to install custom PHP extensions?

Post by ghis123 » Wed Nov 27, 2013 10:58 am

Now I'm starting to wonder if the apc.so you gave me is actually working since it does not doing what it's suppose to, at least I cannot find anything like this from other users. When everything is enable, I check with phpinfo and it's enable but then wherever I want to go in my site, the phpinfo will show over and over, so basically it seems to be displaying the last page only which in my case is phpinfo.

Philippe if you have a chance, can you try with some simple config

Code: Select all

[APC]
extension = apc.so
apc.enabled = 1
apc.shm_size = 12M
apc.optimization = 0
apc.cache_by_default = 1
apc.localcache = 1
apc.localcache.size = 512


When you have apc.enabled=1 and apc.cache_by_default=1, you need both enable for it to cache. Everything goes all wrong with I enable the cache, but if disable it and leave the APC enabled then the problem goes away. it looks like the extension is not working properly.

Thanks for help

ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

Re: How to install custom PHP extensions?

Post by ghis123 » Wed Nov 27, 2013 9:57 pm

oh wow sorry to have cut your lunch, wasn't expecting that much. Please take the time to live, even if it's for the weekend, it's all good too!!!

As for the PHP version you are possibly right, the documentation is so limited (only change logs) it's open source after all, in this case take the latest stable APC version 3.1.9 and it seems they added php 5.4 support in the next version right after it, so it looks like apc 3.1.9 was dedicated for php 5.3. My understanding was that adding support to next version of php doesn't remove support for previous, looks like I was wrong in this case.

http://pecl.php.net/get/APC-3.1.9.tgz

again sorry to cut down on your lifetime, though I really appreciate your help. I just woke up here in Montreal with actually the first snow (10 cm) oh well... Next time you come to Montreal, let's go out and have a drink...or 2..hehe

Thanks from your cousin in Montreal
Ghislain

ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

Re: How to install custom PHP extensions?

Post by ghis123 » Thu Nov 28, 2013 9:00 am

Thanks Philippe, I downloaded your next apc.so and it seems to have the same effect even though I added the path of apc.preload_path=/share/Web/temp/ and the folder as suggested. But as for the extension of igbinary.so I don't have it, so yes I would be happy if you could send me as well, that might be my problem, did you see this in the error log? I still don't have mine enabled, since I'm not sure how to do it.

I reused the same config as you said, though apc.cache_by_default=1 needs to be enable, if not it won't cache, your configuration shows 0, did you enable it afterward?
Here is the config I used:

Code: Select all

[APC]
extension = apc.so
apc.enabled=1
apc.cache_by_default=1
apc.shm_size=8M
apc.preload_path=/share/Web/temp/


and the result of your command

Code: Select all

[~] # /mnt/ext/opt/apache/bin/php --ri apc -c /etc/config/php.ini

apc

APC Support => disabled
Version => 3.1.9
APC Debugging => Disabled
MMAP Support => Disabled
Locking type => pthread mutex Locks
Serialization Support => broken
Revision => $Revision: 308812 $
Build Date => Nov 27 2013 15:02:28

Directive => Local Value => Master Value
apc.enabled => On => On
apc.shm_segments => 1 => 1
apc.shm_size => 8M => 8M
apc.include_once_override => Off => Off
apc.num_files_hint => 1000 => 1000
apc.user_entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.ttl => 0 => 0
apc.user_ttl => 0 => 0
apc.filters => no value => no value
apc.cache_by_default => On => On
apc.file_update_protection => 2 => 2
apc.enable_cli => Off => Off
apc.max_file_size => 1M => 1M
apc.stat => On => On
apc.canonicalize => On => On
apc.stat_ctime => Off => Off
apc.write_lock => On => On
apc.slam_defense => On => On
apc.report_autofilter => Off => Off
apc.rfc1867 => Off => Off
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_freq => 0 => 0
apc.rfc1867_ttl => 3600 => 3600
apc.coredump_unmap => Off => Off
apc.preload_path => /share/Web/temp/ => /share/Web/temp/
apc.file_md5 => Off => Off
apc.use_request_time => On => On
apc.lazy_functions => Off => Off
apc.lazy_classes => Off => Off
apc.serializer => default => default


and the list of my modules

Code: Select all

[/usr/local/apache/modules] # ls
apc.so*                 mod_charset_lite.so*    mod_proxy_ajp.so*
eaccelerator.so*        mod_deflate.so*         mod_proxy_balancer.so*
httpd.exp               mod_disk_cache.so*      mod_proxy_connect.so*
libphp5.so*             mod_expires.so*         mod_proxy_ftp.so*
mod_auth_digest.so*     mod_file_cache.so*      mod_proxy_http.so*
mod_authn_alias.so*     mod_filter.so*          mod_proxy_scgi.so*
mod_authnz_external.so* mod_headers.so*         mod_ssl.so*
mod_authnz_ldap.so*     mod_ldap.so*            xcache.so*
mod_authz_unixgroup.so* mod_mem_cache.so*
mod_cache.so*           mod_proxy.so*


oh and please note for your own info, that it is not suggested to use both caching together as you might have weird page display, eAccelerator does not support anonymous functions and that is why I want to use APC and at the end APC is much better and you should get much faster page loading.

Thanks a lot, I really owe you a few beers :wink:

ghis123
Starting out
Posts: 22
Joined: Wed Nov 20, 2013 2:23 am

Re: How to install custom PHP extensions?

Post by ghis123 » Thu Nov 28, 2013 11:32 am

Ahh it seems I that I found a setting to make it working, I do have the preload_path as you said but I changed another parameter that was set to a default that is not working in my config... :idea: and culprit being this apc.stat=0 If this setting is off, APC will not check, which usually means that to force APC to recheck files I read a few things from the documentation and that was the only thing I found... Thanks a lot for all your help provided, not only did it helped me to make it working but I also learned a lot from it.

Side note, I would still like to have the missing extension for the serializer and if you could tell me what you've put inside the php.ini as well

oh and also if I try to run ipcs -lm to find how much I can use, it returns command not found... and it seems some of my pages prefer eAccelerator while some others prefer APC, so I will use both of them and enable/disable them through .htaccess depending on folder.

Philippe, I can't say enough thanks for your tremendous help. Please make sure to send me a PM or a message if you ever come to Montreal. :geek: :mrgreen: 8)

Thanks Ghislain

Post Reply

Return to “Web Server & Applications (Apache + PHP + MySQL / SQLite)”