FreeSwitch: ESL phpmod install

Download source FS

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

выхлоп

выхлоп

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.

I have modules in some strange directory:

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

Check path and module access

Installer set this as minimum:

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

May be needs create the links:

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
  • Последние изменения: 2018/11/05