Web Digest

还有众多网络文摘,仅供个人收藏和参考

Posts Tagged ‘debian

在Debian6.0上编译vim的command-T插件

leave a comment »

虽然安装了ruby, 结果还是遇到

no such file to load — mkmf

错误。

看了这里才知道

原来还要安装

sudo apt-get install ruby1.8-dev

Written by admin

November 25, 2011 at 5:15 am

Posted in 网站|Site

Tagged with ,

解决E319: Sorry, the command is not available in this version

leave a comment »

这个问题比较简单,可以参考这里

主要是默认安装的vim不完整所致。

安装一个完整版的就可以。

如果内存不是问题,对于Debian, 推荐安装vim-nox,带有python, ruby, perl等脚本的完整支持,再也没有无法使用的插件了

Written by admin

November 25, 2011 at 5:13 am

Posted in 网站|Site

Tagged with ,

XOrg字体配置的人间地狱

leave a comment »

在Debian 6.0上,想不通过Gnome,Xfce之类的大型软件,直接使用i3wm这样的窗口管理器。
结果发现Xorg的字体管理真是让人抓狂。

一般bitmap的字体好像还行。但是一碰到TTF字体,无论如何都在xfontsel中显示不出来。

最后看到这篇文章
才发现
1. 要在/etc/X11/xorg.conf(或者~/.xorg.conf)中添加
Section “Files”
FontPath “/usr/share/fonts/truetype/ttf-iconsolata”

EndSection

2. 在/usr/share/fonts/truetype/ttf-iconsolata目录下
还要执行
mkfontscale
mkfontdir

只有这样才能在xfontsel中显示出来。可是还是有“Missing Characters in String to Fontset conversion. Unable to load any usable fontset”的错误。

即使找到了XLD lable,还是会造成i3wm退出。

xfontsel中的显示也不完整。 xlsfonts | grep iconsolata可以看到完整的字体列表。
但是还是解决不了问题,

后来,看看这里发现一个变通的方法,还能将就着用用

Written by admin

October 30, 2011 at 11:30 am

Posted in 其他|Others

Tagged with

在Debian6.0(Squeeze)上建立基本的WordPress环境详细指南

leave a comment »

1. 创建基本用户环境

以下都基于root权限进行
1)安装基本应用包

<pre>apt-get install vim sudo htop openssh-server build-essential
#如果不准备安装python package或者自行编译其他软件包,
#可以不用安装build-essential,其主要提供gcc link等工具

2)选择默认的编辑器为vim.basic

update-alternatives --config editor

Selection    Path                Priority   Status
————————————————————
* 0            /bin/nano            40        auto mode
1            /bin/ed             -100       manual mode
2            /bin/nano            40        manual mode
3            /usr/bin/vim.tiny   30        manual mode
4            /usr/bin/vim.basic   30        manual mode

或者采用 update-alternatives –set editor /usr/bin/vim 直接更新。 最后确保用户的.bashrc中,添加

export EDITOR=/usr/bin/vim

3)VIM的配置 编辑/etc/vim/.vimrc,

syntax on
set background=dark
set mouse=n
set tabstop=4
set softtabstop=4

下载tComment插件Nginx插件,并分别根据各自文档安装设置完毕 4)改善Bash环境 在/root下创建 .profile文件。前提是Debian已经提供好了.bashrc文件。

if [ "$BASH" ]; then
 if [ -f ~/.bashrc ]; then
 . ~/.bashrc
 fi
fi

mesg n

编辑/root/.bashrc,将其中的色彩和别名部分的注释去掉,并增加一些方便的功能。

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
 eval "`dircolors -b`"
 alias ls='ls --color=auto'
 alias dir='dir --color=auto'
 alias vdir='vdir --color=auto'

 alias grep='grep --color=auto'
 alias fgrep='fgrep --color=auto'
 alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -al'
alias la='ls -A'
alias l='ls -CF'
alias ..='cd ..'
alias ...='cd ...'

#bookmark function
alias show='cat ~/.dirs'
save (){
 command sed "/!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ;
}

5) 添加非root用户,用于ssh登陆

useradd user01 -g adm -p password  #创建user01,其primary group为系统adm组
adduser user01 sudo  #将其加入sudo用户组
adduser user01 staff #将其加入staff用户组
visudo  #其中 添加 user01 ALL=(ALL) ALL

adm用户组主要可以看很多/var/log而不需要sudo。staff用户组便于操作/usr/local。这里有更详细的系统默认用户组介绍 将/root/下的.profile, .bashrc,都拷贝到/home/user01下。然后将客户端的Public Key添加到.ssh/authorized_keys中 6) 编辑/etc/ssh/sshd_config

PermitRootLogin no
PasswordAuthentication no

然后/etc/init.d/sshd restart重启sshd服务,这时候应该就可以用user01登陆了 ,同时可以验证一下root,和密码方式已经不被允许了

2. 准备NGINX,PHP和MySQL

1)Nginx
Debian 6中Nginx已经更新到0.7系列最后的版本了,比较稳定。可以直接apt-get install nginx。
安装完毕后,可以编辑一下/etc/sites-available/default,
将documentroot设为/var/www, 然后去/var/www下创建一个index.html测试一下nginx的服务。
2)Mysql
Debian 6中Mysql也已经升级到5.1系列,一般也够用了。可以直接apt-get install mysql-server。
过程中会要求设置数据库的root用户密码。
安装完后,登陆Mysql

mysql -uroot -p密码

然后创建一个wordpress的数据库
CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;
再添加一个非root用户
GRANT ALL PRIVILEGES ON *.* TO alternative_root@localhost IDENTIFIED BY ‘hispassword’;
对于小内存的VPS,需要对/etc/mysql/my.cnf进行完善,特别是skip-innodb可以省下不少内存。
3)Php的fpm功能在5.3版本中才整合过来,需要从第三方源安装,当然也可以参照以前的步骤手工安装。
首先编辑/etc/apt/sources.list, 添加以下两行
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
然后导入dotdeb的公钥,

wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | sudo apt-key add -

再更新一下源列表

apt-get update

随后就可以安装不同的PHP包了。
使用apt-cache search php5 | grep php5可以看到目前可以安装使用的包。

apt-get isntall php5-fpm php5-mysql php5-sohusin php5-apc

其中fpm提供基于fcgi的进程管理,mysql提供与数据库的借口,sohusin加强核心组建的安全,apc提供op code级的缓存,都是必须的。
然后编辑/etc/php5/fpm下的php.ini,主要是启用apc,并确保
expose_php = Off
allow_url_fopen = Off
allow_url_include = Off
在修改/etc/php5/fpm下的fpm.ini,主要是限制一下php的进程数量。

全部就绪后可以,去/etc/nginx/sites-enabled下再创建一个php-basic.conf,

server {
 listen      80;

location / {
 root   /var/www/;
 index  index.php;
 }

 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 #
 location ~ \.php$ {
 root /var/www/;
 fastcgi_pass   127.0.0.1:9000;
 fastcgi_index  index.php;
 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
 include        /etc/nginx/fastcgi_params;
 }
}

再创建一个/var/www/index.php文件
<?php phpinfo(); ?>
如果这个页面可以正常打开,那么基本上就没有问题了。

3. 防火墙以及Fail2ban

编辑 iptables.sh脚本,然后chmod +x iptables.sh。并在/etc/rc.local中加入该脚本


iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X

iptables -P INPUT   ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT  ACCEPT

LO_IF=venet0
SELF_IP= *.*.*.*

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o $LO_IF -j SNAT --to $SELF_IP
#Need this line to enable VPN if default forward chain is drop
iptables -A FORWARD -d 10.8.0.0/24 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i tap+ -j ACCEPT
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tap+ -j ACCEPT
iptables -A FORWARD -i tun+ -j ACCEPT
iptables -A INPUT -p tcp -i $LO_IF --dport ssh -j ACCEPT
#Open ports for OpenVPN
iptables -A INPUT -p udp -i $LO_IF --dport 1194 -j ACCEPT
iptables -A INPUT -p tcp -i $LO_IF --dport 1194 -j ACCEPT
iptables -A INPUT -p tcp -i $LO_IF --dport 80 -j ACCEPT

iptables -A INPUT -p ICMP --icmp-type echo-request -m limit --limit 10/minute --limit-burst 20 -j ACCEPT

iptables -A INPUT -j LOG --log-prefix "Unhandled INPUT Dropped - "
iptables -A INPUT -j DROP
iptables -A FORWARD -j LOG --log-prefix "Unhandled FORWARD Dropped - "
iptables -A FORWARD -j DROP

然后apt-get install fail2ban

默认检测sshd的入侵一般也就可以了,需要的话,可以再启动sshd-ddos以及openvpn的jail。一般Openvpn也会加入tls的握手要求,所以不用太担心。

4. Python相关包的安装。
Debian 6的默认Python已经升级到了Python 2.6.6,而且提供了大量已经编译打包好的第三方Package,一般是不在需要用easy_install了。

1) Pyxmpp。直接apt-get install python-pyxmpp

Debian 6 最贴心的地方就是这些第三方包都有现成的deb可以用,自己安装的话libxml2的编译就很成问题。

2)BeautifulSoap。也可以直接安装3.1版的,apt-get install python-beautifulsoap。

Written by admin

February 15, 2011 at 12:48 am

Debian设置Bash色彩

leave a comment »

不知道Debian是怎么想的,默认安装后,明明都配置了.bashrc文件,但是却省略了~/.profile文件,以至于.bashrc都没有效果。无论是Debian 5还是最新的Debian 6 都是如此。

需要在/root以及其他用户的主目录下,创建这个文件,

# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
 if [ -f ~/.bashrc ]; then
 . ~/.bashrc
 fi
fi

mesg n

Written by admin

February 13, 2011 at 12:50 am

Posted in 网站|Site

Tagged with

从Debian 5升级到Debian 6

leave a comment »

都说Debian升级平滑,其实也不尽然。

Lindoe有一个说明,但是仍然遇到问题。

1. GNUPG Key过期

W: GPG error: http://security.debian.org squeeze/updates Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY AED4B06F473041FA
W: GPG error: http://ftp.debian.org squeeze Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 9AA38DCD55BE302B

通过apt-get install debian-archive-keyring解决

2. insserv: warning: script ‘S10vzquota’ missing LSB tags and overrides, insserv: warning: script ‘vzquota’       │
│ missing LSB tags and overrides,

有个德国人有办法,手工编辑/etc/init.d/openvz 脚本,在开头添加以下注释,

#!/bin/sh
### BEGIN INIT INFO
# Provides: vzquota
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start vzquota at the end of boot
# Description: This command is used to configure and see disk quota statistics for Containers.
### END INIT INFO

就可以了。

然后运行

dpkg-reconfigure sysv-rc

可以解决

这个问题似乎还是不去解决得好

Written by admin

February 12, 2011 at 11:22 am

Posted in 网站|Site

Tagged with