发布系统在技术团队中有着重要作用, 承担我们每天的服务部署工作, 企业发布系统根据企业技术能力来决定, 小公司不像那些公司一样,有充足的人力去开发一套自己的发布系统. 所以尽可能的去寻找一些适合企业应用的部署系统, 以提高人力成本.
这里推荐两款开源的发布系统:
- jekins: https://jenkins.io/ (Java语言开发)[普遍]
- walle: http://www.walle-web.io/ (PHP语言开发)[小众]
jekins可能大家都很熟悉,也有好多文章, walle是国人写的一个轻量的发布系统, 只所以推荐它 是因为相对其它开源的发布系统来说, 其UI界面至少看着比较舒服, 基本功能也都有. 支持国产开源.
Walle安装部署
Walle是基于PHP写的, 所以安装前需要安装PHP环境.
PHP环境安装
这里选用php最新稳定版7.1.10
[root@localhost ~]# wget http://cn2.php.net/distributions/php-7.1.10.tar.gz
[root@localhost ~]# tar -zxvf php-7.1.10.tar.gz
[root@localhost ~]# cd php-7.1.10/
[root@localhost php-7.1.10]# ./configure --help
[root@localhost php-7.1.10]# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
[root@localhost php-7.1.10]# ./configure --prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
[root@localhost php-7.1.10]# make & make install
[root@localhost php-7.1.10]# cp php.ini-development /usr/local/php/lib/php.ini
[root@localhost php-7.1.10]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@localhost php-7.1.10]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@localhost php-7.1.10]# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
[root@localhost php-7.1.10]# /etc/init.d/php-fpm
修改php进程归属用户(/usr/local/php/etc/php-fpm.d/www.conf
), 修改user和group值.
笔者示例中值均为 elonsu
.
[elonsu@localhost ~]$ grep -C 3 'elonsu' /usr/local/php/etc/php-fpm.d/www.conf -n
20-; Unix user/group of processes
21-; Note: The user is mandatory. If the group is not set, the default user's group
22-; will be used.
23:user = elonsu
24:group = elonsu
25-
26-; The address on which to accept FastCGI requests.
27-; Valid syntaxes are:
配置php环境变量
在/etc/profile
文件末尾追加环境变量,如下:
# 这是PHP环境变量
PHP_HOME=/usr/local/php
# 设置Meven环境变量
M2_HOME=/usr/local/apache-maven-3.5.0
# 设置Java环境变量
JAVA_HOME=/usr/local/jdk1.8.0_121
JRE_HOME=/usr/local/jdk1.8.0_121/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$M2_HOME/bin:$PHP_HOME/bin:
export PHP_HOME M2_HOME JAVA_HOME JRE_HOME CLASS_PATH PATH
使配置生效
[root@localhost ~]$ source /etc/profile
[elonsu@localhost ~]$ php -v
PHP 7.1.10 (cli) (built: Oct 22 2017 14:23:52) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
下载Walle
Github: https://github.com/meolu/walle-web
elonsu@localhost cloud]$ pwd
/export/cloud
elonsu@localhost cloud]$ git clone git@github.com:meolu/walle-web.git
elonsu@localhost cloud]$ cd walle-web
elonsu@localhost cloud]$ vi config/local.php
设置数据库链接和用户注册邮件通知服务配置
安装Walle
[elonsu@localhost walle-web]$ curl -sS https://getcomposer.org/installer | php
[elonsu@localhost walle-web]$ php composer.phar require guzzlehttp/promises
[elonsu@localhost walle-web]$ php composer.phar require guzzlehttp/guzzle
[elonsu@localhost walle-web]$ php composer.phar install --prefer-dist --no-dev --optimize-autoloader -vvvv
[elonsu@localhost walle-web]$ ./yii walle/setup
Nginx反向代理
[elonsu@localhost walle-web]$ cat /usr/local/nginx/conf/domains/walle.wuyu.com
server {
listen 80;
server_name walle.wuyu.com;
root /export/cloud/walle-web/web;
index index.php;
# 建议放内网
# allow 192.168.0.0/24;
# deny all;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
访问登录
访问: http://walle.wuyu.com/
首次登录默认管理员用户admin/admin
.
配置项目
发布系统部署完后登录后效果图如下(林韵熙账户为笔者自己创建):
image添加项目配置
【项目配置】- 【新建项目】:
image上图为个人技术博客发布项配置.
检测项目配置
【项目配置】-【配置列表】-【检测】, 检测配置项是否配置成功.
image创建上线任务
【我的上线单】-【创建上线单】-【选择上线的模板】, 填写如下项:
- 上线单标题
- 选取分之
- 版本选取
- 全量/增量
填写完之后会在【我的上线单】, 中出现刚才添加的上线单项目. 如下图:
[图片上传失败...(image-2b5ebe-1576723298986)]
执行上线操作
【我的上线单】-【选择上线单项】-【上线】-【部署】:
[图片上传失败...(image-313508-1576723298986)]
远程GIT仓库授权配置
远程私有仓库ssh 授权
[elonsu@localhost ~]# ssh-keygen -t rsa -C "xxx@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/elonsu/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /elonsu/.ssh/id_rsa.
Your public key has been saved in /elonsu/.ssh/id_rsa.pub.
The key fingerprint is:
8b:8a:a0:b3:a5:a1:5f:96:8a:3c:5a:c1:e0:b3:f4:f3 xxx@163.com
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
|. |
|.o |
| +o S |
|. +. . . . |
|o.oo+ . . |
|=O =o. |
|O== .E |
+-----------------+
[elonsu@localhost ~]# ls
[elonsu@localhost ~]$ ls ~/.ssh/
id_rsa id_rsa.pub
这里的id_rsa为私钥, id_rsa_pub为公钥
Git服务器配置SSH公钥
以开源中国为例, 【个人】-【设置】-【SSH公钥】
[图片上传失败...(image-fdec97-1576723298986)]
开源中国官方配置说明:http://git.mydoc.io/?t=154712
检测配置
[elonsu@localhost ~]$ ssh -T git@gitee.com
...
Welcome to Gitee.com, -林韵熙-!
部署目标机器授权
我们以root用户身份, 将项目发布到192.178.0.107
服务上时,需要给目标机器授权.如下:
[root@localhost ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.107
此时会提示让输入目标服务器密码. 正确输入密码后,配置成功.
网友评论