侧边栏壁纸
博主头像
lukeewin的博客博主等级

行动起来,活在当下

  • 累计撰写 10 篇文章
  • 累计创建 1 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

安装freeswitch

Administrator
2024-09-13 / 0 评论 / 0 点赞 / 9 阅读 / 14080 字 / 正在检测是否收录...

1. 源码编译安装nginx

修改使用阿里yum

cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo-backup
curl http://mirrors.aliyun.com/repo/Centos-7.repo -o CentOS-Base.repo
yum clean all
yum makecache
yum update

安装gcc编译器

yum -y install gcc gcc-c++ libstdc++-devel pcre pcre-devel zlib zlib-devel openssl openssl-devel

下载源码

wget http://nginx.org/download/nginx-1.16.1.tar.gz

解压源码

tar -xzvf nginx-1.16.1.tar.gz

进入源码

cd nginx-1.16.1

执行配置

./configure --prefix=/usr/soft/nginx/   --with-http_ssl_module --with-stream

编译

make -j 4

安装

make install

注册成系统服务

在下面目录中创建一个nginx.service文件

vim /lib/systemd/system/nginx.service

写入下面内容

[Unit] 
Description=nginx 
After=network.target 

[Service]
Type=forking
ExecStart=/usr/soft/nginx/sbin/nginx
ExecReload=/usr/soft/nginx/sbin/nginx -s reload
ExecStop=/usr/soft/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target

启动nginx

systemctl start nginx

设置开机自启

systemctl enable nginx

开放防火墙端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

重载防火墙规则

firewall-cmd --reload

查看防火墙开放了哪些端口

firewall-cmd --list-ports

2. 源码编译安装MySQL

下载源码

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.35.tar.gz

安装依赖

yum install -y cmake ncurses ncurses-devel bison libaio-devel gcc gcc-c++ glibc cmake autoconf openssl openssl-devel

创建目录存放MySQL

useradd -s /sbin/nologin mysql
mkdir -p /data/mysql/data
chown -R mysql:mysql /data/mysql
tar -zxvf mysql-5.7.35.tar.gz -C /usr/local/mysql/

切换到MySQL目录,执行编译

cd /usr/local/mysql/
```shell
cmake -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/mysql

编译安装

make -j 4 && make install

修改/etc/my.cnf文件

[client]
port    = 3306
socket  = /usr/local/mysql/mysql.sock

[mysqld]
character-set-server=utf8mb4
basedir = /usr/local/mysql
datadir = /data/mysql/data
pid-file = /data/mysql/mysql.pid
socket = /usr/local/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
log_error = /data/mysql/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql-slow.log

skip-external-locking
key_buffer_size = 32M
max_allowed_packet = 1024M
table_open_cache = 128
sort_buffer_size = 768K
net_buffer_length = 8K
read_buffer_size = 768K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 16
query_cache_size = 16M
tmp_table_size = 32M
performance_schema_max_table_instances = 1000

explicit_defaults_for_timestamp = true
skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

log_bin=mysql-bin
binlog_format=mixed
server_id   = 232
expire_logs_days = 10
early-plugin-load = ""

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_buffer_pool_size = 128M
innodb_log_file_size = 32M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 32M
sort_buffer_size = 768K
read_buffer = 2M
write_buffer = 2M


#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

初始化MySQL

./mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

对初始化参数的说明

--initialize-insecure 表示初始化的时候不生成默认密码
--initialize 表示初始化的时候生成默认密码,默认密码保存到log-error里,查询temporary password
--basedir 指定mysql安装路径,需要与my.cnf配置中的路径一致
--datadir 指定存储mysql数据路径,需要与my.cnf配置中的路径一致

交给系统管理,首先需要复制一个文件到指定的位置

cd support-files
cp /usr/local/mysql/mysql-5.7.35/support-files/mysql.server /lib/systemd/system

启动MySQL服务

systemctl start mysqld
systemctl enable mysqld

配置系统环境变量

vim /etc/profile
PATH=/usr/local/mysql/bin:$PATH
source /etc/profile

连接到MySQL,并且给MySQL设置密码

mysql -uroot -p
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
FLUSH PRIVILEGES;

3. 安装PHP

安装EPELRemi仓库

yum install epel-release -y
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y

安装yum源管理工具

yum install yum-utils -y

安装PHP7.3

yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xml

启动并设置开机自启

systemctl start php73-php-fpm
systemctl enable php73-php-fpm

编辑/etc/opt/remi/php73/php.ini替换;cgi.fix_pathinfo=1cgi.fix_pathinfo=0快捷命令

sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/opt/remi/php73/php.ini

重启PHP

systemctl restart php73-php-fpm

检查是否安装成功

php73 -v

4. 安装Redis

因为Redis使用C语言开发的,所有需要安装gcc编译器,如果你还没有安装的,可以执行下面命令安装,如果已经安装,则忽略该命令

yum install gcc-c++ -y

下载源码

wget http://download.redis.io/releases/redis-5.0.8.tar.gz

解压源码

tar -zxvf redis-5.0.8.tar.gz

编译安装

make -j 4 && make install PREFIX=/usr/local/redis

复制源码中的一个文件到安装目录下

cp /usr/software/redis-5.0.8/redis.conf /usr/local/redis/bin/

修改配置文件,使得可以以后台方式运行

vim /usr/local/redis/bin/redis.conf
```shell
# 找到 daemonize no
# 修改为
daemonize yes

启动Redis服务端

cd /usr/local/redis/bin
./redis-server ./redis.conf

查看是否启动成功

ps aux|grep redis

关闭Redis,如果直接kill,会导致持久化数据异常,所以我们需要通过Redis客户端发送关闭命令方式关闭Redis

cd /usr/local/redis/bin
./redis-cli shutdown

设置开机自启

vim /etc/systemd/system/redis.service
```shell
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target
```shell
systemctl start redis.service #启动redis服务 
systemctl enable redis.service #设置开机自启动 
systemctl disable redis.service #停止开机自启动 
systemctl status redis.service #查看服务当前状态 
systemctl restart redis.service  #重新启动服务 
systemctl list-units --type=service #查看所有已启动的服务 

5. 安装PHP拓展

5.1 安装Redis

安装依赖

yum -y install php-mcrypt libmcrypt-devel libxml2 libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libxslt libxslt-devel cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib m4 autoconf gcc gcc-c++ openssl openssl-devel pcre pcre-devel zlib zlib-devel wget net-tools zip php-ldap php73-php-devel

解压并进入

tar -xzvf redis-4.0.2.tgz
cd redis-4.0.2

执行下面命令

/opt/remi/php73/root/usr/bin/phpize
./configure --with-php-config=/opt/remi/php73/root/usr/bin/php-config
make -j 4 && make install

修改php.ini文件

vim /etc/opt/remi/php73/php.ini

添加下面语句

extension=redis.so

5.2 安装Swoole4

安装依赖

yum install -y gcc gcc-c++ make autoconf libtool libxml2-devel openssl-devel curl-devel libcurl-devel bzip2-devel libmcrypt-devel libpng-devel libjpeg-devel freetype-devel

创建软链接,方便之后使用phpize

ln -s /opt/remi/php73/root/usr/bin/phpize /usr/bin/phpize

下载源码

wget https://github.com/swoole/swoole-src/archive/refs/tags/v4.8.13.tar.gz

解压源码

tar -zxvf v4.8.13.tar.gz

进入源码

cd swoole-src-4.8.13

执行配置

phpize
./configure --with-php-config=/opt/remi/php73/root/usr/bin/php-config

编译安装

make -j 4 && make install

修改php.ini文件

vim /etc/opt/remi/php73/php.ini

添加下面语句

extension=swoole.so

重启php

systemctl restart php73-php-fpm

查看版本

php73 --ri swoole

6. 源码编译安装freeswitch

设置环境变量

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib

安装依赖

yum install -y epel-release \
    git autoconf automake bison wget \
    openssl-devel \
    curl-devel \
    gdbm-devel \
    gcc-c++ \
    gnutls-devel \
    libcurl-devel \
    libjpeg-devel \
    libogg-devel \
    libtiff-devel \
    libtool \
    libuuid-devel \
    libxml2-devel \
    ncurses-devel \
    opus-devel \
    pcre-devel \
    pkgconfig \
    portaudio-devel \
    postgresql-devel \
    python3-devel \
    sqlite-devel \
    unixODBC-devel \
    zlib-devel \
    yasm \
    nasm \
    libedit-devel \
    libatomic \
    lua-devel
```shell
yum localinstall -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
```shell
yum install -y ffmpeg ffmpeg-devel speex-devel speexdsp-devel libshout-devel libmpg123-devel lame-devel libsndfile-devel

切换路径

cd /usr/software

下载源码

wget https://files.freeswitch.org/releases/freeswitch/freeswitch-1.6.19.tar.gz

解压源码

tar -zxvf freeswitch-1.6.19.tar.gz

执行命令

cd freeswitch-1.6.19
./rebootstrap.sh

编辑modules.conf

vim modules.conf
# 注释 mod_enum, mod_opus
# 取消注释 mod_shout

执行下面命令

cp /usr/software/freeswitch-1.6.19/modules.conf ./
sed -i '/mod_enum/d' modules.conf
sed -i '/mod_opus/d' modules.conf
sed -i 's+#formats/mod_shout+formats/mod_shout+g' modules.conf
sed -i 's+#asr_tts/mod_unimrcp+asr_tts/mod_unimrcp+g' modules.conf

执行配置

./configure --disable-libvpx

编译安装

make -j 4 && make install
make sounds-install && make moh-install

建立软链接

ln -sf /usr/local/freeswitch/bin/freeswitch /usr/bin
ln -sf /usr/local/freeswitch/bin/fs_cli /usr/bin

复制freeswitch.service/lib/systemd/system

cp /usr/software/freeswitch-1.6.19/build/freeswitch.service /lib/systemd/system

修改freeswitch.service文件

[Unit]
Description=FreeSWITCH
After=syslog.target network.target
After=postgresql.service postgresql-9.3.service postgresql-9.4.service mysqld.service httpd.service

[Service]
User=root
EnvironmentFile=-/etc/sysconfig/freeswitch
# RuntimeDirectory is not yet supported in CentOS 7. A workaround is to use /etc/tmpfiles.d/freeswitch.conf
#RuntimeDirectory=/run/freeswitch
#RuntimeDirectoryMode=0750
WorkingDirectory=/usr/local/freeswitch
ExecStart=/usr/local/freeswitch/bin/freeswitch -nc -nf $FREESWITCH_PARAMS
ExecReload=/usr/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

启动freeswitch

systemctl daemon-reload
systemctl restart freeswitch
systemctl enable freeswitch
systemctl status freeswitch

检查是否启动freeswitch

ps aux|grep freeswitch
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区