Hello, i found this here in my error Log...is this advagg Bug or something misconfigured ?

2013/09/02 05:33:41 [error] 11731#0: *1014 FastCGI sent in stderr: "PHP message: PHP Fatal error: Call to undefined function jsmin() in /var/www/xxx/sites/all/modules/advagg/advagg_js_compress/advagg_js_compress.advagg.inc on line 207" while reading response header from upstream, client: xxx.xxx.xx.xxx, server: www.example.de, request: "POST /httprl_async_function_callback?count=4 HTTP/1.0", upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "www.example.de"

CommentFileSizeAuthor
#27 jsmin-checkbox.gif17.47 KBeule
#26 jsmin.gif6.28 KBeule
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Peter Bowey’s picture

Hi eule

Call to undefined function jsmin()

This indicates that the added jsmin() library does not exist!

Realize that this library can be either compiled into php, or added as a PHP extension.

The notes from advagg, for adding the jsmin() feature, have these notes:

'JSMin is the C complied version and is about 25 times faster. Recommend using it.'
'You can use the much faster C version of JSMin by installing the "php_jsmin" JSMin PHP Extension on this server. '
'http://www.ypass.net/software/php_jsmin/'

The easier path for adding this is explained here:

Download the source, then run the following commands:

    tar zxf php-jsmin-1.0.tgz
    cd php-jsmin-1.0
    phpize
    sh ./configure
    make
    make install
    (optional) in php.ini add the following line: extensions=jsmin.so

I usually compile the jsmin.c library direct into PHP.

Peter Bowey’s picture

@eule - a simple way to indicate that the jsmin extension exists is to run:

php-fpm -m

assuming you are using php-fpm as the 'non-cli' php process for html access.

eule’s picture

hi Peter, i use php5-fpm

Peter Bowey’s picture

@eule

That is fine, just run the command below:

php5-fpm -m

This will print to the console a list of PHP extensions currently installed!
If you have successfully added jsmin, as you require for advagg, you will note jsmin exists in the printed list.

If the list of php extensions is very long, then use php5-fpm -m | grep jsmin

Notes: the php(-xxx) -m is used to show compiled in modules (or added extensions)

Example #1 Printing built in (and loaded) PHP and Zend modules

$ php -m
[PHP Modules]
xml
tokenizer
standard
session
posix
pcre
overload
mysql
mbstring
ctype

[Zend Modules]
eule’s picture

seems to me i lost the install over a backup..many thanks for your response!

Peter Bowey’s picture

Hi @eule

Glad to share / assist.
nginx, advagg and php-fpm are great tools to understand and use.
I have utilized all the above, and with much time spent on them.
I can gladly encourage you to do likewise... The outcome is worth the time.

eule’s picture

Installing shared extensions: /usr/lib/php5/20090626/
i have this .so also in my php.ini added

;;;;;;;;;;;;;;;;;;;
;   Extensions    ;
;;;;;;;;;;;;;;;;;;;
extensions=jsmin.so
extension=apc.so
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 50
extension=memcache.so
memcache.hash_strategy="consistent"

but if i reload / or restart i dont find it

xxx@xxxx:~# service php5-fpm restart
xxx@xxxx:~# php5-fpm -m

[PHP Modules]
apc
bcmath
bz2
calendar
cgi-fcgi
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
memcache
mhash
mysql
mysqli
openssl
pcre
PDO
pdo_mysql
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
uploadprogress
wddx
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

eule’s picture

if i do xxx@xxxx:~# php5-fpm -m | grep jsmin
i become this warnings
[02-Sep-2013 14:00:40] NOTICE: PHP message: PHP Warning: Module 'apc' already loaded in Unknown on line 0
[02-Sep-2013 14:00:40] NOTICE: PHP message: PHP Warning: Module 'memcache' already loaded in Unknown on line 0
[02-Sep-2013 14:00:40] NOTICE: PHP message: PHP Warning: Module 'memcache' already loaded in Unknown on line 0

eule’s picture

php5-fpm.log

[02-Sep-2013 05:21:46] NOTICE: Reloading in progress ...
[02-Sep-2013 05:21:46] NOTICE: reloading: execvp("/usr/sbin/php5-fpm", {"/usr/sbin/php5-fpm", "--fpm-config", "/etc/php5/fpm/php-fpm.conf"})
[02-Sep-2013 05:21:46] NOTICE: PHP message: PHP Warning: Module 'apc' already loaded in Unknown on line 0
[02-Sep-2013 05:21:46] NOTICE: PHP message: PHP Warning: Module 'memcache' already loaded in Unknown on line 0
[02-Sep-2013 05:21:46] NOTICE: PHP message: PHP Warning: Module 'memcache' already loaded in Unknown on line 0
[02-Sep-2013 05:21:46] NOTICE: using inherited socket fd=7, "/tmp/php-fpm.sock"
[02-Sep-2013 05:21:46] NOTICE: using inherited socket fd=7, "/tmp/php-fpm.sock"
[02-Sep-2013 05:21:46] NOTICE: fpm is running, pid 1xxx1

Peter Bowey’s picture

@eule,

When running the CLI version of PHP from the command line, you may receive errors like the following:

NOTICE: PHP message: PHP Warning: Module 'apc' already loaded in Unknown on line 0
NOTICE: PHP message: PHP Warning: Module 'memcache' already loaded in Unknown on line 0

Cause

It means that you have already activated the 'PHP' apc.so and the memcache.so extension. (read on further!)

You will need check the 'second module' activation that is occurring.

There are two ways to load most extensions in PHP. 1) One is by compiling the extension directly into the PHP binary (this is the way I generally add extensions). 2) The other is by loading a shared PHP extension dynamically via an PHP ini file.

The errors given [above] indicate that dynamic extensions are being loaded via .ini files, even though they are already compiled into the PHP binary.

Fix

To fix this problem, you can edit your php.ini (or extensions.ini) file and comment-out the extensions that are already compiled-in. For example, after editing, your php ini file may look like the lines below:

;extension=apc.so
;extension=memcache.so
;extension=simplexml.so
;extension=session.so
;extension=exif.so

You may also erase those lines instead of commenting them out. Once you have disabled those lines, run php -v to see if the warnings are removed.

Additional Info

To see which extensions are compiled-in to your PHP binary, run the following command:

php -m

You can also view the configure command, which will show which extensions are enabled and compiled-in, or built as shared, dynamic modules.
php -i | grep Configure

The dynamic extensions are usually located in a special "extensions" folder, which varies by operating system environment. Your php.ini usually has a line that describes where the folder is located. For example:

; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/"

You will find that an upgrade added a php.d directory containing a apc.ini that also loaded the apc module. Commenting out the extension loading in php.ini is required.

Peter Bowey’s picture

@eule

You have added the 'expected' extensions=jsmin.so to your php.ini.

However, if it is *not* reported by the process php5-fpm -m, then it [jsmin] does not exist for you to use. [as a jsmin.c extension - or the library compiled into PHP itself].

You have the tools, at hand, to make this occur. Read through the previous notes of how to add the jsmin.c library - either by a PHP extension, or compiling directly into your php.

If you need notes on how it could be compiled directly into PHP, then please ask. But you will need knowledge of compiling PHP 5.x, and a recent GCC [compiler].

To simply add the extension, to your PHP, requires this step:

Download zxf php-jsmin-1.0.tgz - or use the more recent version of JSMin+ version 1.4 (also see: https://drupal.org/node/1229324 )

tar zxf php-jsmin-1.0.tgz
cd php-jsmin-1.0
phpize
sh ./configure
make
make install
add the following line: extensions=jsmin.so
eule’s picture

Hi Peter, i get it here not loaded: i try all the stuff you write but nothing. I´m on Ubuntu makes this any sense?

xxx@xxxx:~# php -v
PHP 5.3.10-1ubuntu3.7 with Suhosin-Patch (cli) (built: Jul 15 2013 18:05:44)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
xxx@xxxx:~# php -m

i have here a Dir ./etc/php5/conf.d where are some of the .ini files and only when i here outcomment the line extension=apc.so in the apc.ini i dont become PHP message: PHP Warning: Module 'apc' already loaded.
i try also to make a jsmin.ini and add extensions=jsmin.so here. but
php -m shows not the extension loaded. so my question how i can compiled the stuff into the PHP binary? maybe i have more luck

Peter Bowey’s picture

@eule,

I did guess that you might have Ubuntu ;-)

1)

when i here outcomment the line extension=apc.so in the apc.ini i dont become PHP message: PHP Warning: Module 'apc' already loaded.

This is a good step = well done.

2) Ubuntu usually only requires the "extension=jsmin.so" added in the php ini. To further clarify, here are the known 'Ubuntu' steps for adding jsmin.c:

First, download the given jsmin.c file into a directory.

$ cd
$ mkdir jsmin
$ cd !$
$ wget http://www.ypass.net/downloads/php-jsmin/php-jsmin-1.0.tgz

or use the more recent version...

$ wget http://tweakimg.net/files/upload/jsminplus-1.4.zip

For the next step you'll need to make sure you have installed the gcc compilers for Ubuntu, if you have not already done this, then do:

$ sudo apt-get install gcc

Compile the file.

$ cc jsmin.c -o jsmin

You can leave the compiled file in your home directory, but if you think you're going to keep it around I suggest moving it to /usr/local/lib/jsmin/ and creating a symbolic link from /usr/local/bin/

$ sudo mv ~/jsmin/ /usr/local/lib/jsmin/ && \
    sudo ln -s /usr/local/lib/jsmin/jsmin /usr/local/bin/jsmin

Now, to use it! The below assumes you haven't moved it from your home directory. If you have, then the ~/jsmin/ path is unnecessary.

$ ~/jsmin/jsmin < my_javascript.src.js > my_javascript.min.js

That's pretty much all there is to it.

eule’s picture

hi Peter...sorry i get into a automatic sleep mode, I'm just simply tipped backwards ;-)

i do now all you write up but i get the next error :/ if i want to compile it i run into this
jsmin.c:59:17: fatal error: php.h: No such file or directory
sounds like i need a php.dev installed?

and in the 1.4 i found only a .php file

Peter Bowey’s picture

Hi @eule,

You need the php-dev package (for php.h). php is the binary package while php-dev contains source files.
Notes: PCRE is a dependency for installing php shared extensions. You can install it with:

yum install pcre-devel or apt-get install libpcre3-dev

the following packages are often required: (php extensions)

sudo apt-get install php5-pear php5-dev libpcre3-dev

eule’s picture

hi peter

i´m not really sure but i think Debian would be the better choice.

xxx@xxxx:~# apt-get install php5-pear php5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-pear

I think I had installed php-pear times ago

Peter Bowey’s picture

@eule,

You may not need php-pear to compile the jsmin.c as a php extension....

The important requirement is within the php5-dev + libpcre3-dev -> (php.h)

For interest sake, the

"Cannot install php-pear"

is sometimes caused by having installed / updated php5 beyond the version the Ubuntu package manager expects:

Peter Bowey’s picture

@eule,

Another thought on the given Ubuntu package issues:

Not all packages are prefixed with php5-*, some are php-*

APC for example is php-apc
PEAR may also be php-pear

Peter Bowey’s picture

@eule,

Ubuntu sometimes shows this 'package' problem if a libapache2-mod-php5 in the original installation is conflicting.

eule’s picture

Hi @Peter

thanks for your Help Peter, but i think i get it never working: i have never touched apache stuff. this is was i have installed on the clean machine

apt-get install nginx php5-cli php5-mysql php5-fpm php5-cgi php5-gd php-pear libpcre3-dev

xxx@xxxx:~# apt-get install php5-dev libpcre3-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-dev is already the newest version.
libpcre3-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
xxx@xxxx:~# apt-get install gcc
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
xxx@xxxx:~# cd
xxx@xxxx:~# mkdir jsmin
mkdir: cannot create directory `jsmin': File exists
xxx@xxxx:~# cd !$
cd jsmin
xxx@xxxx:~/jsmin# cc jsmin.c -o jsmin
jsmin.c:59:17: fatal error: php.h: No such file or directory
compilation terminated.
Peter Bowey’s picture

Hi @eule,

I am sorry it has been such a trial!

Things to consider:

Ubuntu is based on Debian and one event I dislike with Debian is that sometimes the official (stable) packages are far behind what vendors provide. Fortunately for both Debian and Ubuntu you can use the dotdeb repository, which is 'more up to date' with the popular packages (such as mysql, php, etc). If you are not familiar with this repository yet, please take a look at dotdeb repository (or directly via their setup instructions) and install PHP and related packages from there.

If any package is missing, here are some step-by-step instruction on how to make the package yourself.

Peter Bowey’s picture

@eule,

1) A wild guess really, but if you are using the Nginx version of XAMPP, then read this:

Fatal error: php.h: No such file or directory
You must have the XAMPP development files installed and also run /opt/lampp/bin/phpize in the APC source directory.

2) If you are using a standard Ubuntu, with stable release PHP, NGINX, and PHP5-FPM, then you only need to do: sudo apt-get install -f php5-dev, then the jsmin.c GCC compile.

Notes: php5-dev contains files to develop PHP modules.

The command - below;

apt-cache search php

will show the differences:

   php5 - server-side, HTML-embedded scripting language (metapackage)
   php5-dev - Files for PHP5 module development
eule’s picture

Hi Peter
it´s all here...
apt-get install -f php5-dev

Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

apt-cache search php

php5-dev - Files for PHP5 module development
php5-cgi - server-side, HTML-embedded scripting language (CGI binary)
php5-gd - GD module for php5
php-pear - PEAR - PHP Extension and Application Repository
php5-memcached - memcached extension module for PHP5, uses libmemcached
php5-curl - CURL module for php5
php5-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php5-common - Common files for packages built from the php5 source
php-console-table - PHP PEAR module to make it easy to build console style tables
php5-cli - command-line interpreter for the php5 scripting language
php5-mysql - MySQL module for php5
drush - command line shell and Unix scripting interface for Drupal

i try again

xxx@xxxx:~/jsmin# cc jsmin.c -o jsmin
jsmin.c:59:17: fatal error: php.h: No such file or directory

you write:

Fatal error: php.h: No such file or directory
You must have the XAMPP development files installed and also run /opt/lampp/bin/phpize in the APC source directory.

the DIR /opt/ is here but still empty

Peter Bowey’s picture

Hi @eule

Let us see if the needed php.h file exists on your Ubuntu system.

At the Linux Prompt enter: find / -name 'php.h'

My Fedora Linux shows this result:

/root/rpmbuild/BUILD/php-5.5.1/main/php.h
/root/rpmbuild/SOURCES/php-5.5.1/main/php.h

Have you setup a 'build' environment for php?

For Ubuntu, the php.h file is normally found at: /usr/include/php5/main/php.h

New advagg+jsmin Update @ September 4th 2013:

for advagg + jsmin: It might help to read the recent notes here -> Recommend pecl-jsmin if php >= 5.3.10

This new version of jsmin should be easier to install as a 'php pecl' add-on.

You can install this extension by using the pecl command:

pecl install jsmin-beta

eule’s picture

you guys rule!

my php.h file is here i found it with the command you given.

xxx@xxxx:~# find / -name 'php.h'
/usr/include/php5/main/php.h

install the jsmin-beta looks good!

Build process completed successfully
Installing '/usr/lib/php5/20090626/jsmin.so'
Installing '/usr/include/php5/ext/jsmin/php_jsmin.h'
install ok: channel://pecl.php.net/jsmin-0.1.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=jsmin.so" to php.ini

i add also the extension now its right?

eule’s picture

FileSize
6.28 KB

not sure i´m done?

jsmin 0.2.0 enabled

eule’s picture

FileSize
17.47 KB

i wish to spend you guys money..but i don´t have it yet. maybe some day ;D
i get the checkbox!

jsmin via advagg under nginx working

so it looks to work now, but i get 2 times guru meditation. i will digg

Thanks a Lot Guys!!! also @Peter Bowey and @mikeytown2 ..awesome!

mikeytown2’s picture

Category: bug » support
Status: Active » Closed (works as designed)

Thanks @Peter Bowey for the support :)

biswajeetparida’s picture

Issue summary: View changes

hi,
#24 work like a charm