A method for automated deployment code:
Setting up an svn repository hooks to write scripts to automate deployment.
2.jenkins and git combine to automate the deployment of code.
3. The combination of ftp and rsync and cron job to automate the deployment of code.
Two, SVN deployment Description:
[root @ E /] # yum the install Subversion -Y -> download
[root @ E /] # CD / Data /
[root @ E Data] # mkdir testsvn -> Create Warehouse
[root testsvn @e] # Create the svnadmin / Data / testsvn
[testsvn the root @ E] # LS
the conf DB Hooks Locks the README.txt the format
[testsvn the root @ E] the conf # CD /
[the conf the root @ E] # LS
the authz the passwd the svnserve.conf
[root @ E conf] # vi svnserve.conf
anon = the read-Access # anonymous user readable
auth-access = write # authorized users can write
password-db = passwd # which file to use as account files
authz-db = authz # use which file as the file permissions
realm = data / testsvn # certification space name, the repository directory
[root @ E conf] # vi passwd
LB = LB -> add the user's password
[root @ E conf] # vi authz
[/] - -> Add permissions
-
= r
[root@e conf]# svnserve -d -r /data/testsvn/ 启动
[root@e conf]# netstat -luntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3690 0.0.0.0: LISTEN 18463/svnserve
[root@e conf]# cd ../hooks/ -->钩子脚本位置
[root@e hooks]# ls
post-commit.tmpl post-revprop-change.tmpl pre-commit.tmpl pre-revprop-change.tmpl start-commit.tmpl
post-lock.tmpl post-unlock.tmpl pre-lock.tmpl pre-unlock.tmpl
[root@e hooks]# cp post-commit.tmpl post-commit
[root@e hooks]# chmod +x post-commit
[root@e hooks]# vi post-commit#!/bin/bash
. /etc/profile
REPOPATH="$1"
REV="$2"
TRANS="$3"
repo_name="testsvn"
svn_url="svn://127.0.0.1:3690/"
local_co_path="/data/svn_push_dir/"
repo_url=$svn_url$repo_name
repo_co_path=$local_co_path$repo_name
/usr/bin/test -d $local_co_path || /bin/mkdir $local_co_path
/usr/bin/svn --username lb --password 'lb' co $repo_url $repo_co_path --no-auth-cache
remote_dir="/data/www/code/"
for host in intf-01 intf-02;do
/usr/bin/rsync -az --timeout=300 --exclude ".svn" --exclude "tmp" $repo_co_path"/" www@$host:/data/www/code/
doneThis is a simple svn, git used because I do not I will not say that the
three, ftp + rsync + scheduled tasks automatically deploy code selected here pureftp this ftp tool, I used to compile and install
1. Download the package "more detailed "
https://blog.51cto.com/865516915/2064503
2. installation
[the root @ E ~] # the tar zxvf lnmp1.5.tar.gz
[the root @ E ~] # CD lnmp1.5
[@ E lnmp1 the root. . 5] # LS
addons.sh the conf the init.d License pureftpd.sh the src the uninstall.sh upgrade.sh
the ChangeLog the include the install.sh lnmp.conf the README Tools upgrade1.x-1.5.sh
[lnmp1.5 the root @ E] ./ # pureftpd.sh -> compiler installation
[lnmp1.5 the root @ E] # CD / usr / local / the pureftpd /
[the pureftpd the root @ E] # LS
bin etc sbin Share
[the pureftpd the root @ E] # VI etc / the pureftpd .conf -> profiles can modify the port
...
the Bind 127.0.0.1,21 -> IP, port
...
[the pureftpd the root @ E] # the pureftpd the restart-Service
Note: iptbables to release port
3. Use:
A, adding user permissions
①. Compiled and installed can be used to add lnmp ftp add users and privileges
[the pureftpd the root @ E] # lnmp ftp add
+ ---------------------------- + ---------------
| Manager for LNMP, Written by Licess |
+ ------------------------ + -------------------
| https://lnmp.org |
+ -------------------- + -----------------------
the Enter the FTP the Account name: LB -> username
Enter password for ftp account lb: lb -> password
Enter directory for ftp account lb: / data -> permissions
Password:
the Enter IT Again:
the Created the FTP the User: LB sucessfully.
②. Add command using pure-pw
[the root bin @ E] # CD / usr / local / the pureftpd / bin /
[the root bin @ E] LS #
pwconvert-PW-Pure Pure Pure-statsdecode
[the root bin @ E] -u # ./pure-pw WWW LBLB the useradd -d / Data /
Password:
the Enter Again IT:
Note: lblb -u the user is present in the system user -d permission
b, delete users
①. the FTP del LB LNMP
②. userdel LBLB ./pure-pw
c, view the user
①. List the FTP LNMP
②. List ./pure-pw
4, with rsync
rsync installed I will not elaborate, we can be installed in accordance with this post documentation
https://blog.csdn.net/u011017575/article/details/52456645
After 5, start rsync you can write a regular task client
# / 1 * -avzP --timeout rsync --password-File 300 = = / tmp / lmpasswd.txt the Data :: LB @ ip / the Data / the WWW / 2> & 1> / dev / null