重新整理目录,添加导航栏,侧边栏根据导航栏分组,文档文件名改为非中文
This commit is contained in:
parent
e0a49394d2
commit
b9f39d89fb
@ -20,89 +20,24 @@ module.exports = {
|
|||||||
themeConfig: {
|
themeConfig: {
|
||||||
lastUpdated: "上次更新",
|
lastUpdated: "上次更新",
|
||||||
displayAllHeaders: false,
|
displayAllHeaders: false,
|
||||||
sidebar: [
|
nav: [
|
||||||
{
|
{ text: '首页', link: '/' },
|
||||||
title: "README",
|
{ text: 'FreeSWITCH', link: '/freeswitch/ubuntu1604' },
|
||||||
path: "/",
|
{ text: 'PHP', link: '/php/php82' }
|
||||||
sidebarDepth: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "FreeSWITCH",
|
|
||||||
children: [
|
|
||||||
"/freeswitch/Ubuntu16.04安装FreeSWITCH1.6.md",
|
|
||||||
"/freeswitch/Debian11安装FreeSWITCH1.10.md",
|
|
||||||
"/freeswitch/Debian11安装FreeSWITCH1.10-参照ClueCon官方文档.md",
|
|
||||||
"/freeswitch/Debian11安装lua和luarocks.md",
|
|
||||||
"/freeswitch/Debian11中注册FreeSWITCH为系统服务.md",
|
|
||||||
"/freeswitch/为FreeSWITCH安装mod_unimrcp模块.md",
|
|
||||||
"/freeswitch/FreeSWITCH对接阿里云MRCP.md",
|
|
||||||
"/freeswitch/部署百度智能呼叫中心的MRCPServer.md",
|
|
||||||
"/freeswitch/FreeSWITCH对接百度MRCP.md",
|
|
||||||
"/freeswitch/FreeSWITCH配置SSL.md",
|
|
||||||
"/freeswitch/搭建STUN服务.md",
|
|
||||||
"/freeswitch/恶意SIP行为IP黑名单.md",
|
|
||||||
"/freeswitch/【安全】使用fail2ban自动防止FreeSWITCH被恶意SIP注册.md",
|
|
||||||
],
|
|
||||||
initialOpenGroupIndex: 0, // 可选的, 默认值是 0
|
|
||||||
sidebarDepth: 0, // 可选的, 默认值是 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "前端",
|
|
||||||
children: [
|
|
||||||
"/frontend/在VuePress项目中添加百度统计代码.md",
|
|
||||||
"/frontend/解决create-vue创建的项目运行后提示Network: use --host to expose的问题.md",
|
|
||||||
"/frontend/在linux中安装node二进制文件.md",
|
|
||||||
"/frontend/在vscode里配置vetur符合eslint.md",
|
|
||||||
"/frontend/npm切换源.md",
|
|
||||||
],
|
|
||||||
initialOpenGroupIndex: 0, // 可选的, 默认值是 0
|
|
||||||
sidebarDepth: 0, // 可选的, 默认值是 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "PHP",
|
|
||||||
children: ["/php/php74安装pgsql扩展"],
|
|
||||||
initialOpenGroupIndex: 0, // 可选的, 默认值是 0
|
|
||||||
sidebarDepth: 0, // 可选的, 默认值是 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "GIT",
|
|
||||||
children: ["/git/常用git命令", "/git/生成sshkey"],
|
|
||||||
initialOpenGroupIndex: 0, // 可选的, 默认值是 0
|
|
||||||
sidebarDepth: 0, // 可选的, 默认值是 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Linux",
|
|
||||||
children: [
|
|
||||||
"/linux/阿里云centos磁盘扩容",
|
|
||||||
"/linux/删除.user.ini文件",
|
|
||||||
"/linux/删除某时间前的文件或文件夹",
|
|
||||||
"/linux/centos7防火墙",
|
|
||||||
"/linux/docker操作",
|
|
||||||
"/linux/linux常用命令",
|
|
||||||
"/linux/linux改网卡名",
|
|
||||||
"/linux/ssh客户端保持连接",
|
|
||||||
"/linux/ssh免密码连接服务器",
|
|
||||||
"/linux/tmux操作",
|
|
||||||
"/linux/ubuntu配静态IP",
|
|
||||||
"/linux/ubuntu配置nfs服务",
|
|
||||||
"/linux/vim操作",
|
|
||||||
],
|
|
||||||
initialOpenGroupIndex: 0, // 可选的, 默认值是 0
|
|
||||||
sidebarDepth: 0, // 可选的, 默认值是 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Docker",
|
|
||||||
children: [
|
|
||||||
"/docker/Debian11下安装docker和docker-compose",
|
|
||||||
"/docker/配置Docker Hub国内镜像加速",
|
|
||||||
"/docker/docker部署gitea服务",
|
|
||||||
"/docker/docker部署minio服务",
|
|
||||||
"/docker/docker部署postgres数据库服务",
|
|
||||||
"/docker/docker部署rabbitmq启用stomp和延时队列",
|
|
||||||
],
|
|
||||||
initialOpenGroupIndex: 0, // 可选的, 默认值是 0
|
|
||||||
sidebarDepth: 0, // 可选的, 默认值是 1
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
|
sidebar: {
|
||||||
|
'/freeswitch/': [
|
||||||
|
'ubuntu1604',
|
||||||
|
'fail2ban'
|
||||||
|
],
|
||||||
|
'/php/': [
|
||||||
|
'nginx',
|
||||||
|
'openresty',
|
||||||
|
'php82'
|
||||||
|
],
|
||||||
|
'/': [
|
||||||
|
''
|
||||||
|
]
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,3 @@
|
|||||||
源代码地址: <https://git.wandoubaba.com/wandoubaba/knowledge>
|
源代码地址: <https://git.wandoubaba.com/wandoubaba/knowledge>
|
||||||
|
|
||||||
作者邮箱:<wandoubaba517@gmail.com>
|
作者邮箱:<wandoubaba517@gmail.com>
|
||||||
|
|
||||||
## 更新记录
|
|
||||||
|
|
||||||
[2023-07-11] 新增文档[【安全】使用fail2ban自动防止FreeSWITCH被恶意SIP注册.md](/freeswitch/【安全】使用fail2ban自动防止FreeSWITCH被恶意SIP注册.md)
|
|
||||||
|
@ -1,307 +0,0 @@
|
|||||||
# 在ubuntu16.04系统上安装freeswitch1.6
|
|
||||||
|
|
||||||
------
|
|
||||||
|
|
||||||
## 操作系统和软件版本
|
|
||||||
|
|
||||||
ubuntu16.04
|
|
||||||
|
|
||||||
freeswitch v1.6
|
|
||||||
|
|
||||||
python2.7
|
|
||||||
|
|
||||||
lua5.3
|
|
||||||
|
|
||||||
## 准备工作
|
|
||||||
|
|
||||||
### 安装系统
|
|
||||||
|
|
||||||
最小安装ubuntu16.04系统,安装ssh server
|
|
||||||
|
|
||||||
### 网络等必要配置
|
|
||||||
|
|
||||||
根据实际网络环境和个要习惯来配置
|
|
||||||
|
|
||||||
- 静态IP:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo vim /etc/network/interfaces
|
|
||||||
```
|
|
||||||
|
|
||||||
示例(根据实际情况设置,照抄大概率无效)
|
|
||||||
|
|
||||||
```txt
|
|
||||||
auto eth0
|
|
||||||
iface eth0 inet static
|
|
||||||
address 192.168.0.234
|
|
||||||
netmask 255.255.255.0
|
|
||||||
gateway 192.168.0.1
|
|
||||||
dns-nameserver 219.148.204.66
|
|
||||||
dns-nameserver 219.149.6.99
|
|
||||||
dns-nameserver 114.114.114.114
|
|
||||||
```
|
|
||||||
|
|
||||||
- root登录:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo vim /etc/ssh/sshd_config
|
|
||||||
```
|
|
||||||
|
|
||||||
- root密码:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo passwd root
|
|
||||||
```
|
|
||||||
|
|
||||||
- 修改更新源:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo vim /etc/apt/sources.list
|
|
||||||
```
|
|
||||||
|
|
||||||
```txt
|
|
||||||
deb http://mirrors.aliyun.com/ubuntu/ xenial main
|
|
||||||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
|
|
||||||
|
|
||||||
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
|
|
||||||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
|
|
||||||
|
|
||||||
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
|
|
||||||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
|
|
||||||
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
|
|
||||||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
|
|
||||||
|
|
||||||
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
|
|
||||||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
|
|
||||||
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
|
|
||||||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
|
|
||||||
```
|
|
||||||
|
|
||||||
> 在mirrors.aliyun.com里可以查看具体配置方法
|
|
||||||
|
|
||||||
- 更新系统
|
|
||||||
|
|
||||||
```bash
|
|
||||||
apt update && apt upgrade -y
|
|
||||||
```
|
|
||||||
|
|
||||||
### 安装依赖
|
|
||||||
|
|
||||||
- apt部分
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt install python-dev swig ffmpeg yasm unixodbc-dev libshout3-dev libmpg123-dev libmp3lame-dev libsndfile-dev autoconf automake devscripts libopus-dev libvorbis0a libogg0 libogg-dev libvorbis-dev gawk g++ git-core libjpeg-dev libncurses5-dev libtool-bin pkg-config libtiff5-dev libperl-dev libgdbm-dev libdb-dev gettext libssl-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libspeexdsp-dev libsqlite3-dev libedit-dev libldns-dev libpq-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
如果需要开启mod_lua模块,还需要安装lua
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt install lua5.3 liblua5.3-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
- pip安装
|
|
||||||
|
|
||||||
```bash
|
|
||||||
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
|
|
||||||
python get-pip.py
|
|
||||||
pip install pydub
|
|
||||||
pip install python-ESL
|
|
||||||
pip install pika
|
|
||||||
pip install dbutils
|
|
||||||
```
|
|
||||||
|
|
||||||
### 下载源码
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/signalwire/freeswitch.git
|
|
||||||
cd freeswitch
|
|
||||||
git checkout v1.6
|
|
||||||
git remote rm origin
|
|
||||||
```
|
|
||||||
|
|
||||||
> 最后一句是断开本地目录和远程代码库的关联
|
|
||||||
|
|
||||||
## 安装freeswitch
|
|
||||||
|
|
||||||
- 配置lua(如果不需要mod_lua模块,可跳过)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cp /usr/include/lua5.3/*.h src/mod/languages/mod_lua/
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.3.so /usr/lib/x86_64-linux-gnu/liblua.so
|
|
||||||
```
|
|
||||||
|
|
||||||
- 预处理
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo ./bootstrap.sh -j
|
|
||||||
```
|
|
||||||
|
|
||||||
- 预配置模块
|
|
||||||
|
|
||||||
```bash
|
|
||||||
vim modules.conf
|
|
||||||
```
|
|
||||||
|
|
||||||
打开注释
|
|
||||||
|
|
||||||
```conf
|
|
||||||
formats/mod_shout
|
|
||||||
languages/mod_python
|
|
||||||
event_handlers/mod_cdr_pg_csv
|
|
||||||
asr_tts/mod_unimrcp
|
|
||||||
```
|
|
||||||
|
|
||||||
如果不需要使用lua语言模块,则将下面内容加注释
|
|
||||||
|
|
||||||
```conf
|
|
||||||
#languages/mod_lua
|
|
||||||
```
|
|
||||||
|
|
||||||
- 预编译
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./configure --with-python=/usr/bin/python2.7 --with-lua=/usr/bin/lua5.3 --enable-core-pgsql-support
|
|
||||||
```
|
|
||||||
|
|
||||||
- 编译安装
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo make
|
|
||||||
sudo make mod_cdr_pg_csv-install
|
|
||||||
sudo make mod_unimrcp-install
|
|
||||||
sudo make install
|
|
||||||
```
|
|
||||||
|
|
||||||
- 安装声音包
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo make sounds-install
|
|
||||||
sudo make moh-install
|
|
||||||
sudo make cd-sounds-install
|
|
||||||
sudo make cd-moh-install
|
|
||||||
sudo make uhd-sounds-install
|
|
||||||
sudo make uhd-moh-install
|
|
||||||
```
|
|
||||||
|
|
||||||
- 建立软连接
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo ln -sf /usr/local/freeswitch/bin/freeswitch /usr/local/bin/
|
|
||||||
sudo ln -sf /usr/local/freeswitch/bin/fs_cli /usr/local/bin/
|
|
||||||
```
|
|
||||||
|
|
||||||
- 配置mod
|
|
||||||
|
|
||||||
```bash
|
|
||||||
vim /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
|
|
||||||
```
|
|
||||||
|
|
||||||
打开注释
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<load module="mod_python"/>
|
|
||||||
<load module="mod_shout"/>
|
|
||||||
```
|
|
||||||
|
|
||||||
添加配置
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<load module="mod_cdr_pg_csv"/>
|
|
||||||
<load module="mod_unimrcp"/>
|
|
||||||
<load module="mod_vad"/>
|
|
||||||
```
|
|
||||||
|
|
||||||
如果不需要lua支持,则注释下面内容
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<!-- <load module="mod_lua"> -->
|
|
||||||
```
|
|
||||||
|
|
||||||
- 配置acl白名单
|
|
||||||
|
|
||||||
```bash
|
|
||||||
vim /usr/local/freeswitch/conf/autoload_configs/acl.conf.xml
|
|
||||||
```
|
|
||||||
|
|
||||||
根据自己网络的实际情况进行配置(照抄大概率无效)
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<list name="domains" default="deny">
|
|
||||||
<!-- domain= is special it scans the domain from the directory to build t$ -->
|
|
||||||
<node type="allow" domain="$${domain}"/>
|
|
||||||
<!-- use cidr= if you wish to allow ip ranges to this domains acl. -->
|
|
||||||
<!-- <node type="allow" cidr="192.168.0.0/24"/> -->
|
|
||||||
<node type="allow" cidr="192.168.0.112/24"/>
|
|
||||||
<node type="allow" cidr="192.168.0.50/24"/>
|
|
||||||
<!-- ==================这里添加 本机ip 127.0.0.1 ======================== -->
|
|
||||||
<!-- ==================这里添加 本机内网ip ======================== -->
|
|
||||||
<!-- ==================这里添加 本机外网ip ======================== -->
|
|
||||||
<!-- ==================这里添加 web内网ip 192.168.2.173======================== -->
|
|
||||||
<!-- ==================这里添加 web外网ip 39.107.68.127======================== -->
|
|
||||||
<!-- ==================这里添加 runcall 内外网Ip======================== -->
|
|
||||||
<node type="allow" cidr="192.168.2.178/24"/>
|
|
||||||
<node type="allow" cidr="39.107.70.84/24"/>
|
|
||||||
</list>
|
|
||||||
```
|
|
||||||
|
|
||||||
- 配置ESL
|
|
||||||
|
|
||||||
```bash
|
|
||||||
vim /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml
|
|
||||||
```
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<configuration name="event_socket.conf" description="Socket Client">
|
|
||||||
<settings>
|
|
||||||
<param name="nat-map" value="false"/>
|
|
||||||
<!--ip 统一为0.0.0.0-->
|
|
||||||
<param name="listen-ip" value="0.0.0.0"/>
|
|
||||||
<!-- 端口号 默认8021 -->
|
|
||||||
<param name="listen-port" value="8021"/>
|
|
||||||
<!-- 密码统一Aicyber -->
|
|
||||||
<param name="password" value="Aicyber"/>
|
|
||||||
<!-- 允许acl白名单内的IP 访问 -->
|
|
||||||
<param name="apply-inbound-acl" value="domains"/>
|
|
||||||
<!--<param name="apply-inbound-acl" value="loopback.auto"/>-->
|
|
||||||
<!--<param name="stop-on-bind-error" value="true"/>-->
|
|
||||||
</settings>
|
|
||||||
</configuration>
|
|
||||||
```
|
|
||||||
|
|
||||||
- 配置VAD(可暂时省略)
|
|
||||||
|
|
||||||
把mod_vad.so(到已经配置好的服务器上去拉)和mod_G729.so(已经有了)放到/usr/local/freeswitch/mod目录下,并给可执行权
|
|
||||||
|
|
||||||
```bash
|
|
||||||
chmod +x mod_vad.so
|
|
||||||
```
|
|
||||||
|
|
||||||
- 配置网关(可暂时省略)
|
|
||||||
|
|
||||||
在/usr/local/freeswitch/conf/sip_profiles/external 目录下上传网关模板gw1.xml(这个模板在动态生成xml时会用到)
|
|
||||||
|
|
||||||
手动添加网关配置(可暂时省略)
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<include>
|
|
||||||
<gateway name="gw1"><!--PSTN -->
|
|
||||||
<param name="realm" value="192.168.0.153"/>
|
|
||||||
<param name="register" value="false"/>
|
|
||||||
</gateway>
|
|
||||||
</include>
|
|
||||||
```
|
|
||||||
|
|
||||||
## 4. 启动freeswitch
|
|
||||||
|
|
||||||
```bash
|
|
||||||
freeswitch -nc
|
|
||||||
```
|
|
||||||
|
|
||||||
通过fs_cli可以进入freeswitch控制台(freeswitch服务启动需要等一段时间,而且可能会很长)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
fs_cli --password=Aicyber
|
|
||||||
```
|
|
213
docs/freeswitch/ubuntu1604.md
Normal file
213
docs/freeswitch/ubuntu1604.md
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
# 【安装】在ubuntu16.04系统上安装freeswitch1.6
|
||||||
|
|
||||||
|
## 操作系统和软件版本
|
||||||
|
|
||||||
|
ubuntu16.04
|
||||||
|
|
||||||
|
freeswitch v1.6
|
||||||
|
|
||||||
|
python2.7
|
||||||
|
|
||||||
|
lua5.1
|
||||||
|
|
||||||
|
## 准备工作
|
||||||
|
|
||||||
|
### 安装系统
|
||||||
|
|
||||||
|
最小安装ubuntu16.04系统,安装ssh server
|
||||||
|
|
||||||
|
### 安装依赖
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo apt-get install -y \
|
||||||
|
python-dev swig ffmpeg \
|
||||||
|
yasm unixodbc-dev \
|
||||||
|
libshout3-dev libmpg123-dev \
|
||||||
|
libmp3lame-dev libsndfile-dev \
|
||||||
|
autoconf automake devscripts \
|
||||||
|
libopus-dev libvorbis0a \
|
||||||
|
libogg0 libogg-dev \
|
||||||
|
libvorbis-dev gawk \
|
||||||
|
g++ git-core libjpeg-dev \
|
||||||
|
libncurses5-dev libtool-bin \
|
||||||
|
pkg-config libtiff5-dev \
|
||||||
|
libperl-dev libgdbm-dev \
|
||||||
|
libdb-dev gettext libssl-dev \
|
||||||
|
libcurl4-openssl-dev \
|
||||||
|
libpcre3-dev libspeex-dev \
|
||||||
|
libspeexdsp-dev libsqlite3-dev \
|
||||||
|
libedit-dev libldns-dev \
|
||||||
|
libpq-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
如果需要开启mod_lua模块,还需要安装lua
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo apt-get install -y lua5.1 liblua5.1-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
- 安装一些python依赖
|
||||||
|
|
||||||
|
安装dbutils可能会失败,是因为python和pip的版本太老了。
|
||||||
|
|
||||||
|
这一步不是必须的,只有在你需要用python2为FreeSWITCH写脚本时才会用到。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
|
||||||
|
python get-pip.py
|
||||||
|
pip install pydub
|
||||||
|
pip install python-ESL
|
||||||
|
pip install pika
|
||||||
|
pip install dbutils
|
||||||
|
```
|
||||||
|
|
||||||
|
### 下载源码
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://github.com/signalwire/freeswitch.git
|
||||||
|
cd freeswitch
|
||||||
|
git checkout v1.6
|
||||||
|
git remote rm origin
|
||||||
|
```
|
||||||
|
|
||||||
|
> 最后一句是断开本地目录和远程代码库的关联
|
||||||
|
|
||||||
|
## 安装freeswitch
|
||||||
|
|
||||||
|
- 配置lua
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp /usr/include/lua5.1/*.h src/mod/languages/mod_lua/
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.so /usr/lib/x86_64-linux-gnu/liblua.so
|
||||||
|
```
|
||||||
|
|
||||||
|
- 预处理
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./bootstrap.sh -j
|
||||||
|
```
|
||||||
|
|
||||||
|
- 预配置模块
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim modules.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
打开注释
|
||||||
|
|
||||||
|
```conf
|
||||||
|
formats/mod_shout
|
||||||
|
languages/mod_python
|
||||||
|
event_handlers/mod_cdr_pg_csv
|
||||||
|
asr_tts/mod_unimrcp
|
||||||
|
```
|
||||||
|
|
||||||
|
如果不需要使用lua语言模块,则将下面内容加注释
|
||||||
|
|
||||||
|
```conf
|
||||||
|
#languages/mod_lua
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编译安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./configure --with-python=/usr/bin/python2.7 --with-lua=/usr/bin/lua5.1 --enable-core-pgsql-support
|
||||||
|
sudo make
|
||||||
|
sudo make mod_cdr_pg_csv-install
|
||||||
|
sudo make mod_unimrcp-install
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 安装声音包
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo make sounds-install
|
||||||
|
sudo make moh-install
|
||||||
|
sudo make cd-sounds-install
|
||||||
|
sudo make cd-moh-install
|
||||||
|
sudo make uhd-sounds-install
|
||||||
|
sudo make uhd-moh-install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 全局命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ln -sf /usr/local/freeswitch/bin/freeswitch /usr/local/bin/
|
||||||
|
sudo ln -sf /usr/local/freeswitch/bin/fs_cli /usr/local/bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置模块
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
打开注释
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<load module="mod_python"/>
|
||||||
|
<load module="mod_shout"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
添加配置
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<load module="mod_cdr_pg_csv"/>
|
||||||
|
<load module="mod_unimrcp"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置acl白名单
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/acl.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
根据自己网络的实际情况进行配置(照抄大概率无效)
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<list name="domains" default="deny">
|
||||||
|
<!-- domain= is special it scans the domain from the directory to build t$ -->
|
||||||
|
<node type="allow" domain="$${domain}"/>
|
||||||
|
<!-- use cidr= if you wish to allow ip ranges to this domains acl. -->
|
||||||
|
<node type="allow" cidr="127.0.0.1/32"/>
|
||||||
|
</list>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置ESL
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<configuration name="event_socket.conf" description="Socket Client">
|
||||||
|
<settings>
|
||||||
|
<param name="nat-map" value="false"/>
|
||||||
|
<!--ip 统一为0.0.0.0-->
|
||||||
|
<param name="listen-ip" value="0.0.0.0"/>
|
||||||
|
<!-- 端口号 默认8021 -->
|
||||||
|
<param name="listen-port" value="8021"/>
|
||||||
|
<!-- 密码统一ClueCon -->
|
||||||
|
<param name="password" value="ClueCon"/>
|
||||||
|
<!-- 允许acl白名单内的IP 访问 -->
|
||||||
|
<param name="apply-inbound-acl" value="domains"/>
|
||||||
|
<!--<param name="apply-inbound-acl" value="loopback.auto"/>-->
|
||||||
|
<!--<param name="stop-on-bind-error" value="true"/>-->
|
||||||
|
</settings>
|
||||||
|
</configuration>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. 启动freeswitch
|
||||||
|
|
||||||
|
```bash
|
||||||
|
freeswitch -nc
|
||||||
|
```
|
||||||
|
|
||||||
|
通过fs_cli可以进入freeswitch控制台(freeswitch服务启动需要等一段时间,而且可能会很长)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fs_cli --password=ClueCon
|
||||||
|
```
|
154
docs/php/nginx.md
Normal file
154
docs/php/nginx.md
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
# 编译安装nginx
|
||||||
|
|
||||||
|
> wandoubaba / 2023-07-21
|
||||||
|
|
||||||
|
## 系统环境
|
||||||
|
|
||||||
|
以Debian11为例
|
||||||
|
|
||||||
|
## 下载源码
|
||||||
|
|
||||||
|
以1.24.0版本为例,下载nginx:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
wget https://nginx.org/download/nginx-1.24.0.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
如果提示`wget: command not found`就先安装wget,执行`sudo apt-get install wget`就行。
|
||||||
|
|
||||||
|
解压:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
tar zxvf nginx-1.24.0.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
## 安装依赖
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo apt-get install libgd-dev build-essential zlib1g-dev libpcre3-dev libssl-dev lsb-release
|
||||||
|
```
|
||||||
|
|
||||||
|
## 创建www用户和组
|
||||||
|
|
||||||
|
查看www用户是否存在
|
||||||
|
|
||||||
|
```sh
|
||||||
|
id www
|
||||||
|
```
|
||||||
|
|
||||||
|
创建www分组和www用户,并且不允许登录系统
|
||||||
|
|
||||||
|
```sh
|
||||||
|
groupadd www
|
||||||
|
useradd -g www -s /sbin/nologin www
|
||||||
|
```
|
||||||
|
|
||||||
|
再查看www用户
|
||||||
|
|
||||||
|
```sh
|
||||||
|
id www
|
||||||
|
```
|
||||||
|
|
||||||
|
## 编译安装
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd nginx-1.24.0
|
||||||
|
```
|
||||||
|
|
||||||
|
带参数执行编译
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./configure --user=www --group=www \
|
||||||
|
--with-http_ssl_module \
|
||||||
|
--with-http_v2_module \
|
||||||
|
--with-http_realip_module \
|
||||||
|
--with-http_image_filter_module \
|
||||||
|
--with-http_addition_module \
|
||||||
|
--with-http_stub_status_module \
|
||||||
|
--with-stream \
|
||||||
|
--with-stream_ssl_module \
|
||||||
|
--with-stream_ssl_preread_module \
|
||||||
|
--with-http_gzip_static_module \
|
||||||
|
--with-http_gunzip_module \
|
||||||
|
--with-http_sub_module \
|
||||||
|
--with-http_flv_module \
|
||||||
|
--with-http_mp4_module \
|
||||||
|
--with-http_dav_module \
|
||||||
|
--with-openssl-opt=-g \
|
||||||
|
--with-pcre-opt=-g \
|
||||||
|
--with-pcre
|
||||||
|
```
|
||||||
|
|
||||||
|
安装:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
经过以上步骤,nginx已经被安装到`/usr/local/nginx`目录下,程序文件位于`/usr/local/nginx/sbin/nginx`。
|
||||||
|
|
||||||
|
## 启动服务
|
||||||
|
|
||||||
|
可以先把nginx程序路径写到系统环境中(可以把这条命令加到`~/.bashrc`文件中)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export PATH=/usr/local/nginx/sbin/:$PATH
|
||||||
|
```
|
||||||
|
|
||||||
|
执行直接执行`nginx`即可启动服务。
|
||||||
|
|
||||||
|
在浏览器访问`http://ip`(把IP换成你的nginx主机地址),如果防火墙和安全组都放行了80端口,我们现在应该能看到`Welcome to nginx`页面了。
|
||||||
|
|
||||||
|
用下面的命令可以控制服务的启停:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
## 重启服务
|
||||||
|
nginx -s reopen
|
||||||
|
## 停止服务
|
||||||
|
nginx -s stop
|
||||||
|
nginx -s quit
|
||||||
|
## 重载配置
|
||||||
|
nginx -s reload
|
||||||
|
```
|
||||||
|
|
||||||
|
## 注册系统服务
|
||||||
|
|
||||||
|
注意:操作系统不同,下面的方法可能不一样。
|
||||||
|
|
||||||
|
创建`/etc/systemd/system/nginx.service`文件:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[Unit]
|
||||||
|
Description=Nginx Service
|
||||||
|
After=syslog.target network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
PIDFile=/usr/local/nginx/logs/nginx.pid
|
||||||
|
ExecStartPre=/usr/local/nginx/sbin/nginx -t
|
||||||
|
ExecStart=/usr/local/nginx/sbin/nginx
|
||||||
|
ExecReload=/usr/local/nginx/sbin/nginx -s reload
|
||||||
|
ExecStop=/usr/local/nginx/sbin/nginx -s stop
|
||||||
|
PrivateTmp=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
执行下面的命令使服务生效并实现随系统启动:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
用下面的命令控制服务:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl start nginx
|
||||||
|
sudo systemctl restart nginx
|
||||||
|
sudo systemctl stop nginx
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
sudo systemctl status nginx
|
||||||
|
```
|
140
docs/php/openresty.md
Normal file
140
docs/php/openresty.md
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
# 编译安装OpenResty
|
||||||
|
|
||||||
|
> wandoubaba / 2023-07-21
|
||||||
|
|
||||||
|
## 系统环境
|
||||||
|
|
||||||
|
以Debian11为例
|
||||||
|
|
||||||
|
## 安装依赖
|
||||||
|
|
||||||
|
```sh
|
||||||
|
apt-get install wget libpcre3-dev libssl-dev perl make build-essential curl libgd-dev lsb-release
|
||||||
|
```
|
||||||
|
|
||||||
|
## 安装postgres模块依赖
|
||||||
|
|
||||||
|
我们这要安装驱动,而不是安装一个pg数据库服务,所以只需要安装一个`libpq-dev`就够了。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||||
|
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install libpq-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## 创建www用户和组
|
||||||
|
|
||||||
|
查看www用户是否存在
|
||||||
|
|
||||||
|
```sh
|
||||||
|
id www
|
||||||
|
```
|
||||||
|
|
||||||
|
创建www分组和www用户,并且不允许登录系统
|
||||||
|
|
||||||
|
```sh
|
||||||
|
groupadd www
|
||||||
|
useradd -g www -s /sbin/nologin www
|
||||||
|
```
|
||||||
|
|
||||||
|
再查看www用户
|
||||||
|
|
||||||
|
```sh
|
||||||
|
id www
|
||||||
|
```
|
||||||
|
|
||||||
|
## 下载源码包
|
||||||
|
|
||||||
|
```sh
|
||||||
|
wget https://openresty.org/download/openresty-1.21.4.2.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
## 解压&编译&安装
|
||||||
|
|
||||||
|
```sh
|
||||||
|
tar zxvf openresty-1.21.4.2.tar.gz
|
||||||
|
cd openresty-1.21.4.2
|
||||||
|
./configure \
|
||||||
|
--prefix=/www/server/openresty \
|
||||||
|
--with-pcre-jit \
|
||||||
|
--with-http_iconv_module \
|
||||||
|
--with-http_postgres_module \
|
||||||
|
--user=www --group=www \
|
||||||
|
--with-http_ssl_module \
|
||||||
|
--with-http_v2_module \
|
||||||
|
--with-http_realip_module \
|
||||||
|
--with-http_image_filter_module \
|
||||||
|
--with-http_addition_module \
|
||||||
|
--with-http_stub_status_module \
|
||||||
|
--with-stream \
|
||||||
|
--with-stream_ssl_module \
|
||||||
|
--with-stream_ssl_preread_module \
|
||||||
|
--with-http_gzip_static_module \
|
||||||
|
--with-http_gunzip_module \
|
||||||
|
--with-http_sub_module \
|
||||||
|
--with-http_flv_module \
|
||||||
|
--with-http_mp4_module \
|
||||||
|
--with-http_dav_module \
|
||||||
|
--with-openssl-opt=-g \
|
||||||
|
--with-pcre-opt=-g \
|
||||||
|
--with-pcre
|
||||||
|
gmake
|
||||||
|
gmake install
|
||||||
|
```
|
||||||
|
|
||||||
|
## 注册系统服务和开机自启
|
||||||
|
|
||||||
|
在`/etc/systemd/system/`目录下创建`nginx.service`文件,内容如下:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[Unit]
|
||||||
|
Description=Nginx HTTP Server
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
PIDFile=/www/server/openresty/nginx/logs/nginx.pid
|
||||||
|
ExecStartPre=/www/server/openresty/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'
|
||||||
|
ExecStart=/www/server/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;'
|
||||||
|
ExecReload=/www/server/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reload
|
||||||
|
ExecStop=/www/server/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;' -s quit
|
||||||
|
PrivateTmp=true
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
保存文件并退出后,执行下面命令:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
现在已完成系统服务注册和开机自启,下面是服务控制命令:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
systemctl start nginx # 启动nginx服务
|
||||||
|
systemctl stop nginx # 停止nginx服务
|
||||||
|
systemctl restart nginx # 重启nginx服务
|
||||||
|
systemctl reload nginx # 重新加载nginx配置文件
|
||||||
|
systemctl status nginx # 检查nginx服务状态
|
||||||
|
```
|
||||||
|
|
||||||
|
## 测试
|
||||||
|
|
||||||
|
正确启动服务后,使用`ps`命令可以查看nginx服务进程
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ps aux | grep nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
使用`ss`命令可以查看端口监听情况
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ss -tnlp | grep 80
|
||||||
|
```
|
||||||
|
|
||||||
|
在浏览器中访问`http://ip`应该可以看到OpenResty的默认欢迎页`Welcom to OpenResty`。
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
操作系统:CentOS7.9 / Debian11
|
操作系统:CentOS7.9 / Debian11
|
||||||
|
|
||||||
> 在Debian上操作相关简单,所以本文以Centos7.9为例
|
> 在Debian上操作相对简单,所以本文以Centos7.9为例
|
||||||
|
|
||||||
软件版本:PHP7.4, postgresql15
|
软件版本:PHP7.4, postgresql15
|
||||||
|
|
||||||
|
394
docs/php/php82.md
Normal file
394
docs/php/php82.md
Normal file
@ -0,0 +1,394 @@
|
|||||||
|
# 编译安装PHP8.2
|
||||||
|
|
||||||
|
> wandoubaba / 2023-07-21
|
||||||
|
|
||||||
|
以Debian11操作系统为例。
|
||||||
|
|
||||||
|
本文目标:在纯净的操作系统上安装PHP8.2环境,同时安装composer和pecl,并通过pecl安装一些常用的扩展,最终实现在环境中运行基于Workerman和Swoole框架的项目。
|
||||||
|
|
||||||
|
## 安装依赖
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo apt-get install -y \
|
||||||
|
wget make gcc curl \
|
||||||
|
libxml2 libxml2-dev \
|
||||||
|
libsqlite3-dev \
|
||||||
|
libwebp-dev libonig-dev \
|
||||||
|
libsodium-dev pkg-config \
|
||||||
|
libssl-dev openssl \
|
||||||
|
libgd-dev build-essential \
|
||||||
|
zlib1g-dev libpcre3-dev \
|
||||||
|
lsb-release autoconf \
|
||||||
|
libzip-dev unzip
|
||||||
|
```
|
||||||
|
|
||||||
|
安装`libcurl`
|
||||||
|
|
||||||
|
```sh
|
||||||
|
wget https://curl.se/download/curl-8.2.0.tar.gz
|
||||||
|
tar zxvf curl-8.2.0.tar.gz
|
||||||
|
cd curl-8.2.0
|
||||||
|
./configure --with-openssl
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
## 创建安装目录
|
||||||
|
|
||||||
|
为了让多个版本的PHP可以共存,我们不准备把PHP安装到默认目录内,而是为每个版本设置一个目录。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir -p /www/server/php/82/etc
|
||||||
|
```
|
||||||
|
|
||||||
|
## 创建www用户和组
|
||||||
|
|
||||||
|
查看www用户是否存在
|
||||||
|
|
||||||
|
```sh
|
||||||
|
id www
|
||||||
|
```
|
||||||
|
|
||||||
|
创建www分组和www用户,并且不允许登录系统
|
||||||
|
|
||||||
|
```sh
|
||||||
|
groupadd www
|
||||||
|
useradd -g www -s /sbin/nologin www
|
||||||
|
```
|
||||||
|
|
||||||
|
再查看www用户
|
||||||
|
|
||||||
|
```sh
|
||||||
|
id www
|
||||||
|
```
|
||||||
|
|
||||||
|
为www用户创建home目录,composer会用到。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir /home/www
|
||||||
|
chown www:www -R /home/www
|
||||||
|
usermod -d /home/www www
|
||||||
|
```
|
||||||
|
|
||||||
|
## 下载PHP
|
||||||
|
|
||||||
|
```sh
|
||||||
|
wget https://www.php.net/distributions/php-8.2.8.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
## 解压&编译&安装
|
||||||
|
|
||||||
|
```sh
|
||||||
|
tar zxvf php-8.2.8.tar.gz
|
||||||
|
cd php-8.2.8
|
||||||
|
./configure \
|
||||||
|
--prefix=/www/server/php/82 \
|
||||||
|
--with-config-file-path=/www/server/php/82/etc \
|
||||||
|
--enable-fpm \
|
||||||
|
--with-fpm-user=www \
|
||||||
|
--with-fpm-group=www \
|
||||||
|
--enable-mysqlnd \
|
||||||
|
--with-mysqli=mysqlnd \
|
||||||
|
--with-pdo-mysql=mysqlnd \
|
||||||
|
--with-freetype \
|
||||||
|
--with-jpeg \
|
||||||
|
--with-zlib \
|
||||||
|
--enable-xml \
|
||||||
|
--disable-rpath \
|
||||||
|
--enable-bcmath \
|
||||||
|
--enable-shmop \
|
||||||
|
--enable-sysvsem \
|
||||||
|
--with-curl \
|
||||||
|
--enable-mbregex \
|
||||||
|
--enable-mbstring \
|
||||||
|
--enable-intl \
|
||||||
|
--enable-ftp \
|
||||||
|
--enable-gd \
|
||||||
|
--with-openssl \
|
||||||
|
--with-mhash \
|
||||||
|
--enable-pcntl \
|
||||||
|
--enable-sockets \
|
||||||
|
--enable-soap \
|
||||||
|
--with-gettext \
|
||||||
|
--disable-fileinfo \
|
||||||
|
--enable-opcache \
|
||||||
|
--with-sodium=/usr/local/libsodium \
|
||||||
|
--with-webp
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
## 创建全局命令
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln -s /www/server/php/82/bin/php /usr/local/bin/php
|
||||||
|
ln -s /www/server/php/82/bin/phpize /usr/local/bin/phpize
|
||||||
|
```
|
||||||
|
|
||||||
|
## 创建php.ini
|
||||||
|
|
||||||
|
在PHP的源码目录下有`php.ini-development`和`php.ini-production`两个文件,分别表示“开发环境配置”和“生产环境配置”,这里我们直接使用生产环境的。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cp php.ini-production /www/server/php/82/etc/php.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
## 安装composer
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd /www/server/php/82/bin
|
||||||
|
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
|
||||||
|
php composer-setup.php
|
||||||
|
ln -s /www/server/php/82/bin/composer.phar /usr/local/bin/composer
|
||||||
|
composer selfupdate
|
||||||
|
composer --version
|
||||||
|
```
|
||||||
|
|
||||||
|
把composer源改成国内镜像
|
||||||
|
|
||||||
|
```sh
|
||||||
|
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 安装pecl
|
||||||
|
|
||||||
|
pecl是可以方便为PHP安装扩展的工具。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd /www/server/php/82/bin
|
||||||
|
wget http://pear.php.net/go-pear.phar
|
||||||
|
php go-pear.phar
|
||||||
|
ln -s /www/server/php/82/bin/pecl /usr/local/bin/pecl
|
||||||
|
```
|
||||||
|
|
||||||
|
## 安装扩展
|
||||||
|
|
||||||
|
- event扩展
|
||||||
|
|
||||||
|
event扩展可以使基于Workerman的项目发挥更高的性能。
|
||||||
|
|
||||||
|
注意提示:Include libevent OpenSSL support [yes] : 时输入no回车,其它直接敲回车就行。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
apt-get install libevent-dev -y
|
||||||
|
pecl install event
|
||||||
|
```
|
||||||
|
|
||||||
|
安装成功后,命令行会提示编译后的库文件所在的位置,如`/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/event.so`。
|
||||||
|
|
||||||
|
在`php.ini`文件的最后添加下面的内容:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[event]
|
||||||
|
extension="/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/event.so"
|
||||||
|
```
|
||||||
|
|
||||||
|
再执行`php -m`命令后会看到`event`扩展出现在了已安装的扩展列表中,说明扩展安装成功。
|
||||||
|
|
||||||
|
- zip扩展
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pecl install zip
|
||||||
|
```
|
||||||
|
|
||||||
|
在`php.ini`文件的最后添加:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[zip]
|
||||||
|
extension="/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/zip.so"
|
||||||
|
```
|
||||||
|
|
||||||
|
- redis扩展
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pecl install redis
|
||||||
|
```
|
||||||
|
|
||||||
|
在`php.ini`文件的最后添加:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[redis]
|
||||||
|
extension="/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/redis.so"
|
||||||
|
```
|
||||||
|
|
||||||
|
- swoole扩展
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pecl install swoole
|
||||||
|
```
|
||||||
|
|
||||||
|
在`php.ini`文件的最后添加:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[swoole]
|
||||||
|
extension="/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/swoole.so"
|
||||||
|
```
|
||||||
|
|
||||||
|
- protobuf扩展
|
||||||
|
|
||||||
|
如果项目中需要使用到gRPC服务端或客户端,就要安装protobuf扩展
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pecl install protobuf
|
||||||
|
```
|
||||||
|
|
||||||
|
在`php.ini`文件的最后添加:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[protobuf]
|
||||||
|
extension="/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/protobuf.so"
|
||||||
|
```
|
||||||
|
|
||||||
|
- xlswriter扩展
|
||||||
|
|
||||||
|
如果项目中需要读或写excel文件,可以尝试一下这个扩展,它的最大特点的就解析速度,无论读还是写(但是并不具备phpoffice/phpspreadsheet的所有功能)。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pecl install xlswriter
|
||||||
|
```
|
||||||
|
|
||||||
|
在`php.ini`文件的最后添加:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[xlswriter]
|
||||||
|
extension="/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/xlswriter.so"
|
||||||
|
```
|
||||||
|
|
||||||
|
- pdo_pgsql扩展
|
||||||
|
|
||||||
|
如果项目中需要使用postgresql数据库,就需要安装这个扩展。
|
||||||
|
|
||||||
|
先安装pg数据库的驱动库libpg:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||||
|
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install libpq-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
然后进入PHP源代码目录中的`ext/pdo_pgsql`目录下
|
||||||
|
|
||||||
|
```sh
|
||||||
|
## 注意要把下面的path/to换成实际路径
|
||||||
|
cd path/to/php-8.2.8/ext/pdo_pgsql
|
||||||
|
phpize
|
||||||
|
./configure --with-php-config=/www/server/php/82/bin/php-config
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
在`php.ini`文件的最后添加:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[pdo_pgsql]
|
||||||
|
extension="/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/pdo_pgsql.so"
|
||||||
|
```
|
||||||
|
|
||||||
|
- fileinfo扩展
|
||||||
|
|
||||||
|
fileinfo通过在文件的给定位置查找特定的魔术字节序列,来获取文件的MIME信息。laravel框架依赖这个扩展。
|
||||||
|
|
||||||
|
进入PHP源代码目录中的`ext/fileinfo`目录下
|
||||||
|
|
||||||
|
```sh
|
||||||
|
## 注意要把下面的path/to换成实际路径
|
||||||
|
cd path/to/php-8.2.8/ext/fileinfo
|
||||||
|
phpize
|
||||||
|
./configure --with-php-config=/www/server/php/82/bin/php-config
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
在`php.ini`文件的最后添加:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[fileinfo]
|
||||||
|
extension="/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/fileinfo.so"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 测试
|
||||||
|
|
||||||
|
独立的php-cli环境已经安装完成了,下面我们可以用简单的HTTP服务框架`webman`测试一下。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir /www/wwwroot
|
||||||
|
cd /www/wwwroot
|
||||||
|
composer create-project workerman/webman
|
||||||
|
cd webman
|
||||||
|
php start.php start
|
||||||
|
```
|
||||||
|
|
||||||
|
一切顺利的话,应该可以在命令行中看到已经启动了名为`webman`的服务进程,默认监听端口`8787`
|
||||||
|
|
||||||
|
```sh
|
||||||
|
Workerman[start.php] start in DEBUG mode
|
||||||
|
------------------------------------------- WORKERMAN -------------------------------------------
|
||||||
|
Workerman version:4.1.11 PHP version:8.2.8 Event-Loop:\Workerman\Events\Event
|
||||||
|
-------------------------------------------- WORKERS --------------------------------------------
|
||||||
|
proto user worker listen processes status
|
||||||
|
tcp root webman http://0.0.0.0:8787 16 [OK]
|
||||||
|
tcp root monitor none 1 [OK]
|
||||||
|
-------------------------------------------------------------------------------------------------
|
||||||
|
Press Ctrl+C to stop. Start success.
|
||||||
|
```
|
||||||
|
|
||||||
|
这个时候使用浏览器访问`http://ip:8787`就可以看到webman框架的欢迎页了。
|
||||||
|
|
||||||
|
## 启用php-fpm
|
||||||
|
|
||||||
|
为了与nginx整合以支持类似laravel或tp这样的fpm框架,我们还需要启动php-fpm服务。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln -s /www/server/php/82/sbin/php-fpm /usr/local/bin/php-fpm
|
||||||
|
cd /www/server/php/82/etc/php-fpm.d
|
||||||
|
cp www.conf.default www.conf
|
||||||
|
php-fpm
|
||||||
|
```
|
||||||
|
|
||||||
|
要实现多版本PHP环境共存,主要是解决不同版本的php-fpm服务监听端口冲突的问题,我们可以做个约定规则,就是让各个版本的php-fpm都监听`90xx`端口,比如我们现在安装的是8.2版本,那就让它的php-fpm监听`9082`端口。
|
||||||
|
|
||||||
|
修改`www.conf`文件,找到`listen = 127.0.0.1:9000`一行,把它改为`listen = 127.0.0.1:9082`,保存退出即可。
|
||||||
|
|
||||||
|
下面要把php-fpm注册为系统服务。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
touch /etc/systemd/system/php-fpm.service
|
||||||
|
vim /etc/systemd/system/php-fpm.service
|
||||||
|
```
|
||||||
|
|
||||||
|
文件内容:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[Unit]
|
||||||
|
Description=The PHP 8.2 FastCGI Process Manager
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
PIDFile=/run/php-fpm.pid
|
||||||
|
ExecStart=/www/server/php/82/sbin/php-fpm --nodaemonize --fpm-config /www/server/php/82/etc/php-fpm.conf
|
||||||
|
ExecReload=/bin/kill -USR2 MAINPID
|
||||||
|
ExecStop=/bin/kill −SIGINT MAINPID
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
保存退出后执行下面的命令:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable php-fpm
|
||||||
|
```
|
||||||
|
|
||||||
|
服务控制命令:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl start php-fpm
|
||||||
|
sudo systemctl restart php-fpm
|
||||||
|
sudo systemctl stop php-fpm
|
||||||
|
sudo systemctl reload php-fpm
|
||||||
|
sudo systemctl status php-fpm
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user