2022年4月

1.安装需要的环境
yum install -y openssl-devel
yum install -y libevent2
yum install -y libevent-devel
yum install mysql-devel
yum install mysql-server

这里数据库使用mysql,也可以用其他数据库。
其中libevent2可能会安装失败,建议先下载下来然后传到服务器手动安装。

2.手动安装libevent2
官网地址:http://www.monkey.org/~provos/libevent/
1.下载最新的版本上传到/usr目录下并解压
wget https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz
tar zxvf libevent-2.1.11-stable.tar.gz
rm -rf libevent-2.1.11-stable.tar.gz

2.进入解压后的目录
cd libevent-2.1.11-stable

3.安装gcc
yum install gcc

4.设置安装路径
./configure -prefix=/usr

5.编译、安装
make && make install

3.安装coturn
1.在/usr目录下下载coturn

git clone https://github.com/coturn/coturn

若没有安装git,执行yum install git安装git

2.安装
cd coturn
./configure
make && make install

查看是否安装成功(若显示了安装路径则表示安装成功)
which turnserver

4.签名证书
cert和pkey配置的自签名证书用Openssl命令生成:
openssl req -x509 -newkey rsa:2048 -keyout /etc/turn_server_pkey.pem -out /etc/turn_server_cert.pem -days 99999 -nodes

执行命令后需要填写一些信息,随意填写即可

5.设置用户名和密码
使用命令生成密码turnadmin -k -u <用户名> -r north.gov -p <密码>,执行命令后屏幕会打印加密后的密码,请记住这个密码
turnadmin -k -u tuoling -r north.gov -p eee333
0xcf2f076caf51774d114e8ed8ac21fb38

6.在/etc目录下新建turnuserdb.conf文件,将用户名和上一步生成的密码填写进去然后保存退出。可以多生成几个用户名和密码
vi /etc/turnuserdb.conf
tuoling:0xcf2f076caf51774d114e8ed8ac21fb38

5.修改turnserver.conf配置文件
正确配置
vi /usr/local/etc/turnserver.conf
其中listening-ip与relay-ip采用内网ip,external-ip是外网的ip。

listening-ip=0.0.0.0
listening-port=3478
tls-listening-port=5349
relay-ip=103.196.127.20
external-ip=103.196.127.20
relay-threads=50
lt-cred-mech
cert=/etc/turn_server_cert.pem
pkey=/etc/turn_server_pkey.pem
pidfile=/var/run/turnserver.pid
min-port=49152
max-port=65535
userdb=/etc/turnuserdb.conf
user=love:123456
cli-password=888999

6.运行coturn
执行命令运行coturn服务
turnserver -v -r 103.196.127.20:3478 -a -o -c /usr/local/etc/turnserver.conf

关闭命令:
执行 cat /var/run/turnserver.pid
找到进程后:kill

在浏览器输入
<外网ip>:3478,显示

表示启动成功,如果访问不了可能是服务器防火墙没有开启3478端口

7.开启防火墙端口

tcp和udp都要打开

firewall-cmd --permanent --add-port=3478/tcp
firewall-cmd --permanent --add-port=3478/udp

刷新防火墙

firewall-cmd --reload

查看当前开放的端口

firewall-cmd --list-port

如果还是不能访问,请考虑云服务的安全组策略是否同样开启了3478的tcp和udp端口。
8.网站检测穿透效果
访问:https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
turn:103.196.127.20:3478
love
123456
点 Gather candidates 后,如果出现 rtp host、rtp srflx、rtp relay 3个不同IP则成功(分别对应本机内部、外部IP、服务器IP)

一、要求

1.centos或redhat7.0以上系统
2.内存2G以上

二、安装步骤

1.设置sqlserver安装镜像

curl https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo > /etc/yum.repos.d/mssql-server.repo

2.执行安装

yum install -y mssql-server

完毕之后运行 sudo /opt/mssql/bin/mssql-conf setup 做相关配置
输入2使用Developer(免费,无生产许可)版本,再输入 Yes 接受许可,选择语言,设置系统管理员密码

完毕之后即可启动完成,如果内存不够安装失败则重新命令

sudo /opt/mssql/bin/mssql-conf setup

3.下面查看我们安装的sql server版本

rpm -qa | grep mssql

4.查看安装的路径

find / -name mssql

5.设置开机启动

systemctl enable mssql-server

6.打开1433端口

firewall-cmd --zone=public --add-port=1433/tcp --permanent
firewall-cmd --reload

7.几个命令

systemctl start mssql-server
systemctl restart mssql-server
systemctl stop mssql-server
systemctl status mssql-server

具体配置路劲为/opt/mssql/bin/mssql-conf

CentOS 8上安装MS SQL server

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
#SQL Server 2017使用python2和OpenSSL 1.0,你需要在不解析依赖关系的情况下安装软件包:
sudo yum -y install python2 compat-openssl10
sudo alternatives --set python /usr/bin/python2
sudo yum download mssql-server
sudo rpm -Uvh --nodeps mssql-server*rpm

再运行 sudo /opt/mssql/bin/mssql-conf setup 跟上面一样

安装SQL Server命令行工具
使用unixODBC开发包安装mssql-tools:

curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
yum -y install mssql-tools unixODBC-devel
vim /etc/profile.d/mssqltools.sh

输入内容:

export PATH=$PATH:/opt/mssql-tools/bin/

然后 source一下

source /etc/profile.d/mssqltools.sh

---------------- 自动备份 -----------------

2、添加crontab定时任务

crontab -e

添加定时任务,每天6点0分执行

0 6 * * * /home/backup/backup_mssql.sh

3、查看crontab定时任务

crontab -l

完整脚本代码:

#!/bin/bash
#sql备份目录
folder=/home/backup/db
cd $folder
day=`date +%Y%m%d`
#rm -rf $day
#mkdir $day
#cd $day
#数据库服务器,一般为localhost
host=localhost
#用户名
user=sa
#密码
password='mypassword'
#要备份的数据库
db=ASPState

#数据要保留的天数
days=5

#由于crontab命令是没环境变量,所以sqlcmd命令,要用全路径,否则定时执行会执行失败
/opt/mssql-tools/bin/sqlcmd -H$host -U$user -P$password -Q "
BACKUP DATABASE "$db"
TO DISK = '/home/backup/db/"$db$day".bak'
WITH FORMAT;
GO"

#删除之前的备份
#cd ..
day=`date -d "$days days ago" +%Y%m%d`
rm -rf "/home/backup/db/"$db$day".bak"
echo "remove "$db$day".bak"

---------------------- 相关操作 ----------------------

less /var/log/messages    系统日志
cat /dev/null>/var/log/messages    清除日志

下载
cd /usr/local/src/
wget http://ftp.icm.edu.pl/pub/unix/graphics/GraphicsMagick/1.3/GraphicsMagick-1.3.21.tar.gz

解压
tar zxvf GraphicsMagick-1.3.21.tar.gz
rm -rf GraphicsMagick-1.3.21.tar.gz

安装
cd GraphicsMagick-1.3.21
./configure
make -j8
make install

测试
gm version

加入PHP:
yum install php71w-pear
yum install ImageMagick-devel
pecl install imagick

vi /etc/php.ini
加入行:extension=imagick.so

重启PHP:
service php-fpm stop
service php-fpm start

输出以下信息说明安装成功:
GraphicsMagick 1.3.21 2015-02-28 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2014 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.

Feature Support:
Native Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) yes
BZIP no
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG no
JPEG-2000 no
JPEG yes
Little CMS no
Loadable Modules no
OpenMP yes (201107)
PNG yes
TIFF yes
TRIO no
UMEM no
WebP no
WMF no
X11 no
XML no
ZLIB yes

Host type: x86_64-unknown-linux-gnu

Configured using the command:
./configure

Final Build Parameters:
CC = gcc -std=gnu99
CFLAGS = -fopenmp -g -O2 -Wall -pthread
CPPFLAGS = -I/usr/include/freetype2
CXX = g++
CXXFLAGS = -pthread
LDFLAGS = -L/usr/lib
LIBS = -ltiff -lfreetype -ljpeg -lpng15 -lz -lm -lgomp -lpthread

OK,至此,GraphicsMagick安装完成。

安装:
yum install -y denyhosts

官网安装:
wget https://nchc.dl.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz
[root@www ~]# tar zxvf DenyHosts-2.6.tar.gz
[root@www ~]# cd DenyHosts-2.6
[root@www DenyHosts-2.6]# python setup.py install
[root@www DenyHosts-2.6]# cd /usr/share/denyhosts/
[root@www denyhosts]# cp denyhosts.cfg-dist denyhosts.cfg //配置文件
[root@www denyhosts]# cp daemon-control-dist daemon-control //启动文件
[root@www denyhosts]# chown root daemon-control
[root@www denyhosts]# chmod 700 daemon-control

创建启动服务连接
ln -s /usr/share/denyhosts/daemon-control /etc/init.d/denyhosts

加入自启动
chkconfig denyhosts on

配置:
vi denyhosts.cfg

SECURE_LOG = /var/log/secure #ssh日志文件
PURGE_DENY = 50m #过多久后清除已阻止IP
HOSTS_DENY = /etc/hosts.deny #将阻止IP写入到hosts.deny
BLOCK_SERVICE = sshd #阻止服务名
PURGE_THRESHOLD = #定义了某一IP最多被解封多少次。某IP暴力破解SSH密码被阻止/解封达到了PURGE_THRESHOLD次,则会被永久禁止;
DENY_THRESHOLD_INVALID = 1 #允许无效用户登录失败的次数
DENY_THRESHOLD_VALID = 10 #允许普通用户登录失败的次数
DENY_THRESHOLD_ROOT = 5 #允许root登录失败的次数
WORK_DIR = /usr/local/share/denyhosts/data #将deny的host或ip纪录到Work_dir中
DENY_THRESHOLD_RESTRICTED = 1 #设定 deny host 写入到该资料夹
LOCK_FILE = /var/lock/subsys/denyhosts #将DenyHOts启动的pid纪录到LOCK_FILE中,已确保服务正确启动,防止同时启动多个服务。
HOSTNAME_LOOKUP=NO #是否做域名反解
ADMIN_EMAIL = #设置管理员邮件地址
DAEMON_LOG = /var/log/denyhosts #DenyHosts日志位置

黑名单白名单:
vi /etc/hosts.deny
vi /etc/hosts.allow

hosts.allow(hosts.deny同规则)
sshd:...

启动命令(yum安装,已默认配好)
service denyhosts start / /etc/init.d/denyhosts start
service denyhosts stop
service denyhosts status

yum install -y wget
yum install -y net-tools
yum install -y gcc
yum install -y zlib zlib-devel

查看防火墙状态
firewall-cmd --state

停止firewall
systemctl stop firewalld.service

禁止firewall开机启动
systemctl disable firewalld.service

JAVA SDK(http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html):
wget https://download.oracle.com/otn/java/jdk/8u221-b11/230deb18db3e4014bb8e3e8324f81b43/jdk-8u221-linux-x64.tar.gz?AuthParam=1566151122_466245ecc69749dd492cf588c934cd04
tar zxf jdk-8u221-linux-x64.tar.gz?AuthParam=1566151122_466245ecc69749dd492cf588c934cd04 -C /usr/local/java/
rm -rf jdk-8u221-linux-x64.tar.gz?AuthParam=1566151122_466245ecc69749dd492cf588c934cd04
vi /etc/profile,增加到尾部:
export JAVA_HOME=/usr/local/java/jdk1.8.0_221
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

source /etc/profile
ln -s /usr/local/java/jdk1.8.0_221/bin/java /usr/bin/java
检查:java -version

Tomcat9:
cd /usr
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.22/bin/apache-tomcat-9.0.22.tar.gz
tar zxf apache-tomcat-9.0.22.tar.gz
mv apache-tomcat-9.0.22 tomcat9
rm -rf apache-tomcat-9.0.22.tar.gz
sh tomcat9/bin/startup.sh

Maven:
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
tar -zxf apache-maven-3.6.1-bin.tar.gz
rm -rf apache-maven-3.6.1-bin.tar.gz
mv apache-maven-3.6.1 maven3.6
vi /etc/profile,增加到尾部:
export MAVEN_HOME=/usr/maven3.6
export PATH=${MAVEN_HOME}/bin:$PATH

source /etc/profile
检查:mvn -v