PHP Static Binary - with inotify Extension - php

I recently found out how to build a standalone php binary (here), which works great!
Is there a way to include the inotify extension into this binary?
I dont find any documentations about building php with inotiy, only about extend php with the "pecl extension" inotify - may this is the problem, its a pecl extension and therefore not includable into the php binary?
is there another approach to deliver the binary with this inotify extension (except normal php installation)?
Target is, to deliver a php cli application, which is independent of the installed php version of the destiantion server (which works great till now, until we would need the inotify extension in php..)

I just found this pretty documentation, which solved my problem.
INotify (and all other modules) works with the single static binary, compiled (in debian 7) via:
./configure --enable-static --enable-cli --enable-inotify --with-openssl --with-openssl-dir=/usr/bin
complete progress:
download /etxtract php711 source
download /extract inotify module
rename inotify folder to "inotify"
mv inotify folder to {phpsrc}/ext/inotify
change dir to {phpsrc}
rm configure
./buildconf --force
./configure --enable-static --enable-cli --enable-inotify --with-openssl --with-openssl-dir=/usr/bin
make
have fun with the stand alone php cli binary located # {phpsrc}/sapi/cli/php
The binary even works with other distributions (short tested in centos 6 and latest arch)

Related

How to install mcrypt on OS X's natively installed PHP?

I am trying to install the mcrypt PHP extension on my OS X Mountain Lion 10.8 operating system. This OS comes shipped with Apache and PHP already installed. The mcrypt extension however does not come shipped with PHP. I want to install mcrypt into the version of PHP that came shipped with my machine.
I do not want to use Homebrew, Macports, or any similar package manager, and I do not want to install another version of PHP in addition to the one I already have. I just want to plug mcrypt into the PHP that came bunded with my OS. I feel like this makes sense, instead of having multiple versions of the same program installed, yet every tutorial I come across seems to all immediately say to use Homebrew/Macports, and the few that don't teach you how to install a new PHP instead of using the one I already have.
I started following the directions laid out on this page: http://www.coolestguyplanettech.com/how-to-install-mcrypt-for-php-on-mac-osx-lion-10-7-development-server/.
I downloaded libmcrypt-2.5.8.tar.gz from Sourceforge.
I extracted the contents with the following command: tar -zxvf libmcrypt-2.5.8.tar.gz.
I entered the libmcrypt-2.5.8 directory that was created and issued the following commands: ./configure, make, and sudo make install.
Now that tutorial says to go into a directory that was created by a new, non-native version of PHP that the tutorial tells you to install, not the native version that came shipped with OS X. The tutorial says to go into the following directory: cd ../php-5.3.13/ext/mcrypt/ (which is a directory I don't have), and run the phpize command. I can't go into that directory because I'm using the native PHP that came with OS X, so instead I go into the libmcrypt-2.5.8 directory, but when I try to run the phpize command I get an error that says: Cannot find config.m4. Make sure that you run '/usr/bin/phpize' in the top level source directory of the module. I do however have the files acinclude.m4 and aclocal.m4 in this directory. I am not sure if they are related to the config.m4 that phpize is looking for.
I am not sure how to proceed. Maybe I should just cut my losses and install another PHP using Macports or Homebrew, but I'd really prefer to use the native PHP that came bundled with OS X. Can you help me figure out how to do this? It would really help me a lot, and help me understand better how PHP and extensions work. Thank you!
"I'd really prefer to use the native PHP that came bundled with OS X.
Can you help me figure out how to do this? It would really help me a
lot, and help me understand better how PHP and extensions work."
The PHP that came bundled with OSX isn't any more "Native" than any other version that you would install.
You don't have that directory because, IIRC, OSX doesn't ship with PHP source, just a compiled binary and apache module.
You can only run phpize on a php extension, which you can get in the PHP source download (including the mcrypt extension). What you downloaded is the C library (which you may also need to install) that the PHP extension will reference (you don't need to worry about how this happens).
If you want to just install that extension:
Download it
Extract and cd into
sudo phpize
sudo ./configure && sudo make && sudo make install
Add extension=mcrypt.so (or whatever is generated) to your php config / php.ini and restart apache
This sounds to me like a good opportunity to learn more about how your computer works. This is some documentation I wrote for myself a few years ago on how to do this:
http://www.calvinfroedge.com/common-php-compile-configuration-options/ (note that the formatting in the blog might not work if you paste it into terminal, for example –with-mysql should be --with-mysql)
Besides, you don't need to get rid of your PHP installation that came with OSX. You can download the PHP source to a brand new directory, compile it, backup the old binary, and either symlink the result of 'which php' to your new installation or add the binaries that get generated after you compile to your source.

Upgrade to PHP 5.4 on MAC and remove version 5.3.10

I would tring to update my php version to the version 5.4.
When I'm looking via /usr/local/bin/php -v in the console I see the version 5.4.3 and with php -v it tell me there is the version 5.3.10 installed.
How can I remove the older version?
Update:
As of early 2014, you are probably better of installing from http://php-osx.liip.ch/ builds as it contains most extensions. In case you really do need to compile your own, follow the original answer.
Original answer:
Mac comes with a preinstalled php you can easily overwrite.
This is a list of steps I take to update the php I have installed:
Prerequisites:
Xcode and it's Command line utilities (install form preferences) will give you a gcc compiler to build the php with
libjpeg, libpng etc. if you want to build with these.
Building and installing php:
Download the distribution from www.php.net/downloads.php
Untar the archive and point your console into the location
Now, having still the original old php installed, run php -i | head in the console. What you want is to configure your new php with these flags to ensure you have proper pcre support and everything works just fine.
In the php source directory you untarred, run the ./configure script with the flags you just got
Build php by running make and sudo make install afterwards. That will actually replace the original php distributed with OS X.
And dont forget to run make test...
Ex.: my workflow for building php
wget http://url_to/php_source.tar.gz
tar -zxvf php_source.tar.gz
cd php_source/
php -i | head
./configure --prefix=/usr --with-snmp # ... same flags as previous build
make
sudo make install

PHP ICONV glibc to libiconv on CentOS 5.5

I'm having a few issues with the PHP function iconv, which I've tracked down the the iconv implementation. As the manual states, "Note that the iconv function on some systems may not work as you expect. In such case, it'd be a good idea to install the GNU libiconv library." http://uk3.php.net/manual/en/intro.iconv.php
I've downloaded the libiconv library from http://www.gnu.org/software/libiconv/ and installed it without any problems using:
$ ./configure --prefix=/usr/local
$ make
$ make install
My problem now is how to link this installation to PHP? From what i've read I need to recompile PHP with --with-iconv-dir=/usr/local/
but how do I do this on CentOS? I installed php with yum install php.x86_64
I tried yum reinstall php but when I service httpd restart my phpinfo reads the same, glibc.
Is there a better way to install libiconv on CentOS? If not how do I get PHP using this installation without upsetting yum?
Many thanks in advance
compiled php from source seems to be the way
php -m > /tmp/php.modules to list of compiled module for php
backup your current php.ini
yum uninstall php
download the php
and base on your existing module + iconv - almost all steps has been detailed here : http://www.php.net/manual/en/install.unix.apache2.php#90478 (except never advise u to backup php.ini)
You should manually recompile the php iconv extension (in the php-x.y.z/ext/iconv/ subdirectory) after manual changing of the configure script to force it to select GNU libiconv instead of glibc's iconv. See my answer for the similar Stack question.

install PARADOX extension for PHP

I have an ApacheFriends XAMPP running on my windows machine and i am trying to access some Paradox database files directly from PHP.
I see that there is an extension for this but how can i install it for my windows system?
copy the extension's .dll to path\to\xampp\php\ext\
and a line similar to extension=php_paradox.dll in path\to\xampp\php\php.ini, where php_paradox.dll is the name of your extension's .dll file
configure your extension's parameters in path\to\xampp\php\php.ini, if any, per your extension's intructions
restart Apache
If you have pecl installed, pecl install paradox might fetch it on to your system. If not you must step though the ugly steps of extension compiling:
download php source code
copy the extension's source in path/php-src/ext/ dir
./configure --prefix=/where/to/install/php --enable-debug --enable-maintainer-zts --enable-cgi --enable-cli --with-mysql=/path/to/mysql --with-PARADOX=shared,PATH/TO/DIR
make, make install and you'll find the .dll in install/path/ext/ dir
Mike,
I believe that that XAMPP install includes Paradox support by default. Simply use px_get_record() et. al. and you should be good.

Configuring already installed PHP to work with already installed ncurses (MAMP)

I have installed MAMP and the PHP it came with wasn't compiled with ncurses. I've tried to use port to install ncurses and it seems that it already exists on my system so now I was wondering if there was a way to get PHP to use it without having to recompile PHP --with-ncurses.
In other words: Can PHP be configured to use ncurses without the recompilation?
I'm sorry for the late answer but this can actually be done quite easily with MAMP.
I have done this on my MacBook running OS X Snow Leopard.
Your MAMP directory contains the tar file of the php source code. MAMP version 1.8.4 ships with php-5.2.11.tar located here: /Applications/MAMP/bin/php5/
cd /Applications/MAMP/bin/php5/
tar -xvf php-5.2.11.tar
cd php-5.2.11/ext/ncurses
/Applications/MAMP/bin/php5/bin/phpize
./configure --with-php-config=/Applications/MAMP/bin/php5/bin/php-config
make
make install
Afterwards you just need to add the ncurses.so extension to the MAMP php.ini
echo "extension=ncurses.so" >> /Applications/MAMP/conf/php5/php.ini
php -i | grep ncurses
This gives me:
ncurses
ncurses support => enabled
ncurses library version => 5.7
You can also do this with the PCNTL extension ;) ;)
Cheers!
According to the manual, ncurses must be compiled in. Some extensions can be compiled as shared libraries (dll/so) and loaded dynamically, but some can't. Seems that ncurses can't.
I don't know a lot about how mac packages are structured, but isn't it a bsd/ports style installation? In that case, just find the package and configure + recompile it.
Edit: I see that mamp is a binary distribution. You're out of luck then. I would suggest that you install at least php from sources. It's very useful to be able to install new extensions etc. It's fairly straight forward to compile php, so even if you aren't completely confident with compiling stuff, you should be able to huddle through it.

Categories