Charles

Charles监听localhost请求 访问http://localhost.charlesproxy.com:port 浏览器代理,监听端口8888

April 2, 2021 · 1 min · Steven Jiang

Backend Deploy

按需修改application-prod.yml,如需打开Swagger,那么需要将enabled设置为true。 打包jar包为app.jar 启动脚本 start.sh nohup java -jar app.jar --spring.profiles.active=prod > nohup.out 2>&1 & 停止脚本 stop.sh PID=$(ps -ef | grep app.jar | grep -v grep | awk '{ print $2 }') if [ -z "$PID" ] then echo Application is already stopped else echo kill -9 $PID kill -9 $PID fi 查看日志脚本 log.sh tail -f nohup.out 配置nginx server { listen 80; server_name 域名/当前服务器外网IP; location / { proxy_pass http://127.0.0.1:8000; #这里的端口记得改成项目对应的哦 proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }

March 30, 2021 · 1 min · Steven Jiang

Frontend Deploy

前端配置 提供两个配置方式 [History、Hash] 的部署方式,首先修改接口地址,如果是IP地址,那么需要修改为外网IP。 VUE_APP_BASE_API:没有配置ssl,需要将https改成http VUE_APP_WS_API:如果接口是http形式,wss需要改成ws 项目默认是History模式,不需要做任何修改 Hash模式:修改routers.js,取消hash的注释,修改根目录vue.config.js配置,取消15行的注释(publicPath:process.env.NODE_ENV blah…) 打包前端项目 npm run build:prod # 打包完成后会在根目录生成dist文件夹,我们需要将他上传到服务器中 Nginx配置 History模式 server { listen 80; server_name 域名/外网IP; index index.html; root /usr/share/nginx/html/{name}/dist; #dist上传的路径 # 避免访问出现 404 错误 location / { try_files $uri $uri/ @router; index index.html; } location @router { rewrite ^.*$ /index.html last; } } Hash模式 server { listen 80; server_name 域名/外网IP; location / { root /usr/share/nginx/html/{name}/dist; #dist上传的路径 index index.html; } } 二级目录部署 # Nginx配置 server { listen 80; server_name 域名/外网IP; location /dist { root /usr/share/nginx/html/{name}/test; index index....

March 30, 2021 · 1 min · Steven Jiang

Nginx

安装和配置Nginx容器 文件目录 /home/nginx/conf.d 用于存放配置文件 /home/nginx/cert 用于存放https证书 /home/nginx/html 用于存放网页文件 /home/nginx/logs 用于存放日志 运行nginx容器 docker run -d \ --name nginx --restart always \ -p 80:80 -p 443:443 \ -e "TZ=Asia/Shanghai" \ -v /home/nginx/nginx.conf:/etc/nginx/nginx.conf \ -v /home/nginx/conf.d:/etc/nginx/conf.d \ -v /home/nginx/logs:/var/log/nginx \ -v /home/nginx/cert:/etc/nginx/cert \ -v /home/nginx/html:/usr/share/nginx/html \ nginx:alpine 配置nginx 这里使用Nginx反向代理访问后端服务,由于容器内部通信,因此需要使用容器的IP,也就是172.17.0.1。 在/home/nginx/conf.d创建一个{name}.conf的配置文件,文件内容如下 server { listen 80; server_name 域名/外网IP; index index.html; root /usr/share/nginx/html/{name}/dist; #dist上传的路径 # 避免访问出现 404 错误 location / { try_files $uri $uri/ @router; index index....

March 30, 2021 · 1 min · Steven Jiang

Install PostgreSQL in CentOS 7.4

进入PostgreSQL官网:https://www.postgresql.org/download/linux/redhat/ 选择软件版本和系统版本 在服务器上执行脚本,以CentOS7.4和PostgreSQL13为例 # Install the repository RPM: sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm # Install PostgreSQL: sudo yum install -y postgresql13-server # Optionally initialize the database and enable automatic start: sudo /usr/pgsql-13/bin/postgresql-13-setup initdb sudo systemctl enable postgresql-13 sudo systemctl start postgresql-13 远程连接,密码配置 配置文件路径/var/lib/pgsql/13/data/pg_hba.conf。修改127.0.0.1/32为0.0.0.0/0 配置文件路径/var/lib/pgsql/13/data/postgresql.conf。修改listen_address="*",取消port=5432的注释 重启postgresql 配置防火墙,放行5432端口 sudo firewall-cmd --permanent --add-port=5432/tcp sudo firewall-cmd –reload 修改密码 su – postgres psql ALTER USER postgres WITH PASSWORD '这里输入你的密码'; \q exit

March 30, 2021 · 1 min · Steven Jiang

Use Docker to Deploy SpringBoot Jar

构建与启动Java容器。IntelliJ IDEA运行Gradle bootjar命令 将生成的jar包上传到服务器目录,比如/data目录。 在/data目录创建Dockerfile 文件 FROM java:8 ARG JAR_FILE=./*.jar COPY ${JAR_FILE} app.jar ENV TZ=Asia/Shanghai ENTRYPOINT ["java","-jar","/app.jar"] 构建镜像 docker build -t {image}:{tag} . (注意最后有点.) 运行 docker run -d \ --name {name} --restart always \ -p {port}:{port} \ -e "TZ=Asia/Shanghai" \ -e DB_HOST=172.17.0.1 \ -e DB_PWD=mysql_pwd \ -e REDIS_HOST=172.17.0.1 \ -v /data/userData:{镜像内路径} \ {image}:{tag} docker-compose.yml # coming soon

March 30, 2021 · 1 min · Steven Jiang

Powershell

oh-my-posh # https://ohmyposh.dev/docs/installation Install-Module oh-my-posh -Scope CurrentUser -AllowPrerelease Get-PoshThemes code $profile Set-PoshPrompt -Theme paradox . $profile git clone https://github.com/powerline/fonts.git cd fonts ./install.ps1 Install-Module ZLocation -Scope CurrentUser; Import-Module ZLocation; Add-Content -Value "`r`n`r`nImport-Module ZLocation`r`n" -Encoding utf8 -Path $PROFILE.CurrentUserAllHosts

March 25, 2021 · 1 min · Steven Jiang

Cas

install docker run --rm -p 8080:8080 apereo/cas-initializr:6.3.0 curl http://localhost:8080/starter.tgz -o cas.tgz tar -zxvf cas.tgz chmod +x docker-build.sh chmod +x docker-run.sh ./docker-build.sh

March 25, 2021 · 1 min · Steven Jiang

Wechat

Install # install wepy version 1.X cnpm install wepy-cli -g error Q:regeneratorRuntime.mark undefined A: 关掉小程序开发工具ES6转ES5

March 25, 2021 · 1 min · Steven Jiang

Scoop

Instal # https://scoop.sh/ iwr -useb get.scoop.sh | iex # if error Set-ExecutionPolicy RemoteSigned -scope CurrentUser scoop install 7zip git scoop bucket add extras scoop install everything diskgenius postman hugo nvm error 重装系统后无法找到scoop菜单和程序 # powershell运行 scoop reset *

March 25, 2021 · 1 min · Steven Jiang