Browse Source

update

master
许孟阳 3 years ago
parent
commit
edcda14c35
  1. 0
      1.java/1.Spring boot基础.md
  2. 0
      1.java/1.Spring boot整合mongodb.md
  3. 0
      1.java/9.用jdk生成ssl证书.md
  4. 0
      1.java/mongo1.png
  5. 0
      1.java/mongo2.png
  6. 6
      11随记.md
  7. 0
      2.B端/CSS笔记.md
  8. 0
      2.B端/element-ui笔记.md
  9. 0
      2.B端/安装与配置.md
  10. 0
      2.B端/文字颜色自适应背景色.md
  11. 0
      3.C端/android studio.md
  12. 261
      3.linux/3.nginx安装与配置.md
  13. 41
      3.linux/4.redis安装与配置.md
  14. 317
      3.linux/5.docker.md
  15. 70
      3.linux/9.gitlab安装.md
  16. 0
      4.linux知识/1.常用命令整理.md
  17. 0
      4.linux知识/2.看门狗脚本.md
  18. 210
      5.linux环境/1.docker.md
  19. 100
      5.linux环境/2.mysql.md
  20. 342
      5.linux环境/3.nginx.md
  21. 69
      5.linux环境/4.redis.md
  22. 131
      5.linux环境/5.gitlab.md
  23. 49
      5.linux环境/6.gitea.md
  24. 71
      5.linux环境/7.Marsterlab.md
  25. 33
      5.linux环境/8.禅道.md
  26. 6
      99.随记/1.随记.md

0
1.后端/1.Spring boot基础.md → 1.java/1.Spring boot基础.md

0
1.后端/1.Spring boot整合mongodb.md → 1.java/1.Spring boot整合mongodb.md

0
1.后端/9.用jdk生成ssl证书.md → 1.java/9.用jdk生成ssl证书.md

0
1.后端/mongo1.png → 1.java/mongo1.png

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

0
1.后端/mongo2.png → 1.java/mongo2.png

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

6
11随记.md

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
# 随记
- 抛开产品线只讨论品牌的人,我不说你们是傻子或者水军,但是明显你们不关心产品,只是在发泄情绪或者炫耀智商。
- 心理学上说你更容易喜欢上喜欢你的人

0
2.前端/CSS笔记.md → 2.B端/CSS笔记.md

0
2.前端/element-ui笔记.md → 2.B端/element-ui笔记.md

0
2.前端/安装与配置.md → 2.B端/安装与配置.md

0
2.前端/文字颜色自适应背景色.md → 2.B端/文字颜色自适应背景色.md

0
4.客户端/android studio.md → 3.C端/android studio.md

261
3.linux/3.nginx安装与配置.md

@ -1,261 +0,0 @@ @@ -1,261 +0,0 @@
# nginx安装与配置
## 准备环境
```shell
yum -y install gcc
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
```
## 下载
nginx官方下载指定版本源码压缩包
上传到服务器解压
## 编译与安装
```shell
./configure --prefix=指定安装目录前缀 --with指定额外的模块
make
make install DESTDIR=指定安装目录后缀
```
## http反向代理配置
* 根据路径分发到不同端口参数配置示例
```
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name localhost;
location / {
root proxy_pass http://127.0.0.1:8080;
index index.html index.htm;
}
location /fence {
root proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
location /RfsSniffer {
root proxy_pass http://127.0.0.1:8433;
index index.html index.htm;
}
}
}
```
- 根据域名分发到不同端口参数配置示例
```
http {
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name location.xumy.vip;
location / {
proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
}
}
```
## tcp转发
转发https请求,无需在nginx配置ssl证书,nginx版本号必须 >1.15.2,编译时必须配置以下模块
`--with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module`
- 同一个端口监听http与https请求配置示例,$ssl_preread_protocol,可以让stream区分web ssl/tls和其他协议
```
stream {
upstream http{
server 127.0.0.1:8081;
}
upstream https{
server 127.0.0.1:8433;
}
map $ssl_preread_protocol $upstream{
default http;
"TLSv1.3" https;
"TLSv1.2" https;
"TLSv1.1" https;
"TLSv1.0" https;
"TLSv1" https;
"TLSv2" https;
"SSLv2" https;
"SSLv3" https;
}
server {
listen 0.0.0.0:28181;
ssl_preread on;
proxy_pass $upstream;
}
}
```
- http与stream混合使用
```
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name location.xumy.vip;
location / {
proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
}
server {
listen 80;
server_name monitor.xumy.vip;
location / {
proxy_pass http://127.0.0.1:8082;
index index.html index.htm;
}
}
server {
listen 80;
server_name whims.xumy.vip;
location / {
proxy_pass http://127.0.0.1:801;
index index.html index.htm;
}
}
server {
listen 80;
server_name license.xumy.vip;
location / {
proxy_pass http://127.0.0.1:88;
index index.html index.htm;
}
}
server {
listen 80;
server_name robust.xumy.vip;
location / {
proxy_pass http://127.0.0.1:89;
index index.html index.htm;
}
}
server {
listen 80;
server_name dzwl.xumy.vip;
location / {
proxy_pass http://127.0.0.1:805;
index index.html index.htm;
}
}
}
stream{
log_format proxy '$remote_addr - [$time_local] $protocol $status "$upstream_addr" $remote_addr $remote_port ';
access_log /home/work/logs/nginx/tcp-access.log proxy;
open_log_file_cache off;
map_hash_bucket_size 64;
map $ssl_preread_protocol $upstream{
default http;
"TLSv1.3" $https;
"TLSv1.2" $https;
"TLSv1.1" $https;
"TLSv1.0" $https;
"TLSv1" $https;
"TLSv2" $https;
"SSLv2" $https;
"SSLv3" $https;
}
map $ssl_preread_server_name $https{
default dzwl;
}
upstream http {
server 127.0.0.1:80;
}
upstream dzwl {
server 127.0.0.1:806;
}
server{
listen 8080;
ssl_preread on;
proxy_pass $upstream;
proxy_connect_timeout 15s;
proxy_timeout 15s;
proxy_next_upstream_timeout 15s;
}
}
```

41
3.linux/4.redis安装与配置.md

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
# redis安装与配置
## linux
- 下载:[官方源码](http://redis.io/download)
`wget http://download.redis.io/releases/redis-6.0.8.tar.gz`
- 安装
```shell
tar xzf redis-6.0.8.tar.gz
cd redis-6.0.8
make
```
- 配置
默认配置文件为解压目录下redis.conf
| 配置项 | 作用 | 默认 |
| -------------- | --------------------- | --------- |
| daemonize | 是否后台运行redis服务 | no |
| requirepass | redis认证密码 | 无 |
| protected-mode | 是否开启远程保护 | yes |
| bind | 绑定访问地址 | 127.0.0.1 |
- 启动
在src目录下的redis-server和redis-cli两个可执行文件,直接执行就可以启动redis服务或客户端
建议将这两个文件拷贝到/sbin目录下,并将nginx.conf拷贝到/etc目录下
方便在任意目录执行`redis-server /etc/redis.conf`启动服务
- 链接
`redis-cli` 链接
`auth $password` 进行密码验证

317
3.linux/5.docker.md

@ -1,317 +0,0 @@ @@ -1,317 +0,0 @@
# docker的安装与使用
## 安装(centos)
- 卸载旧版本
```shell
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
```
- 安装依赖
```shell
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
```
- 设置仓库(非必须)
官方源地址(比较慢)
```shell
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
```
阿里云
```shell
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
```
清华大学源
```shell
yum-config-manager \
--add-repo \
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
```
- 安装**docker**
安装最新版本
```shell
yum install docker-ce docker-ce-cli containerd.io
```
安装指定版本
```shell
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
```
启动**docker**
```shell
systemctl start docker
```
设置开机启动
```shell
systemctl enable docker
```
停止**docker**
```
systemctl stop docker
```
- 卸载**docker**
删除安装包
```shell
yum remove docker-ce
```
删除镜像、容器、配置文件等内容,默认路径为:/var/lib/docker,自定义路径为:/etc/docker/daemon.json中data-root属性
## 使用
- 镜像
获取最新版本镜像
```shell
docker pull <镜像名称>
docker pull <镜像名称>:latest
```
获取指定版本
```shell
docker pull <镜像名称>:<版本号>
```
删除镜像
```shell
docker rmi <镜像ID>
```
- 创建与启动容器
创建新容器并启动
```shell
docker run -itd --<容器名> <镜像名> <容器内执行的命令>
```
参数说明
```tex
-i: 以交互模式运行容器,通常与 -t 同时使用;
-t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;
-d: 后台运行容器,并返回容器ID;
-p: 指定端口映射,格式为:主机(宿主)端口:容器端口
-v: 挂载宿主机的一个目录到容器,格式为:主机(宿主)目录:容器目录;
-e: username="ritchie": 设置环境变量;
-m: :设置容器使用内存最大值;
--privileged 容器内root用户是否真正拥有root权限
--restart :容器退出是重启策略
no默认值,表示容器退出时,docker不自动重启容器
on-failure 若容器的退出状态非0,则docker自动重启容器,还可以指定重启次数,若超过指定次数未能启动容器则放弃
always 容器退出时总是重启
unless-stopped 容器退出时总是重启,但不考虑Docker守护进程启动时就已经停止的容器
如果容器启动时没有设置–restart参数,则通过下面命令进行更新:
docker update --restart=always <容器ID>
```
停止容器
```shell
docker stop <容器ID>
```
启动容器
```shell
docker start <容器ID>
```
- 进入退出
查看所有容器
```shell
docker ps -a
```
进入容器,**attach**或**exec**(推荐使用,退出容器终端容器不会停止)
```shell
docker exec -it <容器ID> /bin/bash
```
进入容器后输入**exit** 退出容器
- 删除与导入导出
删除容器
```shell
docker rm -f <容器ID>
```
导出容器
```shell
docker export <容器ID> > <文件名>
```
导入容器
```shell
cat <文件名> | docker import - <镜像名>
```
## Docker安装其他软件
- 安装**mysql**
```shell
docker pull mysql:5.7.27
docker run -itd --name mysql-server -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7.27
```
- 安装**nginx**
```shell
docker pull nginx
docker run -d --name nginx -p 80:80 -v /home/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/nginx/logs:/var/log/nginx -v /home/nginx/data:/home nginx
```
- 安装**gitea**
```shell
docker pull gitea/gitea
docker run -d --name gitea --privileged --restart=always -p 122:22 -p 3000:3000 -v /home/gitea/data:/data gitea/gitea
```
- 安装**gitlab**
```shell
docker search gitlab
docker pull twang2218/gitlab-ce-zh
docker run -d -p 443:443 -p 280:80 -p 222:22 --name gitlab --privileged --restart always -v /home/gitlab/config:/etc/gitlab -v /home/gitlab/logs:/var/log/gitlab -v /home/gitlab/data:/var/opt/gitlab twang2218/gitlab-ce-zh
```
修改gitlab.rb配置文件
```tex
external_url "http://gitlab.xumy.vip:28080"
nginx['proxy_set_headers'] = { "Host" => "gitlab.xumy.vip:28080" }
```
- 安装禅道
拉取镜像
```shell
docker pull easysoft/zentao:15.7.1
```
创建网络驱动
```shell
docker network create --subnet=172.172.172.0/24 zentaonet
```
启动容器
```tex
sudo docker run --name [容器名] -p [主机端口]:80 --network=[网络驱动名] --ip [容器IP] --mac-address [mac地址] -v [主机禅道目录]:/www/zentaopms -v [主机mysql目录]:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=[数据库密码] -d easysoft/zentao:[镜像标签]
其中,容器名:启动的容器名字,可随意指定;
主机端口:主机端口为web访问端口;
网络驱动名:刚刚创建的网络驱动名;
容器IP:在网络驱动范围内选择一个作为该容器的固定ip;
mac地址:指定固定的mac地址,建议范围为02:42:ac:11:00:00 到 02:42:ac:11:ff:ff;
主机禅道目录:必须指定,方便禅道代码、附件等数据的持久化,非升级情况需指定空目录;
主机mysql目录:必须指定,方便禅道数据持久化,非升级情况需指定空目录;
数据库密码: 容器内置mysql用户名为root,默认密码123456,如果不修改可以不指定该变量,如果想更改密码可以设置 MYSQL_ROOT_PASSWORD变量来更改密码;
```
```shell
docker run --name zentao -p 8080:80 --network=zentaonet --ip 172.172.172.2 --mac-address 02:42:ac:11:00:ff -v /home/zentao/pms:/www/zentaopms -v /home/zentao/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d easysoft/zentao:15.7.1
```
- 安装**redis**
```shell
docker pull redis:latest
docker run -d --name redis -p 6379:6379 redis:latest
```
- 安装**masterlab**
```shell
cd /home
git clone https://gitee.com/firego/masterlab-docker.git
cd ./masterlab-docker/www
git clone https://gitee.com/firego/masterlab.git
cd ./masterlab
unzip ./vendor.zip
docker run -d --name php74 --expose=9000 -p 9000:9000 --link mysql-server:mysql --link redis:redis \
-v /home/masterlab-docker/www/:/var/www/html/ \
-v /home/masterlab-docker/conf/php/php74.ini:/usr/local/etc/php/php.ini \
-v /home/masterlab-docker/conf/php/php-fpm.d/www74.conf:/usr/local/etc/php-fpm.d/www.conf \
-v /home/masterlab-docker/log/php-fpm/:/var/log/php-fpm/ \
gopeak/masterlab:php-fpm-74
docker run -d --name nginx-alpine -p 80:80 -p 443:443 --link php74:fpm74 \
-v /home/masterlab-docker/www/:/var/www/html/ \
-v /home/masterlab-docker/conf/nginx/conf.d:/etc/nginx/conf.d/ \
-v /home/masterlab-docker/conf/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /home/masterlab-docker/log/nginx/:/var/log/nginx/ \
-e "TZ=Asia/Shanghai" \
nginx:alpine
docker run -d -it --rm --name php74-cli \
-p 9002:9002 \
-v /home/masterlab-docker/www/masterlab:/usr/workspaces/project \
-w /usr/workspaces/project \
gopeak/masterlab:php-cli-74 \
php ./bin/swoole_server.php
```

70
3.linux/9.gitlab安装.md

@ -1,70 +0,0 @@ @@ -1,70 +0,0 @@
# gitlab安装
## 下载
[下载地址](https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/)
## 安装依赖
```shell
yum install curl policycoreutils openssh-server openssh-clients policycoreutils-python
systemctl enable sshd
systemctl start sshd
```
```shell
yum install postfix
systemctl enable postfix
systemctl start postfix
```
## 配置文件
* 默认位置:/etc/gitlab/gitlab.rb
* 内容
external_url 访问地址
git_data_dir 数据保存位置
## 汉化
* 打补丁方式
```shell
wget https://gitlab.com/xhang/gitlab
git diff v12.0.3 v12.0.3-zh > ../12.0.3-zh.diff
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < ../12.0.3-zh.diff
```
* 直接覆盖方式
```shell
wget https://gitlab.com/xhang/gitlab/repository/12-0-stable-zh/archive.tar.bz2 -O gitlab-12-0-stable-zh.tar.bz2
\cp -rf gitlab-v12.0.0/* /opt/gitlab/embedded/service/gitlab-rails/
```
# 卸载
* 清理命令
```shell
wget https://gitlab.com/xhang/gitlab/repository/12-0-stable-zh/archive.tar.bz2 -O gitlab-12-0-stable-zh.tar.bz2
\cp -rf gitlab-v12.0.0/* /opt/gitlab/embedded/service/gitlab-rails/
```
+ 停止gitlab
`gitlab-ctl stop`
* 卸载gitlab
`rpm -e gitlab-ce`
- 查看进程
`ps aux | grep gitlab`
- 杀掉守护进程
`kill -9 xxx`
- 清理残余文件
`find / -name gitlab | xargs rm -rf`

0
3.linux/1.常用命令整理.md → 4.linux知识/1.常用命令整理.md

0
3.linux/2.看门狗脚本.md → 4.linux知识/2.看门狗脚本.md

210
5.linux环境/1.docker.md

@ -0,0 +1,210 @@ @@ -0,0 +1,210 @@
# 安装(centos)
- 卸载旧版本
```shell
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
```
- 安装依赖
```shell
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
```
- 设置仓库(非必须)
官方源地址(比较慢)
```shell
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
```
阿里云
```shell
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
```
清华大学源
```shell
yum-config-manager \
--add-repo \
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
```
- 安装**docker**
安装最新版本
```shell
yum install docker-ce docker-ce-cli containerd.io
```
安装指定版本
```shell
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
```
启动**docker**
```shell
systemctl start docker
```
设置开机启动
```shell
systemctl enable docker
```
停止**docker**
```
systemctl stop docker
```
- 卸载**docker**
删除安装包
```shell
yum remove docker-ce
```
删除镜像、容器、配置文件等内容,默认路径为:/var/lib/docker,自定义路径为:/etc/docker/daemon.json中data-root属性
# 使用
- 镜像
获取最新版本镜像
```shell
docker pull <镜像名称>
docker pull <镜像名称>:latest
```
获取指定版本
```shell
docker pull <镜像名称>:<版本号>
```
删除镜像
```shell
docker rmi <镜像ID>
```
- 创建与启动容器
创建新容器并启动
```shell
docker run -itd --<容器名> <镜像名> <容器内执行的命令>
```
参数说明
```tex
-i: 以交互模式运行容器,通常与 -t 同时使用;
-t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;
-d: 后台运行容器,并返回容器ID;
-p: 指定端口映射,格式为:主机(宿主)端口:容器端口
-v: 挂载宿主机的一个目录到容器,格式为:主机(宿主)目录:容器目录;
-e: username="ritchie": 设置环境变量;
-m: :设置容器使用内存最大值;
--privileged 容器内root用户是否真正拥有root权限
--restart :容器退出是重启策略
no默认值,表示容器退出时,docker不自动重启容器
on-failure 若容器的退出状态非0,则docker自动重启容器,还可以指定重启次数,若超过指定次数未能启动容器则放弃
always 容器退出时总是重启
unless-stopped 容器退出时总是重启,但不考虑Docker守护进程启动时就已经停止的容器
如果容器启动时没有设置–restart参数,则通过下面命令进行更新:
docker update --restart=always <容器ID>
```
停止容器
```shell
docker stop <容器ID>
```
启动容器
```shell
docker start <容器ID>
```
- 进入退出
查看所有容器
```shell
docker ps -a
```
进入容器,**attach**或**exec**(推荐使用,退出容器终端容器不会停止)
```shell
docker exec -it <容器ID> /bin/bash
```
进入容器后输入**exit** 退出容器
- 删除与导入导出
删除容器
```shell
docker rm -f <容器ID>
```
导出容器
```shell
docker export <容器ID> > <文件名>
```
导入容器
```shell
cat <文件名> | docker import - <镜像名>
```

100
5.linux环境/2.mysql.md

@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
# 安装卸载
## 使用安装包
- 下载
[官方下载地址](https://dev.mysql.com/downloads/repo/yum/)
```
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
```
- 安装
```shell
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
```
- 设置数据目录权限
```shell
chown -R mysql:mysql /var/lib/mysql
```
- 初始化
```shell
mysqld --initialize
```
- 启动与停止
```
systemctl start mysqld //启动
systemctl status mysqld //查看运行状态
systemctl stop mysqld //停止
systemctl restart mysqld //重启
```
- 查看版本
```shell
mysqladmin --version
```
- 卸载
```shell
rpm -e mysql  // 普通删除模式
rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
```
## 使用docker
- 安装**docker**
- 下载镜像
```shell
docker pull mysql:5.7.27
```
- 创建并运行容器
```shell
docker run -itd --name mysql-server -p 3306:3306 -v /home/mysql/data:/var/lib/mysql -v /home/mysql/conf:/etc/mysql -v /home/mysql/log:/var/log/mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7.27
```
- 启动与停止容器
- 卸载
删除容器和镜像
```shell
docker rm -f mysql-server
docker rm mysql:5.7.27
```
删除数据
```shell
rm -rf /home/mysql
```
# 配置
## 配置文件
- 位置
目录为`/etc/mysql`,默认使用`my.cnf`文件配置,`conf.d`目录下所有`.cnf`文件中配置项可覆盖默认配置

342
5.linux环境/3.nginx.md

@ -0,0 +1,342 @@ @@ -0,0 +1,342 @@
# 安装卸载
## 使用源码
- 准备环境
```shell
yum -y install gcc
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
```
- 下载
[官方下载页面](http://nginx.org/en/download.html)
```shell
wget http://nginx.org/download/nginx-1.16.1.tar.gz
```
下载后需解压解压
- 编译与安装
```shell
./configure --prefix=指定安装目录前缀 --with指定额外的模块
make
make install DESTDIR=指定安装目录后缀
```
将安装目录的`bin`目录下可执行文件`nginx`拷贝到`/sbin`目录下,这样可以在任意目录下执行`nginx`命令
- 运行与停止
```shell
ningx
nginx -s stop
nginx -s reload
```
- 卸载
删除安装目录,删除`/sbin/nginx`文件
## 使用docker
- 安装**docker**
- 下载镜像
```shell
docker pull nginx
```
- 创建挂载目录
```
mkdir /home/ningx
cd /home/ningx/
mkdir data log
touch nginx/conf
```
- 创建并运行容器
```shell
docker run -d --name nginx --restart=always -p 80:80 -v /home/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/nginx/logs:/var/log/nginx -v /home/nginx/data:/home nginx
```
容器配置文件位置:`/etc/nginx/nginx.conf`
容器日志目录:`/var/log/nginx`
容器数据目录:`/home`
- 运行与重启
```shell
docker start nginx
docker stop nginx
docker restart nginx
```
- 卸载
删除容器与镜像
```shell
docker rm -f nginx
docker rm nginx
```
删除数据
```shell
rm -rf /home/nginx
```
# 配置
## http反向代理配置
* 根据路径分发到不同端口参数配置示例
```tex
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name localhost;
location / {
root proxy_pass http://127.0.0.1:8080;
index index.html index.htm;
}
location /fence {
root proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
location /RfsSniffer {
root proxy_pass http://127.0.0.1:8433;
index index.html index.htm;
}
}
}
```
- 根据域名分发到不同端口参数配置示例
```tex
http {
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name location.xumy.vip;
location / {
proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
}
}
```
## tcp转发
转发https请求,无需在nginx配置ssl证书,nginx版本号必须 >1.15.2,编译时必须配置以下模块
`--with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module`
- 同一个端口监听http与https请求配置示例,$ssl_preread_protocol,可以让stream区分web ssl/tls和其他协议
```tex
stream {
upstream http{
server 127.0.0.1:8081;
}
upstream https{
server 127.0.0.1:8433;
}
map $ssl_preread_protocol $upstream{
default http;
"TLSv1.3" https;
"TLSv1.2" https;
"TLSv1.1" https;
"TLSv1.0" https;
"TLSv1" https;
"TLSv2" https;
"SSLv2" https;
"SSLv3" https;
}
server {
listen 0.0.0.0:28181;
ssl_preread on;
proxy_pass $upstream;
}
}
```
- http与stream混合使用
```tex
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name location.xumy.vip;
location / {
proxy_pass http://127.0.0.1:8081;
index index.html index.htm;
}
}
server {
listen 80;
server_name monitor.xumy.vip;
location / {
proxy_pass http://127.0.0.1:8082;
index index.html index.htm;
}
}
server {
listen 80;
server_name whims.xumy.vip;
location / {
proxy_pass http://127.0.0.1:801;
index index.html index.htm;
}
}
server {
listen 80;
server_name license.xumy.vip;
location / {
proxy_pass http://127.0.0.1:88;
index index.html index.htm;
}
}
server {
listen 80;
server_name robust.xumy.vip;
location / {
proxy_pass http://127.0.0.1:89;
index index.html index.htm;
}
}
server {
listen 80;
server_name dzwl.xumy.vip;
location / {
proxy_pass http://127.0.0.1:805;
index index.html index.htm;
}
}
}
stream{
log_format proxy '$remote_addr - [$time_local] $protocol $status "$upstream_addr" $remote_addr $remote_port ';
access_log /home/work/logs/nginx/tcp-access.log proxy;
open_log_file_cache off;
map_hash_bucket_size 64;
map $ssl_preread_protocol $upstream{
default http;
"TLSv1.3" $https;
"TLSv1.2" $https;
"TLSv1.1" $https;
"TLSv1.0" $https;
"TLSv1" $https;
"TLSv2" $https;
"SSLv2" $https;
"SSLv3" $https;
}
map $ssl_preread_server_name $https{
default dzwl;
}
upstream http {
server 127.0.0.1:80;
}
upstream dzwl {
server 127.0.0.1:806;
}
server{
listen 8080;
ssl_preread on;
proxy_pass $upstream;
proxy_connect_timeout 15s;
proxy_timeout 15s;
proxy_next_upstream_timeout 15s;
}
}

69
5.linux环境/4.redis.md

@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
# 安装卸载
## 使用源码
- 下载
[官方源码](http://redis.io/download)
```shell
wget http://download.redis.io/releases/redis-6.0.8.tar.gz
```
下载后需解压
- 安装
```shell
tar xzf redis-6.0.8.tar.gz
cd redis-6.0.8
make
```
- 配置
默认配置文件为解压目录下`redis.conf`
| 配置项 | 作用 | 默认 |
| -------------- | --------------------- | --------- |
| daemonize | 是否后台运行redis服务 | no |
| requirepass | redis认证密码 | 无 |
| protected-mode | 是否开启远程保护 | yes |
| bind | 绑定访问地址 | 127.0.0.1 |
- 启动
在`src`目录下的r`edis-server`和`redis-cli`两个可执行文件,直接执行就可以启动`redis`服务或客户端
建议将这两个文件拷贝到`/sbin`目录下,并将`nginx.conf`拷贝到/etc目录下
方便在任意目录执行`redis-server /etc/redis.conf`启动服务
- 链接
`redis-cli` 链接
`auth $password` 进行密码验证
## 使用docker
- 安装**docker**
- 下载镜像
```shell
docker pull redis:latest
```
- 创建并运行容器
```shell
docker run -d --name redis -p 6379:6379 redis:latest
```
- 启动与停止容器
- 卸载
删除容器与镜像

131
5.linux环境/5.gitlab.md

@ -0,0 +1,131 @@ @@ -0,0 +1,131 @@
# l安装卸载
## 使用源码
- 下载
[下载地址](https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/)
- 安装依赖
```shell
yum install curl policycoreutils openssh-server openssh-clients policycoreutils-python
systemctl enable sshd
systemctl start sshd
```
```shell
yum install postfix
systemctl enable postfix
systemctl start postfix
```
- 汉化
打补丁方式
```shell
wget https://gitlab.com/xhang/gitlab
git diff v12.0.3 v12.0.3-zh > ../12.0.3-zh.diff
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < ../12.0.3-zh.diff
```
直接覆盖方式
```shell
wget https://gitlab.com/xhang/gitlab/repository/12-0-stable-zh/archive.tar.bz2 -O gitlab-12-0-stable-zh.tar.bz2
\cp -rf gitlab-v12.0.0/* /opt/gitlab/embedded/service/gitlab-rails/
```
- 卸载
* 清理命令
```shell
wget https://gitlab.com/xhang/gitlab/repository/12-0-stable-zh/archive.tar.bz2 -O gitlab-12-0-stable-zh.tar.bz2
\cp -rf gitlab-v12.0.0/* /opt/gitlab/embedded/service/gitlab-rails/
```
* 停止gitlab
```shell
gitlab-ctl stop
```
* 卸载gitlab
```shell
rpm -e gitlab-ce
```
- 查看进程
```shell
ps aux | grep gitlab
```
- 杀掉守护进程
```shell
kill -9 xxx
```
- 清理残余文件
```shell
find / -name gitlab | xargs rm -rf
```
## 使用docker
- 安装**docker**
- 查找镜像
```shell
docker search gitlab
```
- 下载汉化版镜像
```shell
docker pull twang2218/gitlab-ce-zh
```
- 创建并启动容器
```shell
docker run -d -p 443:443 -p 280:80 -p 222:22 --name gitlab --privileged --restart=always -v /home/gitlab/config:/etc/gitlab -v /home/gitlab/logs:/var/log/gitlab -v /home/gitlab/data:/var/opt/gitlab twang2218/gitlab-ce-zh
```
容器80、443、22端口分别为`http`、`https`、`ssh`访问端口
- 启动与停止容器
- 卸载
删除容器、镜像和数据
# 配置
## 配置文件
* 配置文件位置
`/etc/gitlab/gitlab.rb`
使用docker安装时需挂载在宿主机上
* 内容
`external_url` 访问地址
`git_data_dir` 数据保存位置
* 注意
用`docker`方式安装时,如使用`nginx`做反向代理,则需要配置`nginx['proxy_set_headers']`中的`host`配置,例:
```tex
external_url "http://gitlab.xumy.vip:28080"
nginx['proxy_set_headers'] = { "Host" => "gitlab.xumy.vip:28080" }
```

49
5.linux环境/6.gitea.md

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
# 安装卸载
## 使用docker
- 安装docker
- 下载镜像
```shell
docker pull gitea/gitea
```
- 创建挂载目录
```shell
mkdir /home/gitea
```
- 创建容器
```shell
docker run -d --name gitea --privileged --restart=always -p 122:22 -p 3000:3000 -v /home/gitea:/data gitea/gite
```
- 初始化
浏览器直接访问`http://[ip]:3000`,根据提示进行初始化配置
- 启动与停止
- 卸载
删除容器、镜像和数据
# 配置
## 初始化
首次安装后
## 配置文件
- 位置
`/data/gitea/conf/app.ini`
- 配置项
[官方配置说明](https://docs.gitea.io/zh-cn/config-cheat-sheet/)

71
5.linux环境/7.Marsterlab.md

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
# 安装卸载
## 使用docker
- 安装**docker**
- 安装并启动**mysql**
- 安装并启动**redis**
- 安装 **masterlab**
- 下载`masterlab-docker`与`masterlab`最新代码
```shell
cd /home
git clone https://gitee.com/firego/masterlab-docker.git
cd ./masterlab-docker/www
git clone https://gitee.com/firego/masterlab.git
cd ./masterlab
unzip ./vendor.zip
```
- 下载镜像
```shell
docker pull gopeak/masterlab:php-fpm-74
docker pull nginx:alpine
docker pull gopeak/masterlab:php-cli-74
```
- 创建容器
需按顺序创建
```shell
docker run -d --name php74 --expose=9000 -p 9000:9000 --link mysql-server:mysql --link redis:redis \
-v /home/masterlab-docker/www/:/var/www/html/ \
-v /home/masterlab-docker/conf/php/php74.ini:/usr/local/etc/php/php.ini \
-v /home/masterlab-docker/conf/php/php-fpm.d/www74.conf:/usr/local/etc/php-fpm.d/www.conf \
-v /home/masterlab-docker/log/php-fpm/:/var/log/php-fpm/ \
gopeak/masterlab:php-fpm-74
docker run -d --name nginx-alpine -p 80:80 -p 443:443 --link php74:fpm74 \
-v /home/masterlab-docker/www/:/var/www/html/ \
-v /home/masterlab-docker/conf/nginx/conf.d:/etc/nginx/conf.d/ \
-v /home/masterlab-docker/conf/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /home/masterlab-docker/log/nginx/:/var/log/nginx/ \
-e "TZ=Asia/Shanghai" \
nginx:alpine
```
`gopeak/masterlab:php-cli-74`为异步邮件发送服务,如不启用异步邮件发送,可以不创建
```shell
docker run -d -it --rm --name php74-cli \
-p 9002:9002 \
-v /home/masterlab-docker/www/masterlab:/usr/workspaces/project \
-w /usr/workspaces/project \
gopeak/masterlab:php-cli-74 \
php ./bin/swoole_server.php
```
- 启动与停止
启动顺序与创建顺序一致
- 卸载
删除相关容器、镜像与数据

33
5.linux环境/8.禅道.md

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
# 安装与卸载
## 使用docker
- 安装docker
- 拉取镜像
```shell
docker pull easysoft/zentao:15.7.1
```
- 创建挂载目录
```shell
mkdir /home/zentao
cd /home/zentao
mkdir pms mysql
```
- 创建容器
```shell
docker run --name zentao -p 8080:80 -v /home/zentao/pms:/www/zentaopms -v /home/zentao/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d easysoft/zentao:15.7.1
```
- 初始化
浏览器直接访问 `http://[ip]:8080`进行初始化配置
- 启动与停止
- 卸载

6
99.随记/1.随记.md

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
# 随记
> 抛开产品线只讨论品牌的人,我不说你们是傻子或者水军,但是明显你们不关心产品,只是在发泄情绪或者炫耀智商。
> 心理学上说你更容易喜欢上喜欢你的人
Loading…
Cancel
Save