在/etc/timezone里面写上中国的时区,Asia/Shanghai,在/etc/default/rcS里面把UTC设成yes,也就是用 utc,这是Debian推荐做法。最后也是最重要的,把/etc/localtime删除,再从/usr/share/zoneinfo/Asia里面拷贝Shanghai这个文件到/etc下,名字还是localtime。这样做完,不需重启,过会就自己生效了。
Tag: ubuntu
2011年07月17日
2011年07月15日
Ubuntu 9.04 server用apt安装nginx并配置php(fastcgi)
由于Ubuntu 904已经包含了nginx,所以根本不要编译,安装超简单!
修改/etc/apt/sources.list文件内容为国内镜像,然后运行:
apt-get update
apt-get install nginx
即可完成安装
启动nginx:
/etc/init.d/nginx start
然后就可以访问了,http://localhost/ , 一切正常!如果不能访问,先不要继续,看看是什么原因,解决之后再继续。
下面配置php和mysql。
安装php和MySQL:
apt-get install php5-cli php5-cgi mysql-server-5.0 php5-mysql
我们需要/usr/bin/spawn-fcgi这个文件,而它是属于lighttpd这个包里面的,所以我们安装lighttpd然后把它设置为开机不启动:
apt-get install lighttpd #我们只要/usr/bin/spawn-fcgi
rcconf #去掉lighttpd开机自启动
修改nginx的配置文件:/etc/nginx/sites-available/default
修改 server_name 58.30.17.154;
修改index的一行修改为:
index index.php index.html index.htm;
去掉下面部分的注释:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
重新启动nginx:
/etc/init.d/nginx stop
/etc/init.d/nginx start
启动fastcgi php:
spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi
为了让php-cgi开机自启动:
cd /etc/init.d
cp nginx php-cgi
vim php-cgi
替换nginx为php-cgi
并修改相应部分为:
DAEMON=/usr/bin/spawn-fcgi
DAEMON_OPTS=”-a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi”
…
stop)
echo -n “Stopping $DESC: ”
pkill -9 php-cgi
echo “$NAME.”
然后运行rcconf设置php-cgi为开机自启动
在/var/www/nginx-default/目录下创建一个文件:
echo ‘< ?phpinfo();?>’ > /var/www/nginx-default/index.php
然后浏览器访问nginx就可以看到一切正常了
2011年05月19日
简单几步搞定ubuntu 配置开机启动vnc server
在 /etc/init.d 目录下谢一个脚本vnc.sh,内容如下:
#!/bin/bash
vncserver -geometry 1440×900
然后执行:
update-rc.d vnc.sh defaults
只需两步就可以让vnc在系统启动时启动
查看开机启动配置:
chkconfig –list
chkconfig –add xxx
chkconfig –del xxx
2011年05月5日
ubuntu安装学习nginx笔记
nginx发布了1.0版本,就安装最新版本吧。
在新安装好的ubuntu下发现很多依赖还需要自己手动安装。
1.zlib 官网好像被墙了,我把1.2.5版本传上来,以备后用,下载
2.pcre 下载
3.openssl 默认已经安装好了,所以不需要再安装了
把nginx 1.0.1下载完后解压。http://nginx.org/en/download.html
./configure –prefix=/etc/nginx
make
sudo make install
安装完成,默认安装的路径是/usr/local/nginx,我在配置的时候改为/etc/nginx了
更多的安装配置
./configure –prefix=/usr/local/nginx
–with-openssl=/usr/include (启用ssl)
–with-pcre=/usr/include/pcre/ (启用正规表达式)
–with-http_stub_status_module (安装可以查看nginx状态的程序)
–with-http_memcached_module (启用memcache缓存)
–with-http_rewrite_module (启用支持url重写)
三、启动及重启
启动:nginx
重启:kill -HUP `cat /etc/nginx/logs/nginx.pid`
测试配置文件:nginx -t
简单吧,安装,启动都比较方便。
四、配置文件
http://wiki.codemongers.com/NginxFullExample
#运行用户
user nobody nobody;
#启动进程
worker_processes 5;
#全局错误日志及PID文件
error_log logs/error.log notice;
pid logs/nginx.pid;
#工作模式及连接数上限
events {
#工作模式有:select(标准模式),poll(标准模式),kqueue(高效模式,适用FreeBSD 4.1+, OpenBSD 2.9+, NetBSD 2.0 and MacOS X),
#epoll(高效模式,本例用的。适用Linux 2.6+,SuSE 8.2,),/dev/poll(高效模式,适用Solaris 7 11/99+, HP/UX 11.22+ (eventport), IRIX 6.5.15+ 和 Tru64 UNIX 5.1A+)
use epoll;
worker_connections 1024;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
#设定mime类型
include conf/mime.types;
default_type application/octet-stream;
#设定日志格式
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
log_format download '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$http_range" "$sent_http_content_range"';
#设定请求缓冲
client_header_buffer_size 10k;
large_client_header_buffers 4 4k;
#开启gzip模块,要求安装gzip 在运行./config时要指定
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
#设定访问日志
access_log logs/access.log main;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
#设定负载均衡的服务器列表
upstream backserver {
#weigth参数表示权值,权值越高被分配到的几率越大
#本例是指在同一台服务器,多台服务器改变ip即可
server 127.0.0.1:8081 weight=5;
server 127.0.0.1:8082;
server 127.0.0.1:8083;
}
#设定虚拟主机,默认为监听80端口,改成其他端口会出现问题
server {
listen 80;
server_name test.com www.test.com;
charset utf8;
#设定本虚拟主机的访问日志
access_log logs/test.com.log main;
#如果访问 /images/*, /js/*, /css/* 资源,则直接取本地文件,不用转发。但如果文件较多效果不是太好。
location ~ ^/(images|js|css)/ {
root /usr/local/testweb;
expires 30m;
}
#对 "/" 启用负载均衡
location / {
proxy_pass http://backserver;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
#设定查看Nginx状态的地址,在运行./config 要指定,默认是不安装的。
location /NginxStatus {
stub_status on;
access_log on;
auth_basic "NginxStatus";
#是否要通过用户名和密码访问,测试时可以不加上。conf/htpasswd 文件的内容用 apache 提供的 htpasswd 工具来产生即可
#auth_basic_user_file conf/htpasswd;
}
}
有详细的说明
-----------------------------------
Nginx配置
-
Nginx 使用 Unix 下常用的 ‘./configure && make && make install’ 过程来编译安装。
configure 脚本确定系统所具有一些特性,特别是 nginx 用来处理连接的方法。然后,它创建 Makefile 文件。
configure 支持下面的选项:
–prefix=<path> - Nginx安装路径。如果没有指定,默认为 /usr/local/nginx。
–sbin-path=<path> - Nginx可执行文件安装路径。只能安装时指定,如果没有指定,默认为<prefix>/sbin/nginx。
–conf-path=<path> - 在没有给定-c选项下默认的nginx.conf的路径。如果没有指定,默认为<prefix>/conf/nginx.conf。
–pid-path=<path> - 在nginx.conf中没有指定pid指令的情况下,默认的nginx.pid的路径。如果没有指定,默认为 <prefix>/logs/nginx.pid。
–lock-path=<path> - nginx.lock文件的路径。
–error-log-path=<path> - 在nginx.conf中没有指定error_log指令的情况下,默认的错误日志的路径。如果没有指定,默认为 <prefix>/logs/error.log。
–http-log-path=<path> - 在nginx.conf中没有指定access_log指令的情况下,默认的访问日志的路径。如果没有指定,默认为 <prefix>/logs/access.log。
–user=<user> - 在nginx.conf中没有指定user指令的情况下,默认的nginx使用的用户。如果没有指定,默认为 nobody。
–group=<group> - 在nginx.conf中没有指定user指令的情况下,默认的nginx使用的组。如果没有指定,默认为 nobody。
–builddir=DIR - 指定编译的目录
–with-rtsig_module - 启用 rtsig 模块
–with-select_module –without-select_module - Whether or not to enable the select module. This module is enabled by default if a more suitable method such as kqueue, epoll, rtsig or /dev/poll is not discovered by configure.
//允许或不允许开启SELECT模式,如果 configure 没有找到更合适的模式,比如:kqueue(sun os),epoll (linux kenel 2.6+), rtsig(实时信号)或者/dev/poll(一种类似select的模式,底层实现与SELECT基本相 同,都是采用轮训方法) SELECT模式将是默认安装模式
–with-poll_module –without-poll_module - Whether or not to enable the poll module. This module is enabled by default if a more suitable method such as kqueue, epoll, rtsig or /dev/poll is not discovered by configure.
–with-http_ssl_module - Enable ngx_http_ssl_module. Enables SSL support and the ability to handle HTTPS requests. Requires OpenSSL. On Debian, this is libssl-dev.
//开启HTTP SSL模块,使NGINX可以支持HTTPS请求。这个模块需要已经安装了OPENSSL,在DEBIAN上是libssl
–with-http_realip_module - 启用 ngx_http_realip_module
–with-http_addition_module - 启用 ngx_http_addition_module
–with-http_sub_module - 启用 ngx_http_sub_module
–with-http_dav_module - 启用 ngx_http_dav_module
–with-http_flv_module - 启用 ngx_http_flv_module
–with-http_stub_status_module - 启用 “server status” 页
–without-http_charset_module - 禁用 ngx_http_charset_module
–without-http_gzip_module - 禁用 ngx_http_gzip_module. 如果启用,需要 zlib 。
–without-http_ssi_module - 禁用 ngx_http_ssi_module
–without-http_userid_module - 禁用 ngx_http_userid_module
–without-http_access_module - 禁用 ngx_http_access_module
–without-http_auth_basic_module - 禁用 ngx_http_auth_basic_module
–without-http_autoindex_module - 禁用 ngx_http_autoindex_module
–without-http_geo_module - 禁用 ngx_http_geo_module
–without-http_map_module - 禁用 ngx_http_map_module
–without-http_referer_module - 禁用 ngx_http_referer_module
–without-http_rewrite_module - 禁用 ngx_http_rewrite_module. 如果启用需要 PCRE 。
–without-http_proxy_module - 禁用 ngx_http_proxy_module
–without-http_fastcgi_module - 禁用 ngx_http_fastcgi_module
–without-http_memcached_module - 禁用 ngx_http_memcached_module
–without-http_limit_zone_module - 禁用 ngx_http_limit_zone_module
–without-http_empty_gif_module - 禁用 ngx_http_empty_gif_module
–without-http_browser_module - 禁用 ngx_http_browser_module
–without-http_upstream_ip_hash_module - 禁用 ngx_http_upstream_ip_hash_module
–with-http_perl_module - 启用 ngx_http_perl_module
–with-perl_modules_path=PATH - 指定 perl 模块的路径
–with-perl=PATH - 指定 perl 执行文件的路径
–http-log-path=PATH - Set path to the http access log
–http-client-body-temp-path=PATH - Set path to the http client request body temporary files
–http-proxy-temp-path=PATH - Set path to the http proxy temporary files
–http-fastcgi-temp-path=PATH - Set path to the http fastcgi temporary files
–without-http - 禁用 HTTP server
–with-mail - 启用 IMAP4/POP3/SMTP 代理模块
–with-mail_ssl_module - 启用 ngx_mail_ssl_module
–with-cc=PATH - 指定 C 编译器的路径
–with-cpp=PATH - 指定 C 预处理器的路径
–with-cc-opt=OPTIONS - Additional parameters which will be added to the variable CFLAGS. With the use of the system library PCRE in FreeBSD, it is necessary to indicate –with-cc-opt=”-I /usr/local/include”. If we are using select() and it is necessary to increase the number of file descriptors, then this also can be assigned here: –with-cc-opt=”-D FD_SETSIZE=2048″.
–with-ld-opt=OPTIONS - Additional parameters passed to the linker. With the use of the system library PCRE in FreeBSD, it is necessary to indicate –with-ld-opt=”-L /usr/local/lib”.
–with-cpu-opt=CPU - 为特定的 CPU 编译,有效的值包括:pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
–without-pcre - 禁止 PCRE 库的使用。同时也会禁止 HTTP rewrite 模块。在 “location” 配置指令中的正则表达式也需要 PCRE 。
–with-pcre=DIR - 指定 PCRE 库的源代码的路径。
–with-pcre-opt=OPTIONS - Set additional options for PCRE building.
–with-md5=DIR - Set path to md5 library sources.
–with-md5-opt=OPTIONS - Set additional options for md5 building.
–with-md5-asm - Use md5 assembler sources.
–with-sha1=DIR - Set path to sha1 library sources.
–with-sha1-opt=OPTIONS - Set additional options for sha1 building.
–with-sha1-asm - Use sha1 assembler sources.
–with-zlib=DIR - Set path to zlib library sources.
–with-zlib-opt=OPTIONS - Set additional options for zlib building.
–with-zlib-asm=CPU - Use zlib assembler sources optimized for specified CPU, valid values are: pentium, pentiumpro
–with-openssl=DIR - Set path to OpenSSL library sources
–with-openssl-opt=OPTIONS - Set additional options for OpenSSL building
–with-debug - 启用调试日志
–add-module=PATH - Add in a third-party module found in directory PATH
在不同版本间,选项可能会有些许变化,请总是使用 ./configure –help 命令来检查一下当前的选项列表。
示例 (最好能在同一行):
./configure
–sbin-path=/usr/local/nginx/nginx
–conf-path=/usr/local/nginx/nginx.conf
–pid-path=/usr/local/nginx/nginx.pid
–with-http_ssl_module
–with-pcre=../pcre-4.4
–with-zlib=../zlib-1.1.3
Example on Ubuntu/debian with libgcrypt11-dev, libpcre3-dev and libssl-dev installed (choose EITHER –with-md5 OR –with-sha1, but not both; on debian and ubuntu, they should both point to /usr/lib)
./configure --with-openssl=/usr/lib/ssl/ --with-md5=/usr/lib
选项
-c </path/to/config> 为 Nginx 指定一个配置文件,来代替缺省的。
-t 不运行,而仅仅测试配置文件。nginx 将检查配置文件的语法的正确性,并尝试打开配置文件中所引用到的文件。
-v 显示 nginx 的版本。
-V 显示 nginx 的版本,编译器版本和配置参数。
一个简单的负载均衡的示例,把www.domain.com均衡到本机不同的端口,也可以改为均衡到不同的地址上。
http {
: upstream myproject {
: server 127.0.0.1:8000 weight=3;
: server 127.0.0.1:8001;
: server 127.0.0.1:8002;
: server 127.0.0.1:8003;
: }
: server {
: listen 80;
: server_name www.domain.com;
: location / {
: proxy_pass http://myproject;
: }
: }
将nginx 设置为系统服务
$ wget http://nginx-init-ubuntu.googlecode.com/files/nginx-init-ubuntu_v2.0.0-RC2.tar.bz2
$ tar jxvf nginx-init-ubuntu_v2.0.0-RC2.tar.bz2
$ gedit nginx
更新为以下值:
DAEMON=/etc/nginx/sbin/nginx
NGINX_CONF_FILE=”/etc/nginx/conf/nginx.conf”
$ mv nginx /etc/init.d/
$ sudo /usr/sbin/update-rc.d -f nginx defaults
2010年11月16日
How to Fix VirtualBox USB Device Support UBUNTU
It is actually a known fact that there
is an issue with VirtualBox and the attached USB devices that many of us are trying to use in the virtual machine. Here is a real-life example:
I am a 100% Linux user and I have a photo printer that Linux can’t recognize. Let’s say that I want to print some photos quickly, to give them to someone. I have a Windows installation in a virtual machine just for this reason (sad, I know) and I want to access my printer, which is connected via a USB port. To my surprise, I can see the printer in the USB device list of VirtualBox, but I can’t access it (very frustrating). Firing up Firefox and searching on Google for a fix takes too long, because there are many old tutorials that teach you how to modify various files or change permissions, etc. What to do? Well, below is the answer to the endless VirtualBox – USB issue (and it’s pretty damn simple too!).
This tutorial was created mostly for my needs, but I am sure that many of you will find it very helpful. Ready?
This is how a default installation of VirtualBox in Ubuntu 9.04 shows the USB devices, and we need to fix it.
![]() |
Go to System -> Administration -> Users and Groups…
![]() |
Click the “Unlock” button…
![]() |
Type your password and click the “Authenticate” button….
![]() |
Click on the “Manage Groups” button…
![]() |
In the “Groups settings” window that will appear, scroll down until you see the vboxusers entry. Select it and then click on the “Properties” button…
![]() |
Another window will appear, called “Group ‘vboxusers’ Properties. Just check the box in front of your username and click the “OK” button when you’re done…
![]() |
Close the “Group settings” and “Users Settings” windows and log out. Log in and open up VirtualBox, start your virtual machine and you will see that you can now access the USB devices!
![]() |
Yes… it was that simple!
2010年11月9日
UBUNTU编译出能运行在DD-WRT、Tomato下的软件
我的系统环境:vista
在虚拟机virtualbox中安装ubuntu
1.装好ubuntu,安装增强工具
2.在ubuntu的用户目录下建立以下几个文件夹cross、tools、source。
tools:放置交叉编译工具 source:存放源代码

3.到DD-WRT的官方网站下载交叉编译工具toolchains.x86.debian.sp1.tar.bz2
4.将toolchains.x86.debian.sp1.tar.bz2中的4.1.0-uclibc-0.9.28,解压缩到tools目录,并改名为dd
这个交叉编译工具编译出的程序可在tomato和dd-wrt下正常运行

5.安装一些所需要的工具
sudo apt-get install bison flex build-essential patch libncurses5-dev
6. 到这个时候准备工作就基本完成了
每次新打开终端,使用前请运行
export PATH=”$PATH:/home/jacky/tools/dd/bin” (请根据实际情况修改路径)
1.下载libpcap源码http://www.tcpdump.org/release/
(我用的是0.9.8,因为这个版本编译出来的libpcap.a比较小254KB)
2.将其解压缩到cross目录
3.进入libpcap目录,cd /home/jacky/cross/libpcap-0.9.8
4.运行命令 export PATH=”$PATH:/home/jacky/tools/dd/bin”
5.运行命令 export ac_cv_linux_vers=2.6
6.运行命令 ./configure –host=mipsel-linux-uclibc –prefix=/home/jacky/tools/dd –with-pcap=linux
(–host=HOST 指定软件运行的系统平台,configure –host=mipsel-linux-uclibc这个就是mipsel的交叉编译选项。
prefix是你要安装的位置,这里我把libpcap安装到交叉编译工具所在目录)
7.运行命令 make
8.运行命令 make install
………………………….
红色字体部分,请按实际情况修改路径
通常交叉编译开源软件一般只需以下几步即可编译
1 export PATH=”$PATH:/home/jacky/tools/dd/bin“
2 ./configure –host=mipsel-linux
3 make
…………………………………………………………………
针对tomato对xclient进行的小修改
xclient源码中,使用了pkill、dhclient命令,但是tomato中并没有这两个命令,
所以用killall替代pkill,用dhcpc-renew替代dhclient。
通常在tomato中客户端是设置成开机自动运行的,我们难以知道客户端运行情况。
所以我想了一个折中的方法,把拨号时的提示信息输出到日志文件中。
tomato中有个logger命令,可以用他把信息输入到日志文件中,
如运行logger hello,可在tomato日志中发现信息user.notice root: hello
具体修改如图所示

………………………………………………………………….
相关文章:
http://felix021.com/blog/read.php?1467
http://www.right.com.cn/forum/viewthread.php?tid=22853&extra=page%3D1&page=1
http://groups.google.com/group/njit8021xclient
http://gforge.osdn.net.cn/projects/njit8021xclient/
http://hi.baidu.com/syshall/blog/item/d75d89182368904243a9adda.html
2010年11月9日
ubuntu 安装极点五笔(五笔拼音)
ibus下用法如下:
1.下载附件文件vissible-ibus.tar.gz
ibus的文件下载地址 :
http://www.uudisc.com/user/vissible/file/3496164
2. 解压
tar xvzf vissible-ibus.tar.gz
3. 执行如下命令:
cd vissible-ibus
sudo cp vissible.db /usr/share/ibus-table/tables
sudo cp vissible.gif /usr/share/ibus-table/icons
4.重启ibus或注销再登录,ibus里添加极点五笔即可
scim下用法如下:
1.下载附件文件vissible-scim.tar.gz
scim的文件载地址 :
http://www.uudisc.com/user/vissible/file/3496159
2. 解压
tar xvzf vissible-scim.tar.gz
3. 执行如下命令:
cd vissible-scim
sudo cp vissible.bin /usr/share/scim/tables
sudo cp vissible.gif /usr/share/scim/icons
4.重启scim或注销再登录,scim里选择极点五笔即可
————————————————————————————————-
如果没有安装SCIM,还需按以下方法安装SCIM
ubuntu scim输入法及输入法管理器的安装:
$sudo apt-get install scim
$sudo atp-get install scim-modules-socket
$sudo apt-get install scim-modules-table
$sudo apt-get install scim-pinyin
$sudo apt-get install scim-tables-zh
$sudo apt-get install scim-input-pad
启动scim输入法
$scim -d
说明:以上也可以在软件管理包中自动安装。
给Ubuntu安装极点五笔
1、安装Ubuntu语言包
2、下载
3、在Ubuntu系统中选择[系统]-[首先项]-[SCIM输入法设置]-[输入法引擎]-[通用码表]-[码表管理]-[安装],找到上一步下载的freeim.bin,进行安装并重启系统!
4、在Ubuntu系统中选择[系统]-[首先项]-[SCIM输入法设置]-[输入法引擎]-[全局设置]-[简体中文],确认激活freeime选项,就可以在Ubuntu中使用“极点永不言弃2010-09-16 14:23:27笔”了!
极点五笔是 Windows 下非常优秀的五笔输入法之一,而 SCIM 自带的五笔输入法却不是很理想,所以如果能在 Ubuntu 下用上极点五笔会非常不错。以下就是方法。
一、安装
解压、复制 极点五笔.bin 到主目录下
sudo mv 极点五笔.bin /usr/share/scim/tables
sudo pkill scim && scim -d
出终端再执行下面命令
scim-setup
二、设置
输入法引擎:全局设置:简体中文:极点五笔 6.1(勾选):确定
sudo pkill scim && scim -d
退出终端
2010年10月29日
Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny)
mod_mono is an Apache module that makes it possible to run ASP.NET applications in Linux environments running Apache. While ASP.NET is a Microsoft technology and is traditionally used with IIS, mod_mono has become a viable option for deploying ASP.NET applications on Linux. This guide is inspired by the mod_mono guide created by the Ubuntu Community
and the Mono Project’s Apache and Mono document
with minor modifications. This guide does not cover installation and configuration of the Mono IDE which is used to develop ASP.NET applications on Linux. If you are interested in developing using Visual Studio for Mono, you can download a 30-day trial of the commercial Mono Tools plugin at the Mono Tools for Visual Studio page
.
This guide assumes that you’ve followed the steps outlined in our getting started guide. You will install the Apache web server with very minimal configuration. If you already have Apache installed and configured, you may omit these steps; however, if you have not installed Apache and are unfamiliar with this server read the installation guide for additional documentation. Additionally, mod_mono is incompatible with the integrated PHP interpreter described in other guides. If you need to have both mod_mono and PHP running on the same Apache server you will need to run PHP scripts using the CGI method
These instructions work with the Linode platform. If you don’t have a Linode yet, sign up for a Linux VPS and get started today.
Install Required Software 
Before beginning the installation process, issue the following command to update your package lists:
apt-get update apt-get upgrade
Install Apache 
If you already have Apache installed and configured, you can safely skip this section of the guide. Install Apache by running the following command:
apt-get install apache2
As mentioned earlier, you will need to go to the installation guide if you wish to configure your server beyond the default configuration.
Install mod_mono 
The Apache daemon must be stopped before mod_mono is installed. Issue the following command to stop the apache process:
/etc/init.d/apache2 stop
At this point we’re able to install the required packages for mod_mono. Run the following command:
apt-get install mono-apache-server2 libapache2-mod-mono libmono-i18n2.0-cil
When the installation process completes start Apache with the following command:
/etc/init.d/apache2 start
Configure Apache 
We recommend using name-based virtual hosts for web hosting. Refer to the Apache documentation for setting up Name-based virtual hosts.
Recent versions of mod_mono utilize the AutoHosting method of application deployment. This allows non-privileged users to deploy new applications without modifying Apache configuration files. While this provides great flexibility, it may also present a security risk. As a result, mod_mono must be enabled on a per-virtual host basis.
For the sake of this guide, we’re going to create a site on the root of our example domain, ducklington.org. If you already have an Apache configuration for the root of your site, you will need to modify your existing virtual host file or create a new one on a subdomain of your site. Create the virtual host file, taking the following example virtual host configuration and modifying it to suit your needs. You may also use the Mod_Mono Configuration Generator
to generate your own custom configuration.
File excerpt: /etc/apache2/sites-available/ducklington.org
<VirtualHost *:80>
ServerName ducklington.org
ServerAdmin web-admin@ducklington.org
ServerAlias www.ducklington.org
DocumentRoot /srv/www/ducklington.org/public_html
ErrorLog /srv/www/ducklington.org/logs/error.log
CustomLog /srv/www/ducklington.org/logs/access.log combined
MonoServerPath ducklington.org "/usr/bin/mod-mono-server2"
MonoDebug ducklington.org true
MonoSetEnv ducklington.org MONO_IOMAP=all
MonoApplications ducklington.org "/:/srv/www/ducklington.org/public_html"
<Location "/">
Allow from all
Order allow,deny
MonoSetServerAlias ducklington.org
SetHandler mono
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
</Location>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
</IfModule>
</VirtualHost>
Save and close the file, and create the directories referenced in the DocumentRoot and ErrorLog directive:
mkdir -p /srv/www/ducklington.org/public_html mkdir /srv/www/ducklington.org/logs
Enable the site by running the a2ensite command:
a2ensite ducklington.org
Since we have modified the virtual host configuration, Apache must be reloaded:
/etc/init.d/apache2 reload
Note: Should you restart Apache in the future, you will see an error that will look similar to this:
[crit] (13)Permission denied: Failed to attach to existing dashboard, and removing dashboard file '/tmp/mod_mono_dashboard_XXGLOBAL_1' failed (Operation not permitted). Further action impossible.
You can safely ignore this warning, as it won’t affect deployment using the methods explained in this guide.
Installing MySQL Connector/Net for ASP.NET 
This section assumes that you already have a functioning MySQL installation. Please refer to our MySQL Installation Guide for more detailed instructions for installing MySQL, otherwise issue the following command:
apt-get install mysql-server
In order for your ASP.NET application to communicate properly with your MySQL server, you must install the MySQL Connector/Net driver. The following commands download and install the 6.2.3 version of the connector. Check the MySQL Upstream
to ensure that this the latest version of the plugin:
cd /opt/ wget http://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-6.2.3-noinstall.zip/from/http://mysql.mirrors.pair.com/ unzip -d mysqlConnector mysql-connector-net-6.2.3-noinstall.zip cd mysqlConnector gacutil -i mysql.data.dll gacutil -i mysql.web.dll
Creating a Database to Test the MySQL Connector 
Now that the MySQL Connector has been installed, you should test it by creating a sample database and a test table. First you must log in to your MySQL DBMS:
mysql -u root -p
Next you must create the sample table. Issue the following commands at the MySQL prompt:
CREATE DATABASE sample; USE sample; CREATE TABLE test (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(25)); INSERT INTO sample.test VALUES (null, 'Lucy'); INSERT INTO sample.test VALUES (null, 'Ivan'); INSERT INTO sample.test VALUES (null, 'Nicole'); INSERT INTO sample.test VALUES (null, 'Ursula'); INSERT INTO sample.test VALUES (null, 'Xavier');
Finally you must create a test user named “testuser” and give that user access to the newly created sample database:
CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'somepassword'; GRANT ALL PRIVILEGES ON sample.* TO 'testuser'@'localhost'; FLUSH PRIVILEGES;
Creating a Simple ASP.NET Application 
Now that you have created a sample database, you can test your installation with the following test page. This will not only test your Mono installation but it will also will test your MySQL connector configuration. First create a file called testdb.aspx in your DocumentRoot and paste the text below into it. Be sure to change the User ID and Password to match what you specified above.
File excerpt: /srv/www/ducklington.org/public_html/testdb.aspx
[COLORIZE aspx-cs] <%@ Page Language=”C#” %> <%@ Import Namespace=”System.Data” %> <%@ Import Namespace=”MySql.Data.MySqlClient” %> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
“> <html xmlns=”http://www.w3.org/1999/xhtml
” xml:lang=”en” lang=”en”> <head> <title>ASP and MySQL Test Page</title> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<script runat=”server”> private void Page_Load(Object sender, EventArgs e) { string connectionString = “Server=127.0.0.1;Database=sample;User ID=testuser;Password=somepassword;Pooling=false;”; MySqlConnection dbcon = new MySqlConnection(connectionString); dbcon.Open();
MySqlDataAdapter adapter = new MySqlDataAdapter(“SELECT * FROM test”, dbcon); DataSet ds = new DataSet(); adapter.Fill(ds, “result”);
dbcon.Close(); dbcon = null;
SampleControl.DataSource = ds.Tables["result"]; SampleControl.DataBind(); } </script>
</head>
<body> <h1>Testing Sample Database</h1> <asp:DataGrid runat=”server” id=”SampleControl” /> </body>
</html> [/COLORIZ]
Next you will need to create a web.config file. You can copy and paste the the example below. Please note that Custom Errors have been turned off in this web.config for debugging purposes. The customErrors mode line should be removed in a production environment.
File excerpt: /srv/www/ducklington.org/public_html/web.config
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation>
<assemblies>
<add assembly="MySql.Data"/>
</assemblies>
</compilation>
</system.web>
</configuration>
Visit the testdb.aspx file in a web browser. If you see the text “Testing Sample Databases” in your browser with the information that you inserted into the database above, you now have a functioning mod_mono installation and can continue with the development and deployment of your own application!
2010年05月26日
在VPS中安装配置OpenVPN
如果VPS的带宽和内存充足,通过它使用VPN代理上网是非常方便的。本文以Ubuntu系统为例,介绍OpenVPN的安装与配置。 OpenVPN身份验证使用的是证书文件,而非账号密码形式。
安装配置OpenVPN之前,请确保VPS已支持tun/tap,且iptables已支持NAT。ramhost的VPS默认都是支持的。
如果还没有安装iptables请先安装iptables:
apt-get install iptables
安装OpenVPN:
apt-get install openvpn
拷贝文件夹,以方便后续配置:
cp -R /usr/share/doc/openvpn/examples/easy-rsa /etc/openvpn
生成服务端和客户端的密钥及证书文件:
cd /etc/openvpn/easy-rsa/2.0
source ./vars
./clean-all
./build-ca
./build-key-server server
./build-key clientsteven
./build-dh
其中遇到需要输入信息的步骤全部按回车过去,直到最后一个步骤提示是否生成证书,按Y即可。
配置iptables规则,以转发来自VPN的请求:
chmod 755 /etc/rc.local
vim /etc/rc.local
将rc.local文件修改为以下内容:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0″ on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# add iptables rule for openvpn
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j SNAT –to 202.248.185.66
/etc/init.d/openvpn start
exit 0
其中,202.248.185.66是VPS的IP.
注意:上面那行尾SNAT –to 202.248.185.66,是两个“-”号,WP把两个变成一个了,不知道为什么
创建OpenVPN的配置文件:
vim /etc/openvpn/openvpn.conf
openvpn.conf文件内容如下:
dev tun
proto tcp
port 1194
ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
key /etc/openvpn/easy-rsa/2.0/keys/server.key
dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem
user nobody
group nogroup
server 10.8.0.0 255.255.255.0
persist-key
persist-tun
#status openvpn-status.log
#verb 3
client-to-client
push “redirect-gateway def1″
push “dhcp-option DNS 8.8.8.8″
push “dhcp-option DNS 8.8.4.4″
comp-lzo
启动OpenVPN:
/etc/init.d/openvpn start
/etc/rc.local
至此,服务端的配置结束,接下来是Windows客户端的配置。
下载以下几个文件到客户端机器:
/etc/openvpn/easy-rsa/2.0/keys/ca.crt
/etc/openvpn/easy-rsa/2.0/keys/clientsteven.crt
/etc/openvpn/easy-rsa/2.0/keys/clientsteven.key
下载安装OpenVPN,下载链接:
http://openvpn.net/release/openvpn-2.1.0-install.exe
将下载的ca.crt、clientsteven.crt、clientsteven.key三个文件拷贝到OpenVPN安装目录的config 文件夹下,并新建clientsteven.ovpn文件,内容如下:
client
dev tun
proto tcp
# The hostname/IP and port of the server.
# CHANGE THIS TO YOUR VPS IP ADDRESS
remote 202.248.185.66 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert clientsteven.crt
key clientsteven.key
comp-lzo
verb 3
其中,202.248.185.66是VPS的IP.
若之后还需要添加其他的VPN账号,则需要以下命令:
cd /etc/openvpn/easy-rsa/2.0
./build-key clientsusan
而后下载相应的文件到客户端,并按照之前介绍的步骤配置客户端。
2010年05月25日
(转)将ubuntu 8.10 装进移动硬盘
准备工作
1.备份移动硬盘中的重要数据。
2.考虑到有些电脑对 USB 启动支持不够好,启动时只能认到移动硬盘前 8G 空间,所以最好把系统装在前 8G 中,以获得更高的启动成功率。
3.准备 ubuntu 8.10 desktop 光盘或 iso 文件( http://releases.ubuntu.com/intrepid/ubu … p-i386.iso )。
启动 ubuntu 安装程序
如果有 ubuntu 8.10 desktop 光盘,可以直接从光盘启动,选择语言后,出现启动菜单,选择第二项“安装 ubuntu”,过一会儿便进入安装程序界面。
如果没有光盘或光盘不能正常启动,也可以从硬盘启动安装程序,前提是电脑中装有 windows 2000/xp/2003/vista 系统。步骤如下:
1.将附件中的 wubildr.mbr、wubildr和menu.lst拷贝到C盘根目录下;将 ubuntu 8.10 desktop iso 中的 .disk 和 casper 两个文件夹解出来,也放到C盘根目录下。
2. 如果是 windows 2000/xp/2003:从资源管理器打开“工具 –> 文件夹选项 –> 查看”,去掉“隐藏受保护的操作系统文件(推荐)”和“隐藏已知文件类型的扩展名”前面的对勾,选中“显示所有文件和文件夹”,确定后,可以看到 C 盘中有一个 boot.ini 文件,修改其属性,去掉“只读”,然后打开它,在最下方添加一行 C:wubildr.mbr=”Install UBUNTU” 。可酌情修改 timeout 值。保存。
3.如果是 windows vista/2008,则需要用 bcdedit 添加启动项目(以管理员身份运行):
此时生成一个{id}
bcdedit /set {id} device partition=C:
bcdedit /set {id} path wubildr.mbr
bcdedit /displayorder {id} /addlast
4.重启,出现系统选择菜单时选择 Install UBUNTU ,回车,即可看到ubuntu 安装菜单。默认启动第一项(标准模式),若不能正常启动,可以试试第二项或第三项。
安装系统
接上移动硬盘,按照安装程序的提示前进。
到 第4步“预备硬盘空间”时,选择“手动”,前进,来到“准备分区”界面。按您的需求合理分区。如果没有 linux 分区经验,可以这样:在移动硬盘的前端分两个区,一个 6G 左右,建议用“ReiserFS 日志文件系统”,挂载点为“/” ,另一个1G左右,用于“交换空间”。这两个分区分成主分区或逻辑分区均可。

2.png [ 265.25 KiB | 被浏览 4598 次 ]
分 好后继续前进。到第7步时,点右下方的“高级”按钮,检查一下“安装启动引导器的设备”是不是移动硬盘(如图)。一般情况下,程序会自动作出判断,将 grub 安装到移动硬盘上。我们只是确认一下,以保证万无一失 —— 这里如果出错,可能导致电脑中原有的系统无法启动。

3.png [ 256.26 KiB | 被浏览 4195 次 ]
确认无误后,点击“安装”,开始安装系统。此时拔掉网线可以加快安装速度。安装完成后会提示重启。至此,移动ubuntu 就装好了。您可以拿着它在不同电脑上启动,与本地安装的系统没有任何区别。
为了获得更好的兼容性,可以安装一个自动配置显卡的脚本
启动移动硬盘ubuntu,将附件中的 S03xconfig.sh 拷贝到用户主目录,打开终端,运行
即可。
这 是一个自动配置 X 的脚本,功能比较简陋,只是尽量保证能启动到图形界面。ubuntu 系统中有个“硬件驱动”程序,可以从源中检索、安装硬件驱动,将它加以改进,再配合预先下载的驱动程序包,应该能实现开机自动检测、安装闭源显卡驱动,获 得更好的显示性能。这个工作目前没时间做,有兴趣的朋友可以试试。









