Home >Backend Development >PHP Tutorial >Common methods for compiling PHP extensions, _PHP Tutorial
Take installing swoole extension as an example:
Step 1: wget pecl.php.net/get/swoole-1.7.21.tgz (Download the swoole package file)
Step 2: tar zxvf swoole-1.7.21.tgz (unzip the swoole compressed file)
Step 3: cd swoole-1.7.21 (enter the swoole directory)
Step 4: /usr/local/php/bin/phpize (or use phpize directly. The phpize command is used to prepare the compilation environment of the PHP extension library, everyone The path of the phpize command may be different, do not copy and execute directly)
Step 5: ./configure --with-php-config=/usr/local/php/bin/php-config (or use ./configure directly. ./configure is used to configure the upcoming Configure the installed software and check whether the current environment meets the dependencies of the software to be installed)
Step 6: make (compile)
Step 7: make test (This step is to check the make in the previous step to ensure that there are no errors in make)
Step 8: make install
After executing make install, you will see a message similar to this:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/, this path is the path of the PHP extension (extension_dir), the swoole is successfully installed .so is in this directory.
Step 9: vim /usr/local/php/lib/php.ini Add extension=swoole.so
Step 10: service php-fpm reload (or service php-fpm restart, restart PHP’s FastCGI process manager, Now I have nginx, php- The fpm service startup script has been written into /etc/rc.d/init.d)