4. Rebuilding Extensions for Production
While we are on the subject of build processes and before we go deeper into building a PHP extension skeleton, it makes sense to explain how to rebuild the extension for production when it’s ready. Actually, you may try this right now. At first, you’ll need PHP development tools especially for your PHP build. It may be a system package.
Installation for Ubuntu/Debian:
$ sudo apt-get install php-dev
Installation for RedHat/Fedora:
$ sudo dnf install php-devel
For Zend Server you should get “php-dev-zend-server” package installed (through Zend Server installer or system package manager) and use its components in the PATH.
$ export PATH=/usr/local/zend/bin:$PATH
The building is very similar to the “DEBUG” build. The difference is that now we use “phpize” from “production” build. (PATH shouldn’t include our DEBUG PHP build directory.)
$ phpize
$ ./configure
$ make
$ sudo make install
Add extension into php.ini:
$ vi /etc/php.ini
Add the following line:
extension=test.so
Check that extension is loaded and works:
$ php -m | grep test
test
Now you can restart your web server or PHP-FPM and start using your extension in a web environment.