Posts
bash.bashrc与profile
之前装bash-completion时就发现不能自动加载,后来在~/bashrc里加了启动。
后来用rvm也没有自动加载,每次都是启动之后再
source /etc/profile.d/rvm.sh
才装载上
观察/etc/profile里有自动加载/etc/profile.d/这个目录里的sh文件
还发现,就是在gnome登录后,打开窗口下的终端时,不能加载/etc/profile和~/bash_profile的内容。
ctrl + alt + F1的控制台中是自动加载的。
应该是profile等文件的内容只在交互式登录环境中其作用。
为了在gnome中的终端中也其作用,于是把/etc/profile里加载/etc/profile.d的内容复制一份到/etc/bash.bashrc中。
再在gnome中的终端中,这些配置就加载了。
Posts
bind9默认不能查询,反解
全aptitude安装
之前的域控服务器挂了导致dns也完了。
终于有有机会不得不弄个dns服务。
发现bind9默认会不允许其他主机进行dns查询
原来需要在其named.conf.options中添加
acl allowed {10.0.0.0/24;};
options {
allow-query {allowed};
}
允许某个ip段访问才可。
很久以后,之前用git都没事,后来用capistrano自动部署的时候被fail2ban ban
发现auth.log里有
POSSIBLE BREAK-IN ATTEMPT
说是ip没有做反解。
在named.conf.default-zones里加上
zone “0.168.192.in-addr.arpa” {
type master;
file “/etc/bind/db.domain”;
};
这里ip要反写.
然后在db.domain里加上
3 IN PTR www.domain.com.
域名最后要有一个.
bind reload之后 nsloopup 一下应该就能反解了。了
Posts
iis7 win2008R2 64
折腾两天没弄出来,原来是32位兼容问题,我连盗版不稳定性都考虑了,看了下面这个解决的。
http://blog.verypod.com/windows7-64-php-mysql-issue/
Posts
nagios fcgiwrap
网上N多到处copy的文章,统统都用一个perl的nginx-fcgi脚本来启动。
找了很多还都失效了,或者报错说语法错误。
后来也找了个有效的
不过最终找了个有用的文
http://vladgh.com/blog/nagios-nginx-ubuntu
用fcgiwrap管理cgi,方便。
apt 安装 nagios3之后,没有 /var/lib/nagios3/rw/nagios.cmd文件
需要修改/etc/nagios3/nagios.cfg
check_external_commands=1
之后service nagios3 restart 就会生成这个文件了,在npc中用到。
nagios的网站根目录在/usr/share/nagios3/htdocs
设置好之后会访问会有一些css和js文件丢失的情况,需要自己建立软链接,其中images应该在 /etc/nagios3/images
以下是我的nginx的配置,因为debian版本的升级,nagios的路径改了一些所以这个网站也要相应的改一些。
cgi那里根据配置已经不用redirect了。
本次更改,debian wheezy已经升级为稳定版了。
server {
listen 80;
server_name monitor.com;
access_log /var/log/nginx/monitor.log;
location / {
location ~ .cgi$ {
root /usr/lib;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location ~ ^nagios3 {
root /usr/share/nagios3/htdocs;
}
root /usr/share/nagios3/htdocs;
index index.php;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
client_max_body_size 100m;
location ~ .php$ {
Posts
debian cacti snmpdiskio
下载了snmpdiskio这个插件,按里面README走
最新版可能是0.9.6,但是到处都找不到了,其实用不到0.9.6也一样用。当前的服务器已经是3.2.0.4版本的内核,debian wheezy已经成stable了的时候了。
在被监控机器上的 /etc/snmp/snmpd.conf里加上了
extend .1.3.6.1.4.1.2021.54 hdNum /usr/local/bin/snmpdiskio hdNum
extend .1.3.6.1.4.1.2021.55 hdIndex /usr/local/bin/snmpdiskio hdIndex
extend .1.3.6.1.4.1.2021.56 hdDescr /usr/local/bin/snmpdiskio hdDescr
extend .1.3.6.1.4.1.2021.57 hdInBlocks /usr/local/bin/snmpdiskio hdInBlocks
extend .1.3.6.1.4.1.2021.58 hdOutBlocks /usr/local/bin/snmpdiskio hdOutBlocks
在
http://public.itmatrix.eu/Cacti_templates/Disk_IO
wget http://public.itmatrix.eu/Cacti_templates/Disk_IO/partition.xml
然后更改文件
将<index_order>hdDescr:hdName:hdIndex</index_order>
这行 hdName: 去掉
wget http://public.itmatrix.eu/Cacti_templates/Disk_IO/snmpdiskio
install -m 0755 -o root -g root -p -v snmpdiskio /usr/local/bin/
在监控端用
snmpwalk -v2c -c public 192.168.0.10 .1.3.6.1.4.1.2021.54
如果配置的是v3的验证
snmpwalk -v3 -u uuu -l auth -a MD5 -A pppppppp 1.
Posts
lvm加密分区
装好cryptsetup
以装好lvm为前提进行以下操作。
若分区不存在则
cryptsetup create home /dev/vg/home
若已经建立lvm分区则
cryptsetup luksFormat /dev/vg/home
让输入密码就输
完成之后的这个新盘的数据会被清空,加密分区就做好了。
打消了我之前以为可以把普通分区无损转成加密分区的幻想…
需要挂载时
cryptsetup luksOpen /dev/vg/home home
就会建立/dev/mapper/home的映射,或者自己起的其他名字的什么映射,必须通过映射名称来格式化和挂载。
完成之后
mkfs.ext4 /dev/mapper/home
或者用其他需要的分区命令格式化
然后mount这个映射就可以了,例如
mount /dev/mapper/home /home
若需要开机自动挂载
则还需要一个key文件
比如在 vim /root/home
内容是11111111或者其他什么字符串就成
然后
cryptsetup luksAddKey /dev/vg/home /root/home
添加了密钥
需要修改/etc/crypttab文件
home /dev/vg/home /root/home luks
这样应该就可以自动启动挂载了
不过我这启动时有个报错,启动之后用着也没影响
FATAL: Error inserting padlock_sha (/lib/modules/2.6.32-5-amd64/kernel/drivers/crypto/padlock-sha.ko): No such device
google说是内核bug,之后的升级应该能修正
后来我把 padlock-sha加到 /etc/modprob.d/blacklis.conf里
还有warning 报错,说那个key文件是明文,不过总算舒服点,也妨碍使用。
如果不使用密钥加载则修改 /etc/crypttab文件的第三列为 none ,如下
home /dev/vg/home none luks
就会在开机加载该分区时提示让输入密码,还是这样好些,我最后就是这么设置的。
Posts
nginx passenger rails
前几天去面试,有个题目是关于passenger的
我写没用过,用的是unicorn + nginx
回来之后觉得passenger实在是有必要研究一下
先gem install passenger
然后装nginx的模块
默认编译和我原来的apt装的差了好多参数
选2自己加参数,用nginx -V看看原来的参数,把合适的都加进去,默认路径就/opt/nginx好了
参数如下
–conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-client-body-temp-path=/var/lib/nginx/body –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –http-log-path=/var/log/nginx/access.log –http-proxy-temp-path=/var/lib/nginx/proxy –lock-path=/var/lock/nginx.lock –pid-path=/var/run/nginx.pid –with-http_geoip_module –with-http_gzip_static_module –with-http_realip_module –with-http_stub_status_module –with-http_sub_module –with-mail –with-mail_ssl_module
按编译完的提示在nginx.conf里加上
passenger_root /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11;
passenger_ruby /usr/bin/ruby1.9.1;
编译好之后把 cp /opt/nginx/sbin/nginx /usr/sbin/nginx里,就直接用了,配置文件什么的都原来的位置
在网站的配置里把我原来的unicorn的配置注释掉
加上 passenger_enabled on;
编译完了之后启动说少了libpcre.so.0
aptitude install libpcre++0
启动之后说
git://github.com/galetahub/simple-captcha.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
bundle install 还不管用
搜了搜
用 bundle install –path vendor/
把所有环境都集成到程序里
Posts
startssl https
想从startssl申请个公网的证书,注册了也提出了申请,在选择域名的时候发现没有dyndns.info这个域名。
写信过去要求申请添加这个域名,果然过了小半天如网上所说的那样,人家服务态度很好,把不能添加的原因给我发过来了,这个域名不支持whois服务,所以无法添加…
免费的东西就泵抱怨了,残念…
Posts
rails3 ssl https
给项目的登录页面做个https认证,登录后还跳转回http的页面。
先让nginx支持ssl
在网站的配置文件中的server {…} 之前加入
map $scheme $fastcgi_https { ## Detect when HTTPS is used
default off;
https on;
}
server {} 内加入
fastcgi_param HTTPS $fastcgi_https;
参考http://www.quany.info/web-design/nginx-400-bad-request-the-plain-http-request-was-sent-to-https-port.html
其他ssl 的配置参考
http://www.linuxidc.com/Linux/2011-09/44187.htm
后来出现了400错误
The page isn’t redirecting properly
试了几回,把 server {} 里的
ssl on;
去掉就好了
只要同时 listen 80;
listen 443; 就行了
然后在程序里的验证身份中
redirect_to url_for(…., :protocol => ‘https’)
这样写,验证完的跳回80端口 :protocol => ‘http’
看rails的配置里,需要在confit/application.rb中加入
config.force_ssl = true
我加了之后出现页面循环重定向错误,后来把这个去掉了也没什么问题,觉得不用加这个。