06-22
0
TP nginx+mysql+php+redis+activemq 服务器原生搭建
TP框架 目录权限
缓存目录
chmod -R 777 /home/fastadmin/runtime
chmod -R 777 /home/fastadmin/application
chmod -R 777 /home/fastadmin/public
安装nginx
yum list installed | grep nginx
yum -y install nginx
systemctl start nginx
vi /etc/nginx/nginx.conf
systemctl restart nginx
systemctl status nginx
systemctl enable nginx
systemctl stop nginx
安装mysql
yum list installed | grep mysql
ps aux | grep mysql
cd /home && wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
yum clean all
yum makecache
yum -y install mysql-community-server
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
systemctl restart mysqld
安装php
sudo yum install -y epel-release
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install -y yum-utils
sudo yum-config-manager --enable remi-php74
sudo yum install -y php php-cli php-fpm php-common php-gd php-json php-mysqlnd php-pdo php-imagick php-zip
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
yum list installed | grep php
sudo yum remove php*
安装redis
yum list installed | grep redis
ps aux | grep redis-server
cd /home && wget http://download.redis.io/releases/redis-3.2.8.tar.gz
tar xzf redis-3.2.8.tar.gz
cd redis-3.2.8 && make install
make
make install
cp /home/redis.conf /etc/
cp /home/redis.service /etc/systemd/system/redis.service
sudo vi /etc/systemd/system/redis.service
sudo systemctl daemon-reload
sudo systemctl start redis.service
sudo systemctl status redis.service
sudo systemctl enable redis.service
sudo systemctl restart redis.service
安装activemq
cd /usr/local
tar -xzvf apache-activemq-5.18.4-bin.tar.gz
cp /home/activemq.service /etc/systemd/system/
cp /home/activemq.xml /usr/local/apache-activemq-5.18.4/conf
cp /home/env /usr/local/apache-activemq-5.18.4/bin
sudo vi /etc/systemd/system/activemq.service
/usr/local/jdk/jdk-11.0.2
chmod +x /etc/systemd/system/activemq.service
systemctl start activemq.service
systemctl status activemq.service
systemctl enable activemq.service
systemctl restart activemq.service
systemctl stop activemq.service
/usr/local/apache-activemq-5.18.4/bin/activemq start
/usr/local/apache-activemq-5.18.4/bin/activemq stop
08-02
0
git命令
git init 初始化
git add . 添加 所有内容 到缓存区
git commit -m ‘first commit’ 提交注释
git remote add origin git@github.com:帐号名/仓库名.git 添加远程git库地址
git pull origin master 拉取主分支内容
git push origin master # -f 强推
git clone git@github.com:git帐号名/仓库名.git 克隆远程git库
拉取 某次提交内容 到 当前分支
git cherry-pick <commitHash>
将 feature 分支的最近一次提交,转移到当前分支
git cherry-pick feature
将 A 和 B 两个提交应用到当前分支
git cherry-pick <HashA> <HashB>
可以转移从 A 到 B 的所有提交 提交 A 必须早于提交 B,否则命令将失败,但不会报错。注意,使用上面的命令,提交 A 将不会包含在 Cherry pick 中
git cherry-pick A..B
如果要包含提交 A,可以使用下面的语法。
git cherry-pick A^..B
git checkout master 切到主分支
git fetch origin 获取最新变更
git checkout -b dev origin/master 基于主分支创建dev分支
git add . 添加到缓存
git commit -m ‘xxx’ 提交到本地仓库
git fetch origin 获取最新变更
git status
git add 文件名 将工作区的某个文件添加到暂存区
git add . 将当前工作区的所有文件都加入暂存区
git add -u 添加所有被tracked文件中被修改或删除的文件信息到暂存区,不处理untracked的文件
git add -A 添加所有被tracked文件中被修改或删除的文件信息到暂存区,包括untracked的文件
git add -i 进入交互界面模式,按需添加文件到缓存区
git commit -m “提交说明” 将暂存区内容提交到本地仓库
git commit -a -m “提交说明” 跳过缓存区操作,直接把工作区内容提交到本地仓库
6、查看历史记录
git log 查看所有commit记录(SHA-A校验和,作者名称,邮箱,提交时间,提交说明)
git log -p -次数 查看最近多少次的提交记录
git log --stat 简略显示每次提交的内容更改
git log --name-only 仅显示已修改的文件清单
git log --name-status 显示新增,修改,删除的文件清单
git log --oneline 让提交记录以精简的一行输出
git log --graph --all --online 图形展示分支的合并历史
git log --author=作者 查询作者的提交记录(和grep同时使用要加一个--all--match参数)
git log --grep=过滤信息 列出提交信息中包含过滤信息的提交记录
git log -S查询内容 和--grep类似,S和查询内容间没有空格
git log fileName 查看某文件的修改记录
git reset HEAD^ 恢复成上次提交的版本
git reset HEAD^^ 恢复成上上次提交的版本,就是多个^,以此类推或用~次数
git reflog
git reset --hard 版本号
--soft:只是改变HEAD指针指向,缓存区和工作区不变;
--mixed:修改HEAD指针指向,暂存区内容丢失,工作区不变;
--hard:修改HEAD指针指向,暂存区内容丢失,工作区恢复以前状态;
查看分支:git branch -a
合并分支:
git merge dev #用于合并指定分支到当前分支
git merge --no-ff -m “merge with no-ff” dev #加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并
git相关配置
git config --global user.name “用户名” # 设置用户名
git config --global user.email “用户邮箱” #设置邮箱
git config --global user.name # 查看用户名是否配置成功
git config --global user.email # 查看邮箱是否配置
git config --global --list # 查看全局设置相关参数列表
git config --local --list # 查看本地设置相关参数列表
git config --system --list # 查看系统配置参数列表
git config --list # 查看所有Git的配置(全局+本地+系统)
git config --global color.ui true //显示git相关颜色
撤消某次提交
git revert HEAD # 撤销最近的一个提交
git revert 版本号 # 撤销某次commit
07-31
0
Docker搭建 nginx+php+mysql+redis
一.创建 /app/www /app/docker_files
二. /app/www 项目目录
三.docker配置目录
1.nginx 创建目录 /app/www/nginx /app/www/nginx/
Dockerfile
from nginx
COPY ./conf/conf.d/ /etc/nginx/conf.d/
COPY ./conf/certs/ /etc/nginx/certs/
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
2.php 创建目录 /app/docker_files/php
Dockerfile
FROM php:8.0-fpm
ENV WWW_PATH "/www"
RUN mkdir ${WWW_PATH}
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get clean
RUN pecl install redis-5.3.7 && docker-php-ext-enable redis
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
RUN apt-get install -y \
zlib1g-dev \
libzip-dev
RUN docker-php-ext-install zip
RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-install bcmath
RUN apt-get install -y procps
RUN apt-get install -y vim
RUN apt-get install -y supervisor
WORKDIR ${WWW_PATH}
RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" && php composer-setup.php && php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer
3.redis 创建目录/app/docker_files/redis
Dockerfile
FROM redis
COPY ./redis.conf /usr/local/etc/redis/redis.conf
4.mysql 创建目录 /app/docker_files/mysql /app/docker_files/mysql/conf /app/docker_files/mysql/data
Dockerfile
FROM mysql:5.7
COPY conf/ /etc/mysql/conf.d/
COPY data/ /var/lib/mysql/
EXPOSE 3306
5. docker-comose.yml 配置
version: '3' services: web: build: './nginx' image: 'nginx-server:1.0' container_name: 'nginx-server' ports: - "80:80" - "443:443" volumes: - '/app/docker_files/nginx/conf/nginx.conf:/etc/nginx/nginx.conf' - '/app/docker_files/nginx/conf/conf.d:/etc/nginx/conf.d' - '/app/docker_files/nginx/conf/certs:/etc/nginx/certs' - '/app/www:/usr/share/nginx/html' networks: - lnmp php: build: './php' image: 'php-server:1.0' container_name: 'php-server' ports: - "9000:9000" volumes: - "/app/www:/www" networks: - lnmp redis: build: './redis' image: 'redis-server:1.0' container_name: 'redis-server' ports: - "6379:6379" networks: - lnmp db: build: './mysql' image: 'db-server:1.0' container_name: 'db-server' ports: - "3366:3306" volumes: - "/app/docker_files/mysql/conf:/etc/mysql/conf.d" - "/app/docker_files/mysql/data:/var/lib/mysql" restart: always environment: MYSQL_ROOT_PASSWORD: 123456 networks: - lnmp networks: lnmp: driver: bridge
07-31
0
mysql主从数据库 docker环境
1.配置主库
master.cnf
[mysqld]
# 同一局域网内注意要唯一
server-id=100
# 开启二进制日志功能,可以随便取
log-bin=mysql-bin
查看二进制日志是否开启
SHOW GLOBAL VARIABLES LIKE '%log%';
查看主节点的server id
SHOW GLOBAL VARIABLES LIKE '%server%';
创建有复制权限的用户slave
CREATE USER 'slave'@'%' IDENTIFIED BY '123456';
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'slave'@'%' IDENTIFIED by '123456';
刷新配置
FLUSH PRIVILEGES;
查看File和Position字段的值
show master status;
2.配置从库
slave.cnf
[mysqld]
server-id=101
#开启二进制日志功能,以备Slave作为其它Slave的Master时使用
log-bin=mysql-slave-bin
#relay_log配置中继日志
relay_log=edu-mysql-relay-bin
停止主从复制
stop slave;
设置主数据库信息
change master to master_host='172.17.0.5', master_user='slave', master_password='123456', master_port=3306, master_log_file='mysql-bin.000001', master_log_pos=856, master_connect_retry=30;
启动主从复制
start slave;
查看主从同步状态
show slave status;
设置从库只读
# 开启只读
show global variables like "%read_only%";
# 对所有用户生效,包括super用户(不建议使用)
flush tables with read lock;
# 只对普通用户生效,如slave用户
set global read_only=1;
show global variables like "%read_only%";
# 关闭只读
unlock tables;
set global read_only=0;
Docker配置
创建 /app/docker_files/mysql 文件夹
docker-compose.yml 配置文件 放在 /app/docker_files目录下
version: '3'
services:
db-master:
build: './mysql'
image: 'db-server:1.0'
container_name: 'db-master'
ports:
- "3366:3306"
volumes:
- "/app/docker_files/mysql/conf/master.cnf:/etc/mysql/conf.d/master.cnf"
- "/app/docker_files/mysql/data:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: qwe123!@#
command: ["mysqld", "--server-id=1", "--log-bin=mysql-bin"]
networks:
- lnmp
db-slave:
build: './mysql'
image: 'db-server:1.0'
container_name: 'db-slave'
ports:
- "3307:3306"
volumes:
- "/app/docker_files/mysql/conf/slave.cnf:/etc/mysql/conf.d/slave.cnf"
- "/app/docker_files/mysql/slave-data:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: qwe123!@#
command: ["mysqld", "--server-id=2"]
networks:
- lnmp
networks:
lnmp:
driver: bridge
07-05
0
laravel
1.创建一个名为laravel的laravel项目
composer create-project laravel/laravel --prefer-dist ./QZ_20_0712
命令解释:
composer:表示执行该程序;
create-project :创建项目
laravel/laravel:需要创建的项目名称;
–prefer-dist:优先下载压缩包方式,而不是直接从GitHub上下载源码
2.php artisan
(1)数据表
//创建迁移 建表
php artisan make:migration create_demo_table
//重建数据库,在原本的迁移文件中增加字段后执行
php artisan migrate:refresh
//数据表迁移
php artisan migrate
//数据表回滚
php artisan migrate:rollback
(2)功能列表
php artisan list
(3)make 列表
make:cast Create a new custom Eloquent cast class
make:channel Create a new channel class
make:command Create a new Artisan command
make:component Create a new view component class
make:controller Create a new controller class
make:event Create a new event class
make:exception Create a new custom exception class
make:export Create a new export class
make:factory Create a new model factory
make:import Create a new import class
make:job Create a new job class
make:listener Create a new event listener class
make:mail Create a new email class
make:middleware Create a new middleware class
make:migration Create a new migration file
make:model Create a new Eloquent model class
make:notification Create a new notification class
make:observer Create a new observer class
make:policy Create a new policy class
make:provider Create a new service provider class
make:request Create a new form request class
make:resource Create a new resource
make:rule Create a new validation rule
make:seeder Create a new seeder class
make:test Create a new test class