CentOS6下安装mysql5.7

下载mysql5.7

养成良好的目录习惯,切换到/usr/local/src

cd /usr/local/src
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz 

解压并挪到安装目录

tar -vxf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.23-linux-glibc2.12-x86_64 /usr/local/mysql

添加系统用户mysql及mysql组

groupadd mysql
useradd -r -g mysql mysql

切换到安装目录并修改其拥有者

cd /usr/local/mysql
chown -R mysql:mysql ./

安装

mkdir data
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

如下图安装成功,得到默认登录密码

登录mysql

mysql -uroot -p

提示输入密码,请使用上面截图的默认密码登录即可

修改默认密码

alter user 'root'@'localhost' identified by '123456';

CentOS6安装gitlab-ce

安装必要依赖:

sudo yum install -y curl policycoreutils-python openssh-server cronie
sudo lokkit -s http -s ssh

安装邮件发送依赖

sudo yum install postfix
sudo service postfix start
sudo chkconfig postfix on

将gitlab-ce加入下载仓库

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

安装gitlab-ce

URL请根据自身设置

sudo EXTERNAL_URL="http://gitlab.adebug.com" yum -y install gitlab-ce

git仓库创建管理

Git global setup

git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"

Create a new repository

git clone git@域名或ID:/仓库目录/empty.git
cd empty
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder

cd existing_folder
git init
git remote add origin git@域名或ID:/仓库目录/empty.git
git add .
git commit -m "Initial commit"
git push -u origin master

Existing Git repository

cd existing_repo
git remote add origin git@gitlab.66580.cn:ziyo/empty.git
git push -u origin --all
git push -u origin --tags

利用hooks进行自动部署

生成sshkey

ssh-keygen -t rsa -C "admin@adebug.com"

会提示保存在什么目录下(一般在/var/opt/gitlab/.ssh/),得到两个文件:id_rsa和id_rsa.pub。注意该目录权限权限应改为700

创建公钥配对目录及文件,并将生成的公钥id_rsa.pub内容加到authorized_keys中

cd /home
mkdir -p git/.ssh/
cd git/.ssh
touch authorized_keys
chown -R git:git /home/git
chmod 600 authorized_keys
cat /var/opt/gitlab/.ssh/id_rsa.pub >> authorized_keys

到代码仓库目录下加入post-receiv,下面目录根据自身情况切换

cd /gitrepo/test.git/hooks/
touch post-receive

文件内容为

#!/bin/sh
export LANG=zh_CN.UTF-8
unset GIT_DIR
cd /home/wwwroot/test #你服务器上发布的项目目录
git pull origin master

服务器上的项目目录需要加入到git组中,否则有权限问题

chown -R git:git /home/wwwroot/test