#!/bin/sh
#安装必要插件
yum install -y epel-release && \
yum update -y && \
yum install -y deltarpm && \
yum install -y openssh-server sudo which file curl zip unzip wget && \
yum install -y libmicrohttpd-devel jansson-devel libnice-devel glib22-devel opus-devel libogg-devel pkgconfig gengetopt libtool autoconf automake make gcc gcc-c++ git cmake libconfig-devel openssl-devel
-------------------------------------------------------------------------------------------------1
#安装 libsrtp
#upgrade libsrtp 1.5.4
#wget https://github.com/cisco/libsrtp/archive/v1.5.4.tar.gz
#tar xfv v1.5.4.tar.gz
#cd libsrtp-1.5.4
#./configure --prefix=/usr --enable-openssl
#make shared_library && sudo make install
#cd -
#wget https://github.com/cisco/libsrtp/archive/v2.0.0.tar.gz
#tar xfv v2.0.0.tar.gz
#cd libsrtp-2.0.0
#./configure --prefix=/usr/libsrtp --enable-openssl
#或BUILD_LIBS=${HOME}/telecom/build_libs
#./configure --prefix=${BUILD_LIBS}
#make shared_library && sudo make install
----------------------------------------------------------------------------------------------------2
#安装 sofia-sip
cd -
#install sofia-sip for sip-gateway plugin
wget https://sourceforge.net/projects/sofia-sip/files/sofia-sip/1.12.11/sofia-sip-1.12.11.tar.gz
tar zxf sofia-sip-1.12.11.tar.gz && cd sofia-sip-1.12.11 && ./configure --prefix=/usr CFLAGS=-fno-aggressive-loop-optimizations && make && make install
-------------------------------------------------------------------------------------3
#安装 usrsctp
cd -
#install usrsctp for Data channel support
git clone https://github.com/sctplab/usrsctp && cd usrsctp && \
./bootstrap && \
./configure --prefix=/usr/usrsctp && make && make install
#去除usrsctp
#如果git clone报超时或者其他错误,试试看clone的地址前面加上 https://ghproxy.com/
#即执行git clone https://ghproxy.com/https://github.com/sctplab/usrsctp
---------------------------------------------------------------------------------------4
#安装 libwebsocket
cd -
#install libwebsocket for android or ios instead of http/https
git clone https://github.com/warmcat/libwebsockets && \
mkdir libwebsockets/build && cd libwebsockets/build && \
cmake -DMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" .. && \
make && make install
--------------------------------------------------------------------------------------5
#升级gcc版本到7,不然后面可能会报错,------可忽略
sudo yum install -y centos-release-scl
sudo yum install -y scl-utils-build
sudo yum install -y devtoolset-7-gcc*
sudo yum install -y devtoolset-7-gdb*
scl enable devtoolset-7 bash
gcc --version
----------------------------------------------------------------------------------6
#安装ice库
cd -
yum install meson
git clone https://gitee.com/mirrors/libnice
cd libnice
meson --prefix=/usr build && ninja -C build && sudo ninja -C build install
-------------------------------------------------------------------------------------7
cd -
#下面安装libmicrohttpd用于janus提供http服务,不装的话,janus配置文件里面会没有janus.transport.http.jcfg这个配置
#3.9.1
wget https://ftp.gnu.org/gnu/nettle/nettle-3.6.tar.gz
tar zxvf nettle-3.6.tar.gz
cd nettle-3.6
./configure --prefix=/usr \
--disable-static \
--enable-mini-gmp
make
make check #测试一下
make install
========================
# 3. gmp安装
libjnutls依赖
wget https://ftp.gnu.org/gnu/gmp/gmp-6.2.0.tar.xz
lzip -d gmp-6.1.2.tar.lz
tar xvf gmp-6.1.2.tar
cd gmp-6.1.2
./configure --prefix=/usr
make
make install
=======================
yum install -y gcc gcc-c++ make expat-devel
yum install -y automake libtool
yum install -y gettext-devel
yum install -y texinfo texlive tar gzip git perl gperf gawk bison libabigail
===============================
#GnuTLS是GNU项目开发的开源代码安全协议库
wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.9.tar.xz
wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.5/gnutls-3.5.9.tar.xz
tar xvf gnutls-3.5.9.tar.xz
cd gnutls-3.5.9
PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
./configure --with-included-libtasn1 --with-included-unistring --without-p11-kit
sudo make && sudo make install
#处理HTTP协议的C语言库
wget https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.71.tar.gz
tar zxf libmicrohttpd-0.9.71.tar.gz
cd libmicrohttpd-0.9.71/
./configure --with-ssl --enable-https=yes
make && sudo make install
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
-----------------------------------------------------------------------------------------8
#安装nginx
yum install nginx
#启动nginx
systemctl start nginx.service
#生成https证书,安装认证要填写一些信息,直接都回车就行了
mkdir /etc/nginx/ssl
openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /usr/local/nginx/ssl/www.zwmyy.cn.key -out /usr/local/nginx/ssl/www.zwmyy.cn.crt
openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /usr/local/nginx/ssl/nginx_janus.key -out /usr/local/nginx/ssl/nginx_janus.crt
-----------------------------------------------------------------------------------------9
#配置nginx
vi /etc/nginx/conf.d/default.conf
#然后重启nginx
#default.conf的内容为
server {
listen 80;
listen *:443 ssl;
server_name localhost;
location / {
root /opt/janus/share/janus/demos;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
ssl_certificate /etc/nginx/ssl/nginx.crt; #就是上面https证书的位置
ssl_certificate_key /etc/nginx/ssl/nginx.key;#就是上面https证书的位置
}
-----------------------------------------------------------------------------------------------------10
cd -
#Janus
#if cannot configure plugin sofia,Perhaps you should add the directory containing `sofia-sip-ua.pc' to the PKG_CONFIG_PATH environment variable,
#for example centos7 :export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig
#if cannot load libsofia-sip-ua.so.0 , try ldconfig -v
git clone https://github.com/meetecho/janus-gateway.git && \
cd janus-gateway &&\
sh autogen.sh && \
./configure --prefix=/opt/janus --disable-rabbitmq --disable-docs --enable-websockets --disable-plugin-lua &&\
make && make install && make configs
#然后执行下面两条指令 (这步应该是必须的)
ldconfig
export LD_LIBRARY_PATH=/usr/local/lib
------------------------------------------------------------问题???
nice:yum -y install ypserv rpcbind nice -n +19 top
Extension
1.若要使用libsrtp1.5.4,需要在configure janus 时加上 --disable-libsrtp2
2.如果需要支持mqtt可以安装paho.mqtt.c后重新configure janus编译安装
git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
make && sudo make install
其他插件可以参考janus-gateway
nohup /opt/janus/bin/janus >> /var/log/janus.log 2>&1 &
netstat -anp | grep janus
问题nice:
#yum install libnice-devel
#安装ice库
yum install meson
git clone https://gitee.com/mirrors/libnice
cd libnice
meson --prefix=/usr build && ninja -C build && sudo ninja -C build install
./configure --prefix=/opt/janus --disable-docs --enable-libsrtp2 --enable-websockets
yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-develfreetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-develglib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devele2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel opensslopenssl-devel openldap openldap-devel nss_ldap openldap-clientsopenldap-servers
---------------------------------------------------------------------------------------------------------------11
#修改janus里的配置
cd /opt/janus/etc/janus
#主要修改这几个配置文件
#janus.jcfg
#janus.transport.http.jcfg
#janus.transport.websockets.jcfg
#修改的内容为
#janus.jcfg
certificates: {
cert_pem = "/etc/nginx/ssl/nginx.crt"
cert_key = "/etc/nginx/ssl/nginx.key"
#cert_pwd = "secretpassphrase"
#ciphers = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256"
}
#janus.transport.http.jcfg
general: {
#events = true # Whether to notify event handlers about transport events (default=true)
json = "indented" # Whether the JSON messages should be indented (default),
base_path = "/janus" # Base path to bind to in the web server (plain HTTP only)
http = true # Whether to enable the plain HTTP interface
port = 8088 # Web server HTTP port
#interface = "eth0" # Whether we should bind this server to a specific interface only
#ip = "192.168.0.1" # Whether we should bind this server to a specific IP address (v4 or v6) only
https = true # Whether to enable HTTPS (default=false)
secure_port = 8089 # Web server HTTPS port, if enabled
#secure_interface = "eth0" # Whether we should bind this server to a specific interface only
#secure_ip = "192.168.0.1" # Whether we should bind this server to a specific IP address (v4 or v6) only
#acl = "127.,192.168.0." # Only allow requests coming from this comma separated list of addresses
#mhd_connection_limit = 1020 # Open connections limit in libmicrohttpd (default=1020)
#mhd_debug = false # Ask libmicrohttpd to write warning and error messages to stderr (default=false)
}
admin: {
admin_base_path = "/admin" # Base path to bind to in the admin/monitor web server (plain HTTP only)
admin_http = true # Whether to enable the plain HTTP interface
admin_port = 7088 # Admin/monitor web server HTTP port
#admin_interface = "eth0" # Whether we should bind this server to a specific interface only
#admin_ip = "192.168.0.1" # Whether we should bind this server to a specific IP address (v4 or v6) only
admin_https = true # Whether to enable HTTPS (default=false)
admin_secure_port = 7889 # Admin/monitor web server HTTPS port, if enabled
#admin_secure_interface = "eth0" # Whether we should bind this server to a specific interface only
#admin_secure_ip = "192.168.0.1" # Whether we should bind this server to a specific IP address (v4 or v6) only
#admin_acl = "127.,192.168.0." # Only allow requests coming from this comma separated list of addresses
}
certificates: {
cert_pem = "/etc/nginx/ssl/nginx.crt"
cert_key = "/etc/nginx/ssl/nginx.key"
#cert_pwd = "secretpassphrase"
#ciphers = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256"
}
#janus.transport.websockets.jcfg
general: {
#events = true # Whether to notify event handlers about transport events (default=true)
json = "indented" # Whether the JSON messages should be indented (default),
#pingpong_trigger = 30 # After how many seconds of idle, a PING should be sent
#pingpong_timeout = 10 # After how many seconds of not getting a PONG, a timeout should be detected
ws = true
ws_port = 8188 # WebSockets server port
#ws_interface = "eth0" # Whether we should bind this server to a specific interface only
#ws_ip = "192.168.0.1" # Whether we should bind this server to a specific IP address only
#ws_unix = "/run/ws.sock" # Use WebSocket server over UNIX socket instead of TCP
wss = true # Whether to enable secure WebSockets
wss_port = 8989 # WebSockets server secure port, if enabled
#wss_interface = "eth0" # Whether we should bind this server to a specific interface only
#wss_ip = "192.168.0.1" # Whether we should bind this server to a specific IP address only
#wss_unix = "/run/wss.sock" # Use WebSocket server over UNIX socket instead of TCP
#ws_logging = "err,warn" # libwebsockets debugging level as a comma separated list of things
#ws_acl = "127.,192.168.0." # Only allow requests coming from this comma separated list of addresses
}
admin: {
admin_ws = false # Whether to enable the Admin API WebSockets API
admin_ws_port = 7188 # Admin API WebSockets server port, if enabled
#admin_ws_interface = "eth0" # Whether we should bind this server to a specific interface only
#admin_ws_ip = "192.168.0.1" # Whether we should bind this server to a specific IP address only
#admin_ws_unix = "/run/aws.sock" # Use WebSocket server over UNIX socket instead of TCP
admin_wss = true # Whether to enable the Admin API secure WebSockets
admin_wss_port = 7989 # Admin API WebSockets server secure port, if enabled
#admin_wss_interface = "eth0" # Whether we should bind this server to a specific interface only
#admin_wss_ip = "192.168.0.1" # Whether we should bind this server to a specific IP address only
#admin_wss_unix = "/run/awss.sock" # Use WebSocket server over UNIX socket instead of TCP
#admin_ws_acl = "127.,192.168.0." # Only allow requests coming from this comma separated list of addresses
}
certificates: {
cert_pem = "/etc/nginx/ssl/nginx.crt"
cert_key = "/etc/nginx/ssl/nginx.key"
#cert_pwd = "secretpassphrase"
#ciphers = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256"
}
#修改前端页面的配置,把请求方式改成websocket的,如果是用原来https请求的话,要重新调整过nginx的配置,不然会阻塞超时,页面中会报net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)这个错
cd /opt/janus/share/janus/demos
vi setting.js
var server = "wss://" + window.location.hostname + ":8989/janus";
-------------------------------------------------------------------------------------------------------12
#针对上面https交互的问题,nginx配置需要做如下调整 增加 location /janus location /admin 和 location ~ \.() 三个配置
#然后重启nginx
server {
listen 80;
listen *:443 ssl;
server_name localhost;
location / {
root /opt/janus/share/janus/demos;
index index.html index.htm index.php;
}
location /janus {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://your_ip:8088/janus; #要正确填写你服务器的ip地址
}
location /admin {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://your_ip:7088/admin; #要正确填写你服务器的ip地址
}
location ~ \.(bmp|gif|jpg|png|css|js|cur|flv|ico|swf|doc|pdf|html)$ {
root /opt/janus/share/janus/demos;
expires 1d;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
}
#然后修改setting.js中server的值。
#var server = "/janus";
#这样就可以正常通过https交互访问了,如果页面还报一个502Bad Way的问题,同时nginx里面报了一个connect() to ip:8088 failed (13: Permission denied) while connecting to upstream的错,原因是SELinux限制了nginx对外访问的权限,执行下面操作
#查网络访问的配置
getsebool -a | grep httpd_can_network_connect
#如果出现如下结果
#httpd_can_network_connect --> off
#则执行如下命令取消限制:
#SELinux命令,临时配置,重启后失效
setsebool httpd_can_network_connect=1
#写入配置文件的命令,重启后保留,推荐这种方式
setsebool -P httpd_can_network_connect 1
------------------------------------------------------------------------------------------13
#最后到/opt/janus/bin 下启动janus,如果看到刚刚配置的几个端口成功启动了那就说明可以了,以上的配置可能并不是都要改,主要就是websocket配置那个wss = false改为true, 启用8989那个端口和http配置的https = false 改为true,启用8089端口 。同时涉及到certificates这个配置应该是一定要改的。
#页面访问 https://your_ip/index.html
./janus
---------------------------------------------------------------------------------------------------
1.检查软件包是否存在
在使用yum删除软件包之前,首先要检查软件包是否已经被安装。你可以使用以下命令来检查:
yum list installed | grep packagename
其中“packagename”为你要查询的软件包名称。如果输出结果中包含了你要删除的软件包名称,则表明该软件包已被安装。
2.删除软件包
一旦确认软件包已经被安装,你可以按照以下命令使用yum卸载软件包:
yum remove packagename
其中“packagename”为你要卸载的软件包名称。这个命令将删除该软件包及其相关的依赖关系。
3.卸载依赖包
有时候,yum在删除软件包时可能会遗留下一些依赖包。这可能会导致系统出现问题,例如软件包无法正常安装或启动。
要解决这个问题,你可以使用以下命令来卸载所有依赖包:
yum autoremove
这个命令将自动卸载所有不再使用的依赖包。
4.强制卸载软件包
有时候,你需要强制卸载软件包。这可能是因为软件包损坏或文件已经丢失,你需要重新安装的原因。
使用以下命令可以强制卸载软件包:
yum remove packagename –nodeps
其中“packagename”为你要删除的软件包名称,“–nodeps”参数告诉yum不要删除依赖包。
注意:强制卸载软件包可能会导致系统的不稳定,因此请谨慎使用。
5.常见问题解决
以下是常见的yum卸载软件包问题及其解决方法:
问题1:删除软件包后,相关的进程仍在运行。
解决方法:使用以下命令查找和停止相关的进程:
ps aux | grep packagename kill -9 PID
其中“packagename”为你删除的软件包名称,“PID”为与软件包相关的进程ID。
问题2:卸载软件包后,该软件包仍然出现在yum搜索结果中。
解决方法:使用以下命令清除yum缓存:
yum clean all