FreeSwitch: ESL phpmod install

Скачайте исходники FreeSwitch

cd /usr/src/
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git -bv1.8 freeswitch
apt-get install gcc autoconf libtool libtool-bin libjpeg libjpeg-dev pkg-config sqlite3 libsqlite3-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libspeexdsp-dev libedit-dev libtiff-dev libqdbm-dev libonig-dev libdb-dev

apt-get install libldns-dev
apt-get install php5-dev
cd /usr/src/freeswitch
./bootstrap.sh -j
./configure --with-php
 cd /usr/src/freeswitch/libs/esl
 make phpmod
На этом этапе обычно проявляются проблемы. Например:
Makefile:681: recipe for target 'esl_wrap.o' failed
make[1]: *** [esl_wrap.o] Error 1
make[1]: Leaving directory '/usr/src/freeswitch/libs/esl/php'
Makefile:1407: recipe for target 'phpmod' failed
make: *** [phpmod] Error 2

Не найдены требуемые заголовки php?
В общем мне удалось собрать только для php5 (php5.6 конкретно). На php7 (php7.3 не удалось)
php-dev и любые зависимости должны быть установлены до ./configure


выхлоп

выхлоп

make MYLIB=".././.libs/libesl.a" SOLINK="-shared -Xlinker -x" CFLAGS="-I/usr/src/freeswitch/libs/esl/src/include -I/usr/include/uuid  -I/usr/src/freeswitch/src/include -I/usr/src/freeswitch/src/include -I/usr/src/freeswitch/libs/libteletone/src -fPIC -ffast-math -Werror -Wno-unused-result -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DCJSON_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -g -ggdb -DHAVE_OPENSSL" CXXFLAGS="-I/usr/src/freeswitch/libs/esl/src/include -I/usr/src/freeswitch/src/include -I/usr/src/freeswitch/src/include -I/usr/src/freeswitch/libs/libteletone/src -fPIC -ffast-math -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DCJSON_API_VISIBILITY=1 -DHAVE_VISIBILITY=1" CXX_CFLAGS="" -C php 
make[1]: Entering directory '/usr/src/freeswitch/libs/esl/php'
g++ -shared -Xlinker -x esl_wrap.o .././.libs/libesl.a -L/usr/lib/php5 -L/usr/lib/x86_64-linux-gnu/mit-krb5 -L/usr/lib/x86_64-linux-gnu -lcrypt -lresolv -lcrypt -lonig -lstdc++ -ldb -lqdbm -lrt -lm -ldl -lnsl -lcrypt -lcrypt -lpthread -o ESL.so -L. -lssl -lcrypto  
make[1]: Leaving directory '/usr/src/freeswitch/libs/esl/php'

 make phpmod-install

выхлоп

выхлоп

make MYLIB=".././.libs/libesl.a" SOLINK="-shared -Xlinker -x" CFLAGS="-I/usr/src/freeswitch/libs/esl/src/include -I/usr/include/uuid  -I/usr/src/freeswitch/src/include -I/usr/src/freeswitch/src/include -I/usr/src/freeswitch/libs/libteletone/src -fPIC -ffast-math -Werror -Wno-unused-result -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DCJSON_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -g -ggdb -DHAVE_OPENSSL" CXXFLAGS="-I/usr/src/freeswitch/libs/esl/src/include -I/usr/src/freeswitch/src/include -I/usr/src/freeswitch/src/include -I/usr/src/freeswitch/libs/libteletone/src -fPIC -ffast-math -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DCJSON_API_VISIBILITY=1 -DHAVE_VISIBILITY=1" CXX_CFLAGS="" -C php 
make[1]: Entering directory '/usr/src/freeswitch/libs/esl/php'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/usr/src/freeswitch/libs/esl/php'
make -C php install
make[1]: Entering directory '/usr/src/freeswitch/libs/esl/php'
test -d "/usr/lib/php5/20131226" || mkdir -p "/usr/lib/php5/20131226"
cp ESL.so "/usr/lib/php5/20131226"
test -d "/usr/share/php" || mkdir -p "/usr/share/php"
cp ESL.php "/usr/share/php"
test -d "/etc/php5/apache2/conf.d" || mkdir -p "/etc/php5/apache2/conf.d"
test -f "/etc/php5/apache2/conf.d/esl.ini" || echo 'extension=ESL.so' > "/etc/php5/apache2/conf.d/esl.ini"
make[1]: Leaving directory '/usr/src/freeswitch/libs/esl/php'

Check php info

 php -r 'phpinfo();' | grep php

выхлоп

выхлоп

phpinfo()
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
Scan this dir for additional .ini files => /etc/php5/cli/conf.d
Additional .ini files parsed => /etc/php5/cli/conf.d/01-esl.ini,
/etc/php5/cli/conf.d/05-opcache.ini,
/etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-curl.ini,
/etc/php5/cli/conf.d/20-gd.ini,
/etc/php5/cli/conf.d/20-json.ini,
/etc/php5/cli/conf.d/20-ldap.ini,
/etc/php5/cli/conf.d/20-mysql.ini,
/etc/php5/cli/conf.d/20-mysqli.ini,
/etc/php5/cli/conf.d/20-odbc.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini,
/etc/php5/cli/conf.d/20-pdo_odbc.ini,
/etc/php5/cli/conf.d/20-pdo_pgsql.ini,
/etc/php5/cli/conf.d/20-pgsql.ini,
/etc/php5/cli/conf.d/20-readline.ini
Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
expose_php => On => On
extension_dir => /usr/lib/php5/20131226 => /usr/lib/php5/20131226
include_path => .:/usr/share/php:/usr/share/pear => .:/usr/share/php:/usr/share/pear
Registered serializer handlers => php_serialize php php_binary wddx 
session.save_path => /var/lib/php5/sessions => /var/lib/php5/sessions
session.serialize_handler => php => php
_ => /usr/bin/php
_SERVER["_"] => /usr/bin/php
questions about PHP licensing, please contact license@php.net.

У меня модули в директории (debian 8):

ls -1 /usr/lib/php5/20131226 | grep -i esl
ESL.so

или /usr/lib/php/20131226 (debian 9, php5.6)

Проверка путей и доступа

Если esl.ini отсутствует создайте его

ls -al /etc/php5/mods-available/ | grep esl
-rwxr-xr-x 1 root root   17 окт 22 18:08 esl.ini
ls -la /usr/share/php | grep ESL
-rw-r--r--   1 root root  9332 окт 22 17:40 ESL.php

В нем должна быть только одна строка:
cat /etc/php5/mods-available/esl.ini

 extension=ESL.so

Может быть потребуются ссылки (нет) :

ls -al /etc/php5/cli/conf.d/ | grep esl
lrwxrwxrwx 1 root root   28 окт 22 18:06 01-esl.ini -> ../../mods-available/esl.ini
ls -al /etc/php5/apache2/conf.d/ | grep esl
lrwxrwxrwx 1 root root   28 окт 22 18:05 01-esl.ini -> ../../mods-available/esl.ini

I had to do a reboot, to make the module visible. You may be smarter.

php -m | grep ESL
ESL

Usage

#!/usr/bin/php5
<?php
require_once('ESL.php');
 
if ($argc > 1) {
    array_shift($argv);
    $command = sprintf('%s', implode(' ', $argv));
    printf("Command to run is: %s\n", $command);
    $sock = new ESLconnection('localhost', '8021', 'ClueCon');
    $res = $sock->api($command);
    printf("%s\n", $res->getBody());
} else {
    printf("ERROR: You Need To Pass A Command\nUsage:\n\t%s <command>", $argv[0]);
}
freeswitch@fs:~$ ./test_esl.php status
Command to run is: status
UP 0 years, 0 days, 0 hours, 14 minutes, 20 seconds, 110 milliseconds, 88 microseconds
FreeSWITCH (Version 1.6.20 -37-987c9b9 64bit) is ready
0 session(s) since startup
0 session(s) - peak 0, last 5min 0 
0 session(s) per Sec out of max 30, peak 0, last 5min 0 
1000 session(s) max
min idle cpu 0.00/99.10
Current Stack Size/Max 240K/8192K

https://freeswitch.org/confluence/display/FREESWITCH/PHP+ESL

  • freeswitch/api/php-esl_install.txt
  • Последние изменения: 2019/03/29