# Flexisipアカウントマネージャー

**URL:** <https://forum.ficusonline.com/t/topic/344>\
**Category:** Server\
**Created:** [2020 年 1 月 21 日午前 8:24 UTC](https://forum.ficusonline.com/t/topic/344 "2020-01-21T08:24:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2020 年 1 月 21 日午前 8:24 UTC](https://forum.ficusonline.com/t/topic/344/1 "2020-01-21T08:24:19Z")

</div>

Linphoneアプリ向けにアカウント作成用サーバのソースコードが公開されています。  
CentOS+Apache向けとなっていますが、Flexisipを稼働しているDockerコンテナ群のNginx+PHP-FPMに導入します。

[https://gitlab.linphone.org/BC/public/flexisip-account-manager](https://gitlab.linphone.org/BC/public/flexisip-account-manager)

また用意されたphpスクリプトにより、以下のLinphoneアカウント用テーブルを作成します。

 ![flexisip_account_db](https://forum.ficusonline.com/uploads/default/original/1X/56d96d0b4ca5e8505abcf8223906d87814a465f9.png)

### インストール手順（Docker-Composeファイルによる）

**Docker-Composeファイル**

別記事で設定した **Flexisip用docker-composeファイル** 内で、 **flexisip-account-manager** 用に新たに共有ボリュームを **nginx** と **php-fpm** の項目に追加します。

> **[docker-flexisip/docker-compose-ubuntu at master · capitalfuse/docker-flexisip](https://github.com/capitalfuse/docker-flexisip/tree/master/docker-compose-ubuntu)**
>
> Dockerfile for flexisip sip server on Ubuntu 18.04 - capitalfuse/docker-flexisip

**./docker\_files** 内の **dockerfile** により、予め各コンテナに必要な追加パッケージをインストールしています。

```auto
# nginx, additional install $ docker exec nginx apk add bash nano
  nginx:
    container_name: nginx
    image: nginx:alpine
    tty: true
    environment:
      - VIRTUAL_HOST=test.site.com
      - VIRTUAL_ROOT=/var/www/html
      - VIRTUAL_PORT=80
      # - VIRTUAL_PROTO=fastcgi
      - LETSENCRYPT_HOST=test.site.com
      - LETSENCRYPT_EMAIL=testsite@gmail.com
    volumes:
      # shared nginx default.conf between host and container
      - ./nginx_default.conf:/etc/nginx/conf.d/default.conf
      # shared the directory /var/www/html in php-fpm container
      - ./html:/var/www/html/register
      # shared the directory /var/www/html in phpmysql-fpm container
      - ./phpmyadmin_data:/var/www/html/phpmyadmin
      # for flexisip-account-manager
      - ./flexisip-account-manager:/var/www/html/flexisip-account-manager
    external_links:
      - nginx-proxy-letsencrypt
    restart: always
    networks:
      proxy-tier:
        ipv4_address: 172.18.0.6

  # php-fpm, additional install $ docker exec php-fpm apk add bash nano
  # php extension mysqli should be installed, $ docker exec php-fpm docker-php-ext-install mysqli
  # for Userfrosting, install followings.
  # apk add libpng-dev freetype-dev libjpeg-turbo-dev zip
  # docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
  # docker-php-ext-install -j$(nproc) gd
  # docker-php-ext-install -j$(nproc) pdo pdo_mysql
  # docker-php-ext-install -j$(nproc) zip
  php-fpm:
    container_name: php-fpm
    build: 
      context: ./docker_files
      dockerfile: php7.2-fpm-alpine
    tty: true
    expose: 
      - "9000"
    volumes:
      - ./html:/var/www/html/register
      # for flexisip-account-manager. install # apk add libxml2-dev, # docker-php-ext-install xmlrpc
      - ./flexisip-account-manager:/var/www/html/flexisip-account-manager
      - ./etc/flexisip-account-manager:/etc/flexisip-account-manager
    depends_on:
      - flexisip-mariadb
    restart: always
    networks:
      proxy-tier:
        ipv4_address: 172.18.0.7

```

**./docker\_files/php7.2-fpm-alpine**

```auto
FROM php:7.2-fpm-alpine
# For flexisip-account-manager xmlrpc server
RUN apk add --no-cache bash nano libpng-dev freetype-dev libjpeg-turbo-dev zip libxml2-dev \
    && docker-php-ext-install mysqli xmlrpc \
    && docker-php-ext-enable mysqli xmlrpc \

# Make the log directory and the log file for flexisip-account-manager    
RUN mkdir -p /var/opt/belledonne-communications/log \
    && cd /var/opt/belledonne-communications/log \
    && touch account-manager.log
    && chown www-data:www-data account-manager.log

```

**flexisip-account-managerのダウンロード**

**git clone** コマンドによりダウンロードします。

**以下srcフォルダ** と **confフォルダ** の中身を **docker-compose** ファイルで設定した共有フォルダ  
**flexisip-account-manager** と **etc** へコピーします。

 ![docker-flexisip](https://forum.ficusonline.com/uploads/default/original/1X/b063ed9cb6cfb751c79c59ae871c92b0b8a304b6.png)

**php-fpmコンテナの設定**

php-fpmコンテナ内にbashコマンドで移動し、xmlrpcサーバに必要なパッケージ、機能拡張をインストールします。インストール後、再起動します。

```auto
$ docker exec -ti php-fpm bash

# apk add libxml2-dev
# docker-php-ext-install xmlrpc
# exit

```

php-fpmの再起動

```auto
$ docker container restart php-fpm

```

**nginxコンテナの設定(/etc/nginx/conf.d/default.conf)**

nginxコンテナ内でサブディレクトリ **flexisip-account-manager** の追加・設定をします。

```auto
$ docker exec -ti nginx bash
# nano /etc/nginx/conf.d/default.conf

```

```nginx
location ^~ /flexisip-account-manager {

    alias /var/www/html/flexisip-account-manager/xmlrpc;
    try_files $uri $uri/ @flexisip-account-manager;

    location ~ \.php$ {
        fastcgi_split_path_info ^\/flexisip-account-manager\/(.+\.php)(.*)$;
        fastcgi_param HTTPS 'on';
        fastcgi_pass php-fpm:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
    }
  }

  location @flexisip-account-manager {
     rewrite /flexisip-account-manager/(.*)$ /flexisip-account-manager/xmlrpc.php;
  }

```

設定のリロード

```auto
# nginx -s reload

```

**アカウントデータテーブルの作成**

事前に

**/etc/flexisip-account-manager/db.conf**

**/var/www/html/flexisip-account-manager/database/database.php**

内でデータベース、ユーザ名、パスワードを設定して下さい。

**db.conf**

```
define("DB_HOST", "mariadb-flexisip");

define("DB_USER", "flexisip");

define("DB_PASSWORD", "your_password");

define("DB_NAME", "flexisip");

```

**database.php**

`"mysql:host=flexisip-mariadb;dbname=flexisip"`

php-fpmコンテナ内で以下phpスクリプトを実行してアカウント用テーブルを作成します。

```auto
$ docker exec -ti php-fpm bash
# php /var/www/html/flexisip-account-manager/tools/create_tables.php

```

xmlrpcサーバ、プロビジョニングの動作については現在検証中。

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2020 年 2 月 1 日午後 1:07 UTC](https://forum.ficusonline.com/t/topic/344/2 "2020-02-01T13:07:37Z")

</div>

### Flexisipの設定ファイルの変更

flexisip-account-managerにより作成されたaccountsテーブルとpasswordsテーブルは切り離されているので、accountsテーブルのusernameからpasswordを抽出できるよう **Flexisip** の設定ファイル **flexisip.conf** の **soci** の項目を変更します。

**/etc/flexisip/flexisip.conf**

```auto
soci-password-request=select passwords.password, 'SHA-256' from accounts inner join passwords on accounts.id=passwords.account_id where username = :id and domain = :domain

```

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2020 年 2 月 10 日午前 2:06 UTC](https://forum.ficusonline.com/t/topic/344/3 "2020-02-10T02:06:07Z")

</div>

**アカウントマネージャーログ確認（php-fpmコンテナ内）**

```auto
bash-5.0# cat /var/opt/belle*/log/account-manager.log

```

**コンテナphp-fpmログ確認**

```auto
$ docker logs php-fpm

```

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2024 年 8 月 4 日午前 12:56 UTC](https://forum.ficusonline.com/t/topic/344/4 "2024-08-04T00:56:02Z")

</div>

## Update Flexisip Account Manager

アップデートについては以下リンク先参照のこと。

> [@Linphone-SDK Ubuntu 22.04 Dockerイメージの作成とアプリのビルド（IPv6対応）](https://forum.ficusonline.com/t/topic/479/21):
>
> アカウントマネージャのアップデート 現時点での最新安定版1.4.6へアップデート [https://github.com/BelledonneCommunications/flexisip-account-manager/tree/1.4.6](https://github.com/BelledonneCommunications/flexisip-account-manager/tree/1.4.6) flexisip-account-managerフォルダごと入替えます。バックアップとしてフォルダの名称を変更します。ex) flexisip-accou…

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2025 年 5 月 4 日午後 10:06 UTC](https://forum.ficusonline.com/t/topic/344/6 "2025-05-04T22:06:21Z")

</div>

Ver 1.6以降の新規インストール後の対応

.envファイルでデバックモードに変更して動作確認のこと。

* * *

### 500 error 対応

原因：以下hcaptchaの旧バージョンによる不具合

4.5から5.2へ変更

`composer.json`

```auto
"rvxlab/hcaptcha": "^5.2"

```

依存パッケージのアップデート

```shell
# composer update 

```

依存パッケージのインストール

```auto
# composer install --no-dev

```

### php artisan コマンド

新規インストールした場合

```shell
# php artisan key:generate

```

データベースアップデート（作成）

```shell
# php artisan migrate

```

SIPドメインと管理者ユーザの登録を以下の`php artisan`コマンドで行います。

SIPドメインを登録（superはオプション）

```shell
# php artisan sip_domains:create-update sip.example.com --super

Your will create or update a SIP Domain in the database
A new domain will be created
Set as a super domain

```

管理者ユーザの登録

```shell
# php artisan accounts:create-admin-account -u user001 -p password -d sip.example.com

Your will create a new admin account in the database, existing accounts with the same credentials will be overwritten
Admin test account created: "user001@sip.example.com" | Password: "password" | API Key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" (valid on any ip)

```

* * *

### MINEタイプエラー

login:1 Refused to execute script from ‘[https://xxx.xxx.xxx/scripts/chartjs-plugin-datalabels@2.0.0](https://xxx.xxx.xxx/scripts/chartjs-plugin-datalabels@2.0.0)’ because its MIME type (‘application/octet-stream’) is not executable, and strict MIME type checking is enabled.

ヒント

`flexiapi/resources/views/layouts/main.blade.php`

```php
<script src="{{ asset('scripts/chartjs-plugin-datalabels@2.0.0') }}"></script>

```

JSファイルであることを明示するため、以下のファイルを採用

```php
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0/dist/chartjs-plugin-datalabels.min.js"></script>

```

* * *

### ラベル属性指定エラー

ラベルエレメントが、インプットエレメントのidではなくnameを参照しているため発生。実際にはインプットエレメントにid項目が欠如。

> Incorrect use of   
> The label’s for attribute refers to a form field by its name, not its id. This might prevent the browser from correctly autofilling the form and accessibility tools from working correctly.
> 
> To fix this issue, refer to form fields by their id attribute.
> 
> 2 resources  
> Label  
> Label  
> Learn more: HTML Standard

インプットエレメントにid項目追加。下記ファイル以外にも `<input id=` エレメントを含むファイルの修正必要（多数、動作に問題はない）。

`flexisip-account-manager/flexiapi/resources/views/account/login.blade.php`

```php
<input id="username" placeholder="username or phone number" required="" name="username" type="text"
                        value="{{ old('username') }}">

<input id="username" placeholder="username" required="" name="username" type="text"
                        value="{{ old('username') }}">
                    <label for="username">Username</label>

<input id="password" placeholder="myPassword" required="" name="password" type="password" value="">

```
