liuyuqi-dellpc 9 months ago
parent
commit
47428d6a15

+ 80 - 0
docs/dev/java.md

@@ -0,0 +1,80 @@
+# Java
+
+
+
+
+### 集成部署
+
+
+前端项目打包,放到后端springboot项目 resources 目录:
+ ```npm
+npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
+npm install --registry https://registry.npm.taobao.org  
+npm run build
+ ```
+* 将文件放到 \resources\static下,然后将java程序打包成jar包
+* 修改application-prod.yml中的datasource地址
+* 数据库账号密码设置为:root/123456
+* 数据库脚本领取地址:[https://www.mindskip.net:999](https://www.mindskip.net:999)
+* 创建数据库xzs,导入数据库脚本
+* 学生端访问地址为:<http://ip:8000/student>
+* 管理员端访问地址为:<http://ip:8000/admin>
+* 执行下列命令,运行程序
+
+ ```java
+nohup java -Duser.timezone=Asia/Shanghai -jar -Dspring.profiles.active=prod  xzs-3.9.0.jar  > start1.log  2>&1 &
+ ```
+
+### 前后端分离部署
+
+* 采用前后端分离方式部署,后端启动和部署方式1一样
+* 前端采用nginx来装载静态页面,先创建/usr/local/xzs/web/目录,然后将打包后的student、admin放到此目录下
+* 页面访问端口为8001,注意检查防火墙端口是否打开
+* 学生端访问地址为:<http://ip:8001/student>
+* 管理员端访问地址为:<http://ip:8001/admin>
+* nginx配置如下:
+
+```nginx
+server {
+    listen      8001;
+    server_name xzs;
+    location / {
+        root /usr/local/xzs/web/;
+        index index.html;
+    }
+    location /api/ {
+       proxy_pass  http://localhost:8000;
+    }
+}
+```
+
+### docker部署
+
+* 打开网站<https://gitee.com/mindskip/xzs-mysql>,找到docker目录,里面有已配置好的文件
+* 下载sql脚本,下载教程<https://www.mindskip.net:999>,然后解压sql压缩包,找到xzs-mysql.sql文件,编辑此文件,在文件开头加如下代码:
+
+```xzs-mysql
+CREATE DATABASE `xzs` CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
+USE xzs;
+```
+
+* sql文件改好后,将文件移动到 docker/sql 目录下
+* 将整个docker目录中的文件,复制到/usr/local/xzs下面
+* 进入到install目录,执行下面命令,安装docker-compose
+
+```docker-compose
+cd /usr/local/xzs/install
+mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
+chmod +x  /usr/local/bin/docker-compose
+docker-compose --version
+```
+
+* 执行下面命令,启动学之思网站,有问题可以看下/usr/local/xzs/log中的日志
+
+```docker-xzs
+cd /usr/local/xzs
+docker-compose up -d
+```
+
+* 学生端访问地址为:<http://ip:8000/student>
+* 管理员端访问地址为:<http://ip:8000/admin>

+ 31 - 20
docs/dev/php.md

@@ -1,26 +1,45 @@
 # php 开发
 
-基于 docker ,快速切换 php 版本开发环境,如,项目需要在 php7.4 环境下开发,可以使用以下方式:
 
+构建开发镜像:
+
+包含 composer + xdebug 
+```bash
+cd php\php74xc\
+docker build --pull --rm -f "Dockerfile" -t jianboy/php74xc:latest
+cd php\php8xc\
+docker build --pull --rm -f "Dockerfile" -t jianboy/php8xc:latest
+
+# 切换 php 版本
+cd workspace
+chmod -R 777 .
+docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 jianboy/php74xc:latest /bin/bash
+docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 jianboy/php8xc:latest /bin/bash
+
+composer install
+```
+
+php基础镜像:
 ```bash
 
 chmod -R 777 .
 docker run --rm -it -v $(pwd):/var/www/html -p 9000:80 php:8.3.6-apache
-docker run --rm -it -v $(pwd):/var/www/html -p 9000:80 php:8.1.8-apache
 
-docker run --rm -it -v $(pwd):/var/www/html -p 9000:80 php:7.4.27-apache
+docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -v $(pwd)/Downloads:/root/Downloads/MusicDL/ -p 9000:80 php:8.1.8-apache /bin/bash
 
-docker run --rm -it -v $(pwd):/var/www/html -p 9000:80 php:5.6.38-apache
+thinkphp new demo
+thinkphp serve
 
+# 其他版本
+docker run --rm -it -v $(pwd):/var/www/html -p 9000:80 php:7.4.27-apache
+docker run --rm -it -v $(pwd):/var/www/html -p 9000:80 php:5.6.38-apache
 ```
 
 开发环境需要 composer,启动下面容器即可:
 ```bash
-#php8+xdebug+composer
-mkdir -p php-demo
-chmod 777 php-demo && cd php-demo
+# php8+xdebug+composer
 docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 sineverba/php8xc:1.18.0 /bin/bash
-cd /var/www/html
+docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 sineverba/php74xc:1.11.0 /bin/bash
 ```
 
 laravel 项目使用下面容器,可以添加 `docker-compose.yaml` 配置一并启动数据库:
@@ -41,18 +60,6 @@ docker run -d --name laravel \
 
 ```
 
-php 命令行项目工具:
-```
-docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -v $(pwd)/Downloads:/root/Downloads/MusicDL/ -p 9000:80 php:8.1.8-apache /bin/bash
-
-docker run --rm -it -w /var/www/html -v /workspace:/app php:7.4 /bin/bash
-
-thinkphp new demo
-thinkphp serve
-```
-
-- -v /workspace:/app 挂载本地目录到容器内,/workspace 为本地目录,/app 为容器内目录
-
 ### 额外配置
 
 - 安装 composer
@@ -113,3 +120,7 @@ composer create-project --prefer-dist yiisoft/yii2-app-basic demo
 
 ## Rust
 
+
+## Reference
+
+- [sineverba/php74xc](https://github.com/sineverba/php74xc)

+ 6 - 4
docs/dev/python.md

@@ -10,15 +10,14 @@ docker run --rm -it -v /workspace:/app python:3.8 /bin/bash
 python环境编译较慢,为此最佳的方式 pull 镜像
 
 
+## 集成部署
+
+前端vue项目静态打包到 static 目录
 
 ## 前后端分离部署方案
 
 部署的方法很多
 
-## 前后端分别运行
-
-开发模式下可以这样做
-
 ## nginx + 前后分离
 
 前端静态打包dist,nginx指定root目录即可,对于/api 请求,反向代理转发到 proxy_pass http://127.0.0.1:9999
@@ -58,3 +57,6 @@ RUN apt-get update && apt-get install -y wget unzip openssh-server
 ENV LANG C.UTF-8
 ENV LANGUAGE C.UTF-8
 ```
+
+
+

+ 52 - 0
php/php74xc/Dockerfile

@@ -0,0 +1,52 @@
+FROM php:7.4-fpm
+RUN sed -i 's/deb.debian.org/mirrors.163.com/g' /etc/apt/sources.list
+# COPY sources.list.strech /etc/apt/sources.list
+RUN apt-get update \
+    && apt-get upgrade -y \
+    && apt-get install --assume-yes --no-install-recommends --quiet \
+    build-essential \
+    libmagickwand-dev
+
+RUN apt-get install -y nano \
+    && apt-get install -y libfreetype6-dev \
+    && apt-get install -y zlib1g-dev \
+    && apt-get install -y libzip-dev \
+    && apt-get install -y libjpeg62-turbo-dev \
+    && apt-get install -y libpng-dev \
+    && apt-get install -y zip \
+    && apt-get install -y git \
+    && apt-get install -y supervisor \
+    && apt-get install -y mariadb-client \
+    && docker-php-ext-install bcmath \
+    && docker-php-ext-install ctype \
+    && docker-php-ext-configure gd \
+    && docker-php-ext-install gd mysqli zip pdo pdo_mysql exif pcntl bcmath opcache \
+    && docker-php-ext-enable mysqli pdo pdo_mysql exif pcntl bcmath gd
+
+# pdo_pgsql need specify correct PostgreSQL installation path
+
+RUN pecl install imagick \
+    && docker-php-ext-enable imagick
+
+RUN pecl install mongodb
+RUN echo "extension=mongodb.so" > $PHP_INI_DIR/conf.d/mongodb.ini
+
+RUN pecl install redis
+RUN echo "extension=redis.so" > $PHP_INI_DIR/conf.d/redis.ini
+
+# xdebug 3.1.6
+RUN pecl install xdebug-3.1.6 \
+    && docker-php-ext-enable xdebug
+
+RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
+RUN php composer-setup.php
+RUN mv composer.phar /usr/local/bin/composer
+RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
+
+RUN apt-get clean all
+
+EXPOSE 9000
+WORKDIR /var/www/html
+
+CMD service supervisor start \
+    && php-fpm

+ 14 - 0
php/php74xc/docker-compose.yml

@@ -0,0 +1,14 @@
+version: '3.7'
+services:
+
+  php:
+    container_name: "php-fpm"
+    # depends_on:
+    #   - redis
+    #   - mysql
+    build:
+      context: ./
+      dockerfile: ./Dockerfile
+    volumes:
+      - ../backend:/var/www/html/
+    restart: on-failure

+ 11 - 0
php/php74xc/sources.list.stretch

@@ -0,0 +1,11 @@
+deb http://mirrors.163.com/debian/ buster main non-free contrib
+deb http://mirrors.163.com/debian/ buster-updates main non-free contrib
+deb http://mirrors.163.com/debian/ buster-backports main non-free contrib
+deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib
+deb http://mirrors.163.com/debian/ stable main contrib non-free
+deb http://mirrors.163.com/debian/ stable-updates main contrib non-free
+
+deb-src http://mirrors.163.com/debian/ buster main non-free contrib
+deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib
+deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib
+deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib

+ 56 - 0
php/php8xc/Dockerfile

@@ -0,0 +1,56 @@
+FROM php:8.3-fpm
+# RUN sed -i 's/deb.debian.org/mirrors.163.com/g' /etc/apt/sources.list
+# COPY sources.list.strech /etc/apt/sources.list
+
+RUN apt-get update \
+    && apt-get upgrade -y \
+    && apt-get install -y nano \
+    && apt-get install -y libfreetype6-dev \
+    && apt-get install -y zlib1g-dev \
+    && apt-get install -y libzip-dev \
+    && apt-get install -y libjpeg62-turbo-dev \
+    && apt-get install -y libpng-dev \
+    && apt-get install -y zip \
+    && apt-get install -y git \
+    && apt-get install -y supervisor \
+    && apt-get install -y mariadb-client \
+    && docker-php-ext-install bcmath \
+    && docker-php-ext-install ctype \
+    && docker-php-ext-configure gd \
+    && docker-php-ext-install gd mysqli zip pdo pdo_mysql exif pcntl bcmath opcache \
+    && docker-php-ext-enable mysqli pdo pdo_mysql exif pcntl bcmath gd
+
+RUN apt-get install --assume-yes --no-install-recommends --quiet \
+    build-essential \
+    libmagickwand-dev
+# && apt-get clean all
+
+# RUN pecl install imagick \
+#     && docker-php-ext-enable imagick
+
+RUN pecl install mongodb
+RUN echo "extension=mongodb.so" > $PHP_INI_DIR/conf.d/mongodb.ini
+
+RUN pecl install redis
+RUN echo "extension=redis.so" > $PHP_INI_DIR/conf.d/redis.ini
+
+# xdebug 3.1.6
+RUN pecl install xdebug-3.3.2 \
+    && docker-php-ext-enable xdebug
+
+RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
+RUN php composer-setup.php
+RUN mv composer.phar /usr/local/bin/composer
+RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
+
+# COPY config/10-shorttag.ini \
+#     config/20-memory-limit.ini \
+#     config/30-opcache.ini \
+#     config/40-xdebug.ini \
+#     $PHP_INI_DIR/conf.d/
+WORKDIR /var/www/html
+
+EXPOSE 9000
+
+CMD service supervisor start \
+    && php-fpm

+ 1 - 0
php/php8xc/config/40-xdebug.ini

@@ -0,0 +1 @@
+xdebug.mode=debug,coverage

+ 14 - 0
php/php8xc/docker-compose.yml

@@ -0,0 +1,14 @@
+version: '3.7'
+services:
+
+  php:
+    container_name: "php-fpm"
+    # depends_on:
+    #   - redis
+    #   - mysql
+    build:
+      context: ./
+      dockerfile: ./Dockerfile
+    volumes:
+      - ../backend:/var/www/html/
+    restart: on-failure

+ 11 - 0
php/php8xc/sources.list.stretch

@@ -0,0 +1,11 @@
+deb http://mirrors.163.com/debian/ buster main non-free contrib
+deb http://mirrors.163.com/debian/ buster-updates main non-free contrib
+deb http://mirrors.163.com/debian/ buster-backports main non-free contrib
+deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib
+deb http://mirrors.163.com/debian/ stable main contrib non-free
+deb http://mirrors.163.com/debian/ stable-updates main contrib non-free
+
+deb-src http://mirrors.163.com/debian/ buster main non-free contrib
+deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib
+deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib
+deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib