git仓库与裸仓库

2014年11月14日 11:32

创建仓库

git init 本地仓库,包含.git目录和工作目录
[wyq@localhost blog.git]$ git init
重新初始化现存的 Git 版本库于 /home/wyq/workspace/blog.git/.git/
[wyq@localhost blog.git]$ ls -a
.  ..  .git

创建裸仓库

git init --bare 裸仓库,只有.git目录下的内容.
[wyq@localhost blog.git]$ git init --bare
初始化空的 Git 版本库于 /home/wyq/workspace/blog.git/
[wyq@localhost blog.git]$ ls -a
.   branches  description  hooks  objects
..  config    HEAD         info   refs
适合作为服务器仓库.

相互转换

git clone --bare 从仓库导出bare仓库
git clone 从bare仓库导出仓库
 
如果服务仓库以git init仓健,当用户向它提交代码时,会出现
Writing objects: 100% (3/3), 236 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /home/wyq/workspace/blog.git
 ! [remote rejected] master -> master (branch is currently checked out)
解决办法是使用git clone --bare 克隆出.git内容作为服务器仓库.
 

Tags: git;bare
评论(157) 阅读(5581)

如何给在用的nginx添加新模块?

2014年11月13日 11:29

有一个在用的nginx,以yum方法安装的,怎样在不改动配置的情况下,为它添加模块.
以添加spdy模块为例.

编译新模块

预编译
./configure  --prefix=/etc/nginx \
   --sbin-path=/usr/sbin \
   --conf-path=/etc/nginx/nginx.conf \
   --pid-path=/run/nginx.pid  \
   --error-log-path=/var/log/nginx/error.log \
   --with-http_spdy_module \
   --with-http_ssl_module \
   --with-ipv6 
--sbin-path, --pid—path, --conf—path,--erro—path三个参数是设定默认配置路径.
如果旧的nginx不是以/usr/local/nginx为安装路径,则需要指定上面参数,可以在旧nginx的nginx.conf文件中取到.
 
编译
make之后复制

验证新nginx是否可用

验证编译后的nginx是否可以使用已有的配置
./obj/nginx -t

使用新nginx

备份 cp /usr/sbin/nginx /usr/sbin/nginx-bak
替换 cp ./obj/nginx /usr/sbin/nginx
ok了
 

评论(30) 阅读(5060)

nginx启用spdy支持

2014年11月13日 10:48

安装nginx

预编译时加入spdy模块,spdy强制使用ssl,需要同时编入ssl模块
./configure --with-http_ssl_module --with-http_spdy_module
 
make 编译之后输出下面信息,nginx默认安装到/usr/local/nginx目录
[wyq@localhost nginx-1.6.2]$ make
make -f objs/Makefile
make[1]: 进入目录“/home/wyq/nginx-1.6.2”
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
....
make[1]: 离开目录“/home/wyq/nginx-1.6.2” make -f objs/Makefile manpage make[1]: 进入目录“/home/wyq/nginx-1.6.2” sed -e "s|%%PREFIX%%|/usr/local/nginx|" \ -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \ -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \ < man/nginx.8 > objs/nginx.8 make[1]: 离开目录“/home/wyq/nginx-1.6.2”

make install 安装

准备数字证书

使用下面命令,生成自己的证书
openssl genrsa -des3 -out openssl.key 1024  
openssl req -new -x509 -key openssl.key -out openssl.crt -days 3650  
openssl rsa -in openssl.key -out openssl_nopass.key  
详细参考
http://yongqing.is-programmer.com/posts/68856.html
或者用我的证书,证书密码:word

添加配置

server{
    ...
    listen 443 ssl spdy;
    ssl_certificate /home/wyq/ssl/openssl.crt;
    ssl_certificate_key /home/wyq/ssl/openssl_nopass.key;
    ...
}

启动nginx

./sbin/nginx

查看spdy启动情况

使用chrome浏览器访问https://localhost,并打开 chrome://net-internals/#spdy 看到下面内容,表示spdy已经开启
Host Proxy ID Protocol Negotiated Active streams Unclaimed pushed Max Initiated Pushed Pushed and claimed Abandoned Received frames Secure Sent settings Received settings Send window Receive window Unacked received data Error
localhost:443 direct:// 65438 spdy/3.1 0 0 100 1 0 0 0 2 true true true 2147483647 10485760 612 0
 

Tags: spdy;ssl;
评论(0) 阅读(3543)

SSL数字证书生成方法

2014年11月13日 09:31

安装openssl

yum install openssl

生成密钥

openssl genrsa -des3 -out openssl.key 1024  
[wyq@localhost ssl]$ openssl genrsa -des3 -out openssl.key 1024
Generating RSA private key, 1024 bit long modulus
..............++++++
...............++++++
e is 65537 (0x10001)
Enter pass phrase for openssl.key:  (输入密码)
Verifying - Enter pass phrase for openssl.key: (确认输入输入密码)

生成证书

openssl req -new -x509 -key openssl.key -out openssl.crt -days 3650  
[wyq@localhost ssl]$ openssl req -new -x509 -key openssl.key -out openssl.crt -days 3650
Enter pass phrase for openssl.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:cn (国家)
State or Province Name (full name) []:hubei (省份)
Locality Name (eg, city) [Default City]:wuhan (城市)
Organization Name (eg, company) [Default Company Ltd]:aa (公司)
Organizational Unit Name (eg, section) []:it (部门)
Common Name (eg, your name or your server's hostname) []:wyq (名字)
Email Address []:562798392@qq.com (邮件地址)

不用密码的密钥

openssl rsa -in openssl.key -out openssl_nopass.key  
[wyq@localhost ssl]$ openssl rsa -in openssl.key -out openssl_nopass.key 
Enter pass phrase for openssl.key: (输入上面设定的密码)
writing RSA key

开启nginx的ssl

server{
    ....
    listen 443 ssl;
    ssl_certificate /home/wyq/ssl/openssl.crt;
    ssl_certificate_key /home/wyq/ssl/openssl_nopass.key;
    ....
}
访问https://localhost 出现"Welcome to nginx ...",好了,配置成功.
 
 

Tags: openssl;数字证书;
评论(0) 阅读(3031)

debian安装nginx 1.6方法

2014年11月10日 15:46

安装

  • apt-get upgrade更新系统。由于nginx 1.6会用到最新包,最好先更新系统。
  • 添加dotdeb源
打开/etc/apt/sources.list在头部添加下面两行
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
  • 运行apt-get install nginx升级nginx
     默认不会覆盖已有的nginx配置
  • nginx -s reload重启gninx

可能出现缺少公钥错误

  • 运行apt-get update出现提示
Reading package lists... Done
W: GPG error: http://packages.dotdeb.org stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E9C74FEEA2098A6E
  • 解决办法:
运行下面两个命令
gpg --keyserver keys.gnupg.net --recv-key A2098A6E
gpg -a --export A2098A6E | apt-key add -
命令中的"A2098A6E",是错误提示"E9C74FEEA2098A6E"的后8位
 

Tags: debian;nginx;dotdeb
评论(1) 阅读(2705)

添加dotdeb源后出现:由于没有公钥,无法验证下列签名: NO_PUBKEY E9C74FEEA2098A6E

2014年11月10日 14:55

在添加dotdeb源后,执行apt-get update出现提示
忽略 http://packages.dotdeb.org stable/all Translation-en                      
命中 http://mirrors.163.com wheezy-updates/main amd64 Packages/DiffIndex       
命中 http://mirrors.163.com wheezy-updates/main Translation-en/DiffIndex       
下载 836 B,耗时 18秒 (44 B/s)                                                 
正在读取软件包列表... 完成
W: GPG 错误:http://packages.dotdeb.org stable Release: 由于没有公钥,无法验证下列签名: NO_PUBKEY E9C74FEEA2098A6E
 
解决办法
执行下面两条命令
gpg --keyserver keys.gnupg.net --recv-key A2098A6E
gpg -a --export A2098A6E | apt-key add -
命令中的"A2098A6E",是错误提示"E9C74FEEA2098A6E"的后8位

Tags: debian;apt-get;dotdeb
评论(0) 阅读(3177)

apt-get包管理工具

2014年11月06日 15:51

什么是apt-get

    apt(the Advanced Packaging Tool)是debian,ubuntu发行版的包管理工具,与红帽中的yum工具非常类似。

基本用法

* 搜索包 apt-cache search
* 获取包信息 apt-cache show
* 安装 apt-get install packagename
* 卸载 apt-get remove packagename
* 更新源 apt-get update
* 更新已安装的包 apt-get upgrade
* 升级系统 apt-get dist-upgrade
* 下载包的源代码 apt-get source packagename

镜像源

apt-get通过镜像源获得软件包
镜像源配置文件:/etc/apt/sources.list
 
网易镜像源
搜狐镜像源
阿里镜像源
 
sources.list有多个版本,不要下错版本
etch    -- debian 4.x
lenny   -- debian 5.x
squeeze -- debian 6.x
wheezy  -- debian 7.x

debian版本

版本 代号    发布日期  
1.1  Buzz   1996年6月17日 
1.2  Rex    1996年12月12日
1.3  Bo     1997年6月2日
2.0  Hamm   1998年7月24日
2.1  Slink  1999年3月9日
2.2  Potato 2000年8月15日
3.0  Woody  2002年7月19日
3.1  Sarge  2005年6月6日 
4.0  Etch   2007年4月8日
5.0  Lenny  2009年2月14日
6.0  Squeeze 2011年2月6日 
7.0  Wheezy 2013年5月5日
8.0  Jessie 尚无确切时间表
 
 

Tags: debian;
评论(7) 阅读(1551)

JSTL日期格式化

2014年11月06日 12:18

引入标签库

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

用法

<fmt:formatDate value="${DATE}"    pattern="yyyy-MM-dd HH:mm:ss" type="date" dateStyle="long" /> 
 

Tags: jsp
评论(0) 阅读(1621)

forEach迭代列表与整数

2014年11月06日 11:18

整数迭代

<!-- 简单示例 -->
<c:forEach var="i" begin="1" end="10" step="1"> 
    <c:out value="${i}" />
</c:forEach>

<!-- 传入变量 -->
<c:forEach var="i" begin="1" end="$(totalPage)" step="1"> 
    <c:out value="${i}" />
</c:forEach>

列表迭代

<!-- experts是个List<Map>-->
<c:forEach items="${experts}" var="expert" varStatus="status" begin="0" end="9">
    <tr>
    <td>${status.index+1}</td>
    <td><img src="${expert.headImagePath}"/></td>
    <td>${expert.expertName}</td>
    <td>${expert.phone}</td>
    <td>${expert.address}</td>
    <td>${expert.expertIntroduction}</td>
    <td>${expert.createTime}</td>
    <td data-expertid="${expert.expertID}">
    </tr>
</c:forEach>

参数说明

items 被迭代的列表(迭代整数时不用设置)
begin 开始的元素(0=第一个元素,1=第二个元素)
end最后一个元素(0=第一个元素,1=第二个元素)
step每次迭代的步长
var 当前条目的变量名称
varStatus 循环状态的变量名称(可以获取序列号)
 

Tags: jstl;迭代
评论(10) 阅读(2482)

shadowsocks简易代理

2014年9月11日 11:12

以下是运行在windows的简易shadowsocks
帐号可从以下地方获取
配置信息示例
{
    "server":"208.110.83.242",  //服务器ip
    "server_port":43202,        //服务端口
    "local_port":1080,          //本地端口
    "password":"sonydafahaoMA", //用来加密的密码
    "timeout":600,              //超时时间
    "method":"aes-256-cfb"      //加密方法
}
  • 运行boafanx-ss.exe
代理已经启动启动,接下来就可以使用代理了,下面以chrome浏览器为例
  • chrome使用代理
首先chrome需要安装了switchysharp插件.
然后设置代理 socks5 127.0.0.1 1080 
再设置切换规则 *.google.com* 通配符 shadowsocks
  • privoxy.exe可以将socks代理转换成http代理
 
 

Tags: 代理;shadowsocks
评论(1) 阅读(5736)