Archive for the ‘Tech’ Category

Configuring OpenSSH Server and Client

最近在研究用Vlad部署php项目。期间需要设置ssh自动登录。

######Server Side######

###安装openssh-server
#apt-get install openssh-server

###修改sshd的配置
#vim /etc/ssh/sshd_config
###为了提高客户端登录的速度,注释掉如下两行
#GSSAPIAuthentication yes
#GSSAPIDelegateCredentials no
###设置可以使用证书登录,修改/加入如下几行
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
###重新启动
#/etc/init.d/ssh restart

###切换到可以通过SSH登录的用户
#su gucheng
###使用ssh-keygen这个工具生成公钥和私钥
$ssh-keygen
Enter passphrase (empty for no passphrase):   #如果输入了密码,需要客户端用代理程序ssh-agent来避免每次输入密码
Enter same passphrase again:
###切换到用户的.ssh目录下
$cd ~/.ssh
###重命名id_rsa.pub这个公钥存放文件为sshd_config中设置的AuthorizedKeysFile的名称,即:authorized_keys
$mv id_rsa.pub authorized_keys
###将私钥~/.ssh/id_rsa拷贝出来
###save file “~/.ssh/id_rsa ” and delete it.
$rm id_rsa

######Client Side######

###将从服务器上保存的id_rsa文件复制到本地(可以重命名)
###路径为: /home/gucheng/.ssh/id_rsa

###使用ssh-add 将私钥文件”id_rsa”添加到ssh-agent
$ ssh-add id_rsa
Could not open a connection to your authentication agent. #如果出现这句,说明ssh-agent没有正常运行
###启动ssh-agent。(使用 eval是为了执行 ssh-agent 输出的设置环境变量的 bash 命令,以确保 ssh-add 可以通过 SSH_AUTH_SOCK 环境变量找到 ssh-agent。from:rainux)
$ eval `ssh-agent`
Agent pid 3513
###重新添加
$ ssh-add id_rsa
Enter passphrase for id_rsa: #输入刚才输入的 passphrase
Identity added: id_rsa (id_rsa) #添加成功

###登录Server
$ssh gucheng@gucheng.me

也可以在Client Side使用ssh-keygen生成公钥和私钥,然后将生成的公钥文件中的内容添加到Server Side的 AuthorizedKeysFile(authorized_keys)文件中即可。

计算机编程发展史(图)

计算机编程的世界

计算机编程的世界

Configuring Nginx HTTP Basic Authentication

Step1:
使用Apache的密码生成工具生成密码(输出到屏幕,具体参数用htpasswd -h查看)
#htpasswd -nb username password
username:TPLoa.pL/PZtQ

Step2:
生成或编辑密码配置文件
#vim /var/www/htpasswd.conf
将Step1生成的那行(即”username:TPLoa.pL/PZtQ”)拷贝进来,save.
修改密码配置文件所有者
#chown www:www /var/www/htpasswd.conf

Step3:
编辑nginx配置文件(如果虚拟主机配置文件独立出来了,那就编辑要认证的虚拟主机的配置文件)
#vim /usr/local/nginx/conf/nginx.conf
在Server段的location节中加入如下两行
######
auth_basic “Restricted”;
auth_basic_user_file /var/www/htpasswd.conf;
######

Step4:
测试nginx配置文件是否有语法错误
#/usr/local/nginx/sbin/nginx -t
平滑重启nginx(适用于nginx 0.8.x版本)
#/usr/local/nginx/sbin/nginx -s reload

推荐三款原型设计工具

最近在做一些设计方面的工作,所以会用到一些画图方面的工具。以下几个自己用着感觉还不错,既简单有方面,该有的功能也都有,在这里推荐一下。

Balsamiq Mockups

这是我正在使用的,操作很方便,直接拖控件就可以了,完成后可以导出成PNG或PDF。风格是手绘的。缺点是不支持中文,还有控件不是很全,不过一般的都够用了。还有就是如果要注册码,你可以帮忙做一下推广就可以申请了。安装前先装AIR。

homepage: http://www.balsamiq.com/

Axure RP Pro

Axure RP is the leading tool for rapidly creating wireframes, prototypes and specifications for applications and web sites. Quickly get the benefits of prototyping without a lot of hassle.

homepage: http://www.axure.com
要做高保真DEMO就用它,要找破解的,Google就可以。

Pencil

Pencil is a free and opensource tool for making diagrams and GUI prototyping that everyone can use.

用Firefox的可以用,它是一个firefox的插件。

homepage: http://www.evolus.vn/pencil/

project url: http://code.google.com/p/evoluspencil/

Configuring Lighttpd for CakePHP

关于cakephp在lighttpd中用到的配置, 网上找到的:

$HTTP["host"] =~ "^(www\.)?example.com" {
        server.document-root = "/var/www/vhost/example.com/app/webroot/"
        url.rewrite = (
                "/(.*)\.(.*)" => "$0",
                "/(css|files|img|js)/" => "$0",
                "^/([^.]+)$" => "/index.php?url=$1"
        )
}

但是如果请求有后缀(如:.xml, .rss, …, RequestHander这个Component可以识别并自动使用相应的layout输出),以上的规则就不行了。
可以简单的修改一下:

$HTTP["host"] =~ "^(www\.)?example.com" {
        server.document-root = "/var/www/vhost/example.com/app/webroot/"
        url.rewrite = (
                "(css|files|img|js)/(.*)" => "/$1/$2",
                "^([^\?]*)(\?(.+))?$" => "/index.php?url=$1&$3",
        )
}

公司服务器上测试似乎没问题:)

Return top