常用开发 服务搭建
java 1.8 jdk 安装
# tar zxvf jdk-8u271-linux-x64.tar.gz -C /usr/local
# ln -s /usr/local/jdk1.8.0_271 /usr/local/java
# vim /etc/profile
export JAVA_HOME=/usr/local/java
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:/usr/local/nginx/sbin:/usr/local/mysql/bin:$PATH
# source /etc/profile
# java -version \\ java version "1.8.0_271"
注:
jdk下载地址 https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html#license-lightbox
k051535@work Teo@1234
mvn 安装 需java环境 maven 3.6.3 下载地址 https://mirrors.cnnic.cn/apache/maven/
# wget https://mirrors.cnnic.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz --no-check-certificate
# tar zxf apache-maven-3.6.3-bin.tar.gz
# mv apache-maven-3.6.3 /usr/local/maven
# ln -s /usr/local/maven/bin/mvn /usr/bin/mvn
# echo " ">>/etc/profile
# echo "# Made for mvn env by zhaoshuai on $(date +%F)">>/etc/profile
# echo 'export MAVEN_HOME=/usr/local/maven'>>/etc/profile
# echo 'export PATH=$MAVEN_HOME/bin:$PATH'>>/etc/profile
# tail -4 /etc/profile
# source /etc/profile
# echo $PATH
# which mvn
# mvn -version
yum安装 mysql 5.7安装 yum安装 https://dev.mysql.com/downloads/repo/yum/ 官网yum源 可以去下载
# rpm -qa | grep mariadb
# rpm -qa | grep mysql
# yum remove mariadb-libs.x86_64
# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
# yum install mysql57-community-release-el7-10.noarch.rpm
# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 // 如果安装报错 需要执行此命令 导入最新的key
# yum install mysql-community-server
# yum install mysql-devel
# vim /etc/my.cnf
max_connections=3600 // 设置最大连接数3600
wait_timeout=120 // 等待时间
interactive_timeout=300 // 超时时间
# systemctl restart mysqld
# ss -tnl
# grep "password" /var/log/mysqld.log // 最后的是初始密码
# mysql -uroot -p
set global validate_password_policy=LOW; // 安全等级低
set global validate_password_length=6; // 密码位数6
alter user user() identified by "123456"; // 设置当前登录用户的密码
grant all privileges on *.* to 'root'@'%' identified by '123456' // 所有权限
flush privileges;
show global variables like '%CONNECTIONS%'; // 查看最大连接数
show global variables like '%timeout%'; // 查看超时时
yum安装 mysql 5.6安装
# rpm -qa | grep mariadb
# rpm -qa | grep mysql
# yum remove mariadb-libs.x86_64
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
# vim /etc/my.cnf
max_connections=3600 // 设置最大连接数3600
wait_timeout=120 // 等待时间
interactive_timeout=300 // 超时时间
# systemctl restart mysqld
# grep "password" /var/log/mysqld.log // 最后的是初始密码 如果没有 使用下面的命令 设置密码
# mysql_secure_installation // 设置密码
# systemctl restart mysqld
# ss -tnl
初始化数据库
# mysql -uroot -p
set global validate_password_policy=LOW; // 安全等级低
set global validate_password_length=6; // 密码位数6
alter user user() identified by "123456"; // 设置当前登录用户的密码
grant all privileges on *.* to 'root'@'%' identified by '123456' // 所有权限
flush privileges;
show global variables like '%CONNECTIONS%'; // 查看最大连接数
show global variables like '%timeout%'; // 查看超时时
命令行导入数据库
# mysql -u root -p 123456 < tj_20220119_125627.sql
设置 root 用户 密码及远程登录权限
# mysql
> use mysql
> select user,host,password from user;
> delete from mysql.user where user=''; // 删除user为空用户
> update user set password=password("123456") where user="root"; // 修改密码 5.6及以下修改密码的命令
> grant all privileges on *.* to root@'%' identified by '123456'; // 远程 权限
> flush privileges;
创建数据库
# mysql
> create database ssyy99; // 创建数据库 不能有点 .
> grant all privileges on ssyy99.* to ssyy99@'%' identified by '123456'; // 创建用户 给所有权限
> source /data/aaa.sql // 导入数据库
grant all privileges on matomo.* to matomo@'%' identified by 'matomo';
重置 mysql 密码
# systemctl stop mysqld
# mysqld_safe --skip-grant-tables & // 无权限验证 启动
# mysql -u root
> FLUSH PRIVILEGES;
> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
> EXIT;
# systemctl stop mysqld
# systemctl start mysqld
# mysql -u root -p
老版本设置密码 使用的命令
> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
mysql 8.0安装 yum安装
# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
# yum install mysql80-community-release-el7-3.noarch.rpm
# yum install mysql-server
# yum install mysql-devel
# vim /etc/my.cnf
max_connections=3600 \\ 设置最大连接数3600
wait_timeout=120 \\ 等待时间
interactive_timeout=300 \\ 超时时间
# systemctl restart mysqld
# systemctl enable mysqld
# grep "password" /var/log/mysqld.log \\ 最后的是初始密码
# mysql -uroot -p
set global validate_password.policy=0;
set global validate_password.length=1;
CREATE USER 'root'@'%' IDENTIFIED BY '123456'; \\ 给所有用户权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; \\ 给所有用户权限
show global variables like '%CONNECTIONS%'; \\ 查看最大连接数
show global variables like '%timeout%'; \\ 查看超时时间
php5.6 安装 yum安装
# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# yum remove php-common \\ 移除系统自带的php-common
# yum install php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring
# php -v \\ 版本5.6
# yum provides php-fpm \\ 安装php-fpm,这里会提示多个安装源,选择5.6版本的安装就可以了
# yum install php56w-fpm
# systemctl restart php-fpm
<?php
phpinfo();
?>
php7.0安装
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# yum remove php-common
# yum install -y php70w-devel php70w-pear php70w-pecl php70w-gd php70w-opcache php70w-cli php70w-pdo php70w-process php70w-pecl-apcu php70w-mcrypt php70w-mysql php70w-fpm php70w-pecl-memcached php70w-common php70w-xml php70w-mbstring php70w-pecl-igbinary
# php -v
# systemctl restart php-fpm
nginx安装 yum安装
# cat > /etc/yum.repos.d/nginx1.repo <<-EOF
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF
# yum install nginx
# systemctl restart nginx
sentinel 安装
# wget https://github.com/alibaba/Sentinel/releases/download/1.6.2/sentinel-dashboard-1.6.2.jar
# mv sentinel-dashboard-1.6.2.jar /usr/local/sentinel-dashboard.jar
# cd /usr/local/
# java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar &
http://172.21.34.80:8849/#/dashboard/home
sentinel
sentinel
注:
下载地址 https://github.com/alibaba/Sentinel/releases/
node 14.15 安装
# wget https://cdn.npm.taobao.org/dist/node/v14.15.1/node-v14.15.1-linux-x64.tar.xz
# tar xvf node-v14.15.1-linux-x64.tar.xz -C /usr/local
# cd /usr/local
# mv node-v14.15.1-linux-x64/ node-14.15.1
# ln -s /usr/local/node-14.15.1/bin/npm /usr/local/bin/
# ln -s /usr/local/node-14.15.1/bin/node /usr/local/bin/
# node -v
注:
官网下载地址 http://nodejs.cn/download/
node 12 yum 安装
# curl -sL https://rpm.nodesource.com/setup_12.x | bash -
# yum install -y nodejs
# node --version
redis 3.2.12 yum安装
# yum install redis
# vim /etc/redis.conf
requirepass foobared \\ 修改密码
# systemctl restart redis
# systemctl enable redis
# redis-cli
auth foobared
MongoDB 安装
# vim /etc/yum.repos.d/mongodb-org-4.0.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
# yum install mongodb-org
# vim /etc/mongod.conf
bindIp: 0.0.0.0
# systemctl restart mongod
# systemctl enable mongod
# ss -tnl \\ 27017 被监听
注:
/var/lib/mongo 数据库位置
/var/log/mongodb 日志文件位置
python 3.6.5 安装
# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
# yum -y install epel-release
# yum install python-pip
# yum install wget
# wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
# xz -d Python-3.6.5.tar.xz
# tar -xf Python-3.6.5.tar
# cd /data/Python-3.6.5
# ./configure prefix=/usr/local/python3
# make && make install
# mv /usr/bin/python /usr/bin/python.bak
# ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
# python -V
# vim /usr/bin/yum
#!/usr/bin/python2 // 第一行修改
# vim /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python2 // 第一行修改
pip 安装
# curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py
# python get-pip.py
# pip --version
# vim ~/.bashrc
export PATH=$PATH:/usr/local/python3/bin
# source ~/.bashrc
# source ~/.bash_profile
# pip --version
node12 安装
# curl -sL https://rpm.nodesource.com/setup_12.x | bash -
# yum install -y nodejs
# node --version
zlib 安装
# wget http://www.zlib.net/zlib-1.2.11.tar.gz
# tar zxvf zlib-1.2.11.tar.gz -C /usr/local/
# cd /usr/local
# ls
# cd zlib-1.2.11/
# ./configure
# make
# make install
# cd /etc/ld.so.conf.d/
# vim zlib.conf
/usr/local/zlib-1.2.11 // zlib 路径
# ldconfig // dconfig 是一个动态链接库管理命令,默认搜寻/lilb和/usr/lib
// 以及配置文件/etc/ld.so.conf内所列的目录下的库文件 搜索出可共享的动态链接库
// 库文件的格式为:lib***.so.** 进而创建出动态装入程序(ld.so)所需的连接和缓存文件
// ldconfig通常在系统启动时运行 新安装了一个新的动态链接库时 就需要手工运行
xdebug 安装 // php插件
# wget http://xdebug.org/files/xdebug-2.7.0beta1.tgz // 需要精确版本对应不同的php版本 xdebug-2.7.0beta1
# tar xvzf xdebug-2.7.0beta1.tgz -C /usr/local/
# cd /usr/local/xdebug-2.7.0beta1
# phpize
# ./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config // 需指定php-config 的路径
# make
# make install // 会出现此目录 要记住 需写进配置文件中
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/
# vim /usr/local/php/etc/php.ini // 需在配置文件中添加
zend_extension = "/www/server/php/70/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.scream = 0
xdebug.cli_color = 1
xdebug.show_local_vars = 1
# php -m | grep xdebug // 有xdebug 为 安装成功
# vim aaa.php // 亦可创建phpinfo 文件 来查看 xdebug 版本
<?php phpinfo(); ?>
注: xdebug其他版本官网下载地址: https://xdebug.org/download/historical
xdebug 与 php 版本需要相匹配 检测网址: http://xdebug.org/wizard
composer 指定版本 安装 // php插件
# which composer // 可以删除以前的版本
# wget composer.phar // 下载 .phar 文件即可 地址在备注
# mv composer.phar /usr/local/bin/composer
# chmod +x /usr/local/bin/composer
# composer --version
注: composer github 下载地址: https://getcomposer.org/download/
chatwoot 安装
官网: https://www.chatwoot.com/docs/self-hosted/deployment/docker/
1. 安装最新版docker
# cd /data
# wget -O .env https://raw.githubusercontent.com/chatwoot/chatwoot/develop/.env.example
# wget -O docker-compose.yaml https://raw.githubusercontent.com/chatwoot/chatwoot/develop/docker-compose.production.yaml
# vim .env // 需要修改密码
POSTGRES_PASSWORD=123456
# vim docker-compose.yaml
POSTGRES_PASSWORD=123456
# docker compose run --rm rails bundle exec rails db:chatwoot_prepare
# docker ps // 有两个容器启动
# docker compose up -d
# docker ps // 有四个容器启动
# ss -tnl // 3000端口被监听
# curl -I localhost:3000/api
# docker compose down // 重启
# docker compose up -d // 重启
2. 配置 nginx 反向代理到 3000端口
nginx 反向代理配置
server {
server_name www.baiud.com;
# Point upstream to Chatwoot App Server
set $upstream 127.0.0.1:3000;
# Nginx strips out underscore in headers by default
# Chatwoot relies on underscore in headers for API
# Make sure that the config is set to on.
underscores_in_headers on;
location /.well-known {
alias /var/www/ssl-proof/chatwoot/.well-known;
}
location / {
proxy_pass_header Authorization;
proxy_pass http://$upstream;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection “”;
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;
}
listen 80;
}