1,在ubuntu上搭建测试环境
需要安装的软件:
sudo chmod 400 ~/.ssh/id_rsa
sudo ./Git.sh -i ~/.ssh/id_rsa clone git@gitlab.rd.chanjet.com:chanjet_web_gov/chanjet_web.git
静态资源:
sudo ~/bin/git.sh -i ~/.ssh/id_rsa clone git@gitlab.rd.chanjet.com:zhengjiang/chanjet_web.git
/home/oliangdd/
修改/etc/profile
sudo vim .profile
sudo vim ./.bashrc 修改path环境变量
sudo ~/bin/git.sh -i ~/.ssh/id_rsa clone git@gitlab.rd.chanjet.com:chanjet_web_gov/chanjet_web.git
sudo ~/bin/git.sh -i ~/.ssh/id_rsa pull
sudo ~/bin/git.sh -i ~/.ssh/id_rsa status
下载maven :
sudo wget http://apache.mirrors.hoobly.com/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
设置maven的环境变量:
M2_HOME=/opt/maven
PATH=$PATH:/home/oliangdd/bin:$M2_HOME/bin
export PATH
mvn install -U
使用ubuntu开启8080 端口:
sudo ufw allow 8080/tcp
安装node 参考:http://blog.csdn.net/chszs/article/details/37521463
sudo apt-get install -y Python-software-properties software-properties-common
sudo add-apt-repository ppa:chris-lea/Node.js
sudo apt-get install nodejs
sudo apt-get install node
sudo apt-get install node-less
查看git 状态:
sudo ~/bin/git.sh -i ~/.ssh/id_rsa status
revert:
sudo ~/bin/git.sh -i ~/.ssh/id_rsa checkout -- css
sudo ~/bin/git.sh -i ~/.ssh/id_rsa checkout -- js
把修改的文件还原
sudo ~/bin/git.sh -i ~/.ssh/id_rsa reset HEAD
2,部署脚本:
服务器端:update_server
- $current_path
- current_path=`pwd`
- server_home=/opt/yunyingyong/mainsite/mainsite/src/server/chanjet_web
- tomcat_home=/opt/yunyingyong/mainsite/mainsite/apache-tomcat-7.0.53
- tomcat_webapp=$tomcat_home/webapps
- echo "into $server_home..."
- cd $server_home
- echo "update git code..."
- sudo ~/bin/git.sh -i ~/.ssh/id_rsa pull
- echo "execute maven "
- # mvn clean install -U
- echo "stop tomcat ..."
- sudo $tomcat_home/bin/shutdown.sh
- cd $tomcat_webapp
- sudo rm -fr ROOT/
- sudo rm -fr ROOT.war
- sudo cp -fr $server_home/target/ROOT.war ./
- echo "start tomcat"
- sudo $tomcat_home/bin/startup.sh
- cd $current_path
静态资源部署脚本:update_web_js
- current_path=`pwd`
- static_home=/opt/yunyingyong/mainsite/mainsite/src/web_js
- tomcat_home=/opt/yunyingyong/mainsite/mainsite/apache-tomcat-7.0.53
- tomcat_webapp=$tomcat_home/webapps
- cd $static_home/chanjet_web
- sudo ~/bin/git.sh -i ~/.ssh/id_rsa pull
- cd $static_home
- echo "delete chanjet_web_build"
- sudo rm -fr chanjet_web_build
- echo "copy chanjet_web to chanjet_web_build "
- sudo cp -r chanjet_web chanjet_web_build
- cd $static_home/chanjet_web_build
- sudo chmod a+x build.sh
- echo "delete mv ./js ./js_src "
- sudo sed -i '/mv[[:space:]]\+.\/js[[:space:]]\+.\/js_src/d' build.sh
- sudo ./build.sh
- cd $tomcat_webapp
- echo "delete $tomcat_webapp/chanjet"
- sudo rm -fr $tomcat_webapp/chanjet
- #sudo mkdir $tomcat_webapp/chanjet_web_js
- sudo cp -fr $static_home/chanjet_web_build $tomcat_webapp/chanjet
- cd $current_path
git.sh脚本内容如下:
- #!/bin/bash
- # The MIT License (MIT)
- # Copyright (c) 2013 Alvin Abad
- #set -x
- if [ $# -eq 0 ]; then
- echo "Git wrapper script that can specify an ssh-key file
- Usage:
- git.sh -i ssh-key-file git-command
- "
- exit 1
- fi
- # remove temporary file on exit
- trap 'rm -f /tmp/.git_ssh.$$' 0
- if [ "$1" = "-i" ]; then
- SSH_KEY=$2; shift; shift
- echo "ssh -i $SSH_KEY \$@" > /tmp/.git_ssh.$$
- chmod +x /tmp/.git_ssh.$$
- export GIT_SSH=/tmp/.git_ssh.$$
- fi
- # in case the git command is repeated
- [ "$1" = "git" ] && shift
- # Run the git command
- git "$@"
nginx的配置文件:
sudo vim /etc/nginx/nginx.conf
启动nginx:
sudo nginx -c /etc/nginx/nginx.conf
配置文件核心内容:
server {
listen 80;
location /chanjet {
add_header Access-Control-Allow-Origin *;
root /opt/yunyingyong/mainsite/mainsite/src/web_js/www;//web根目录
}
location /chanjet/customer {
proxy_pass http://172.18.22.170:8080/chanjet/customer;
#proxy_redirect off ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
proxy_pass http://172.18.22.170:8080;
#proxy_redirect off ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
apache 的配置文件:
/etc/apache2/apache2.conf
启动apache:
sudo /etc/init.d/apache2 restart
哪里设置apache的端口号:
在文件/etc/apache2/ports.conf 中:
安装nodejs
安装nodeJS之前,如果没有安装g++及 libssl-dev,则先要安装好,安装方法如下: $ sudo apt-get install g++ $ sudo apt-get install libssl-dev
接下来,就可以下载安装nodeJS了,目前稳定版本为 Node.js 0.6.18,下面是安装步骤: $ wget http://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz $ tar zxvf node-v0.8.16.tar.gz
cd node-v0.8.16/
$ ./configure $ make && make install
安装好后,在 控制台下输入: $ node -v v0.8.16 即可看到安装好的nodeJS版本号。
推荐安装nodejs 的方式:
sudo apt-get install nodejs
查看版本:
ohuangweii@dev-official-website01-v-o:/opt/yunyingyong/mainsite/mainsite/src/web_js/www/chanjet$ nodejs -v
v0.10.37
安装less
npm install -g less
启动svn服务器:
svnserve -d -r /opt/svn/repositories