存档

文章标签 ‘Other’

linux 下恢复 U 盘下被删除文件

2010年3月4日

我一老师的手机 sd 卡上的照片被不幸删除了,问有没有方法恢复。我找到一个叫 testdisk 的工具,成功将这些照片恢复过来,立此存照兼备忘。

安装:
sudo pacman -S testdisk
使用:
sudo testdiak
接下来按照图片直播搞定:

testdisk1

testdisk2

testdisk3

testdisk4

testdisk5

testdisk6

testdisk7

testdisk8

Other ,

让 php 和 web.py 同时工作在 lighttpd 下

2009年12月15日
Comments Off

这几天在学习 web.py,不满足于让其运行于自带的 web 服务器上,于是想将其运行在 lighttpd 下面,网络上找到的配置几乎是出自同一版本,即通过 fastcgi 将 web.py 跑在 lighttpd下的,本人对 lighttpd 的配置不熟,结果要不是 php (主要是跑 phpmyadmin 用)不能跑就是 web.py 不能跑,摸阿摸阿的弄了半天终于试对了,呵呵,现在先记录在这里,免得以后忘掉。(红色是重点):

# lighttpd configuration file
#
# use it as a base for lighttpd 1.0.0 and above
#
# $Id: lighttpd.conf,v 1.7 2004/11/03 22:26:05 weigon Exp $

############ Options you really have to take care of ####################

## modules to load
# at least mod_access and mod_accesslog should be loaded
# all other module should only be loaded if really neccesary
# – saves some time
# – saves memory
server.modules = (
“mod_rewrite”,
# “mod_redirect”,
“mod_alias”,
“mod_access”,
# “mod_trigger_b4_dl”,
# “mod_auth”,
# “mod_status”,
# “mod_setenv”,
“mod_fastcgi”,
# “mod_proxy”,
# “mod_simple_vhost”,
# “mod_evhost”,
# “mod_userdir”,
“mod_cgi”,
“mod_compress”,
# “mod_ssi”,
# “mod_usertrack”,
# “mod_expire”,
# “mod_secdownload”,
# “mod_rrdtool”,
“mod_accesslog” )

## A static document-root. For virtual hosting take a look at the
## mod_simple_vhost module.
server.document-root = “/srv/http/”

## where to send error-messages to
server.errorlog = “/var/log/lighttpd/error.log”

# files to check for if …/ is requested
index-file.names = ( “index.php”, “index.html”,
“index.htm”, “default.htm” )

## set the event-handler (read the performance section in the manual)
# server.event-handler = “freebsd-kqueue” # needed on OS X

# mimetype mapping
mimetype.assign = (
“.pdf” => “application/pdf”,
“.sig” => “application/pgp-signature”,
“.spl” => “application/futuresplash”,
“.class” => “application/octet-stream”,
“.ps” => “application/postscript”,
“.torrent” => “application/x-bittorrent”,
“.dvi” => “application/x-dvi”,
“.gz” => “application/x-gzip”,
“.pac” => “application/x-ns-proxy-autoconfig”,
“.swf” => “application/x-shockwave-flash”,
“.tar.gz” => “application/x-tgz”,
“.tgz” => “application/x-tgz”,
“.tar” => “application/x-tar”,
“.zip” => “application/zip”,
“.mp3″ => “audio/mpeg”,
“.m3u” => “audio/x-mpegurl”,
“.wma” => “audio/x-ms-wma”,
“.wax” => “audio/x-ms-wax”,
“.ogg” => “application/ogg”,
“.wav” => “audio/x-wav”,
“.gif” => “image/gif”,
“.jar” => “application/x-java-archive”,
“.jpg” => “image/jpeg”,
“.jpeg” => “image/jpeg”,
“.png” => “image/png”,
“.xbm” => “image/x-xbitmap”,
“.xpm” => “image/x-xpixmap”,
“.xwd” => “image/x-xwindowdump”,
“.css” => “text/css”,
“.html” => “text/html”,
“.htm” => “text/html”,
“.js” => “text/javascript”,
“.asc” => “text/plain”,
“.c” => “text/plain”,
“.cpp” => “text/plain”,
“.log” => “text/plain”,
“.conf” => “text/plain”,
“.text” => “text/plain”,
“.txt” => “text/plain”,
“.dtd” => “text/xml”,
“.xml” => “text/xml”,
“.mpeg” => “video/mpeg”,
“.mpg” => “video/mpeg”,
“.mov” => “video/quicktime”,
“.qt” => “video/quicktime”,
“.avi” => “video/x-msvideo”,
“.asf” => “video/x-ms-asf”,
“.asx” => “video/x-ms-asf”,
“.wmv” => “video/x-ms-wmv”,
“.bz2″ => “application/x-bzip”,
“.tbz” => “application/x-bzip-compressed-tar”,
“.tar.bz2″ => “application/x-bzip-compressed-tar”,
# default mime type
“” => “application/octet-stream”,
)

# Use the “Content-Type” extended attribute to obtain mime type if possible
#mimetype.use-xattr = “enable”

## send a different Server: header
## be nice and keep it at lighttpd
# server.tag = “lighttpd”

#### accesslog module
accesslog.filename = “/var/log/lighttpd/access.log”

## deny access the file-extensions
#
# ~ is for backupfiles from vi, emacs, joe, …
# .inc is often used for code includes which should in general not be part
# of the document-root
url.access-deny = ( “~”, “.inc” )

$HTTP["url"] =~ “\.pdf$” {
server.range-requests = “disable”
}

##
# which extensions should not be handle via static-file transfer
#
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( “.php”, “.pl”, “.fcgi”, “.sh”, “.py” )

######### Options that are good to be but not neccesary to be changed #######

## bind to port (default: 80)
#server.port = 81

## bind to localhost (default: all interfaces)
#server.bind = “127.0.0.1″

## error-handler for status 404
#server.error-handler-404 = “/error-handler.html”
#server.error-handler-404 = “/error-handler.php”

## to help the rc.scripts
server.pid-file = “/var/run/lighttpd/lighttpd.pid”

###### virtual hosts
##
## If you want name-based virtual hosting add the next three settings and load
## mod_simple_vhost
##
## document-root =
## virtual-server-root + virtual-server-default-host + virtual-server-docroot
## or
## virtual-server-root + http-host + virtual-server-docroot
##
#simple-vhost.server-root = “/srv/http/vhosts/”
#simple-vhost.default-host = “www.example.org”
#simple-vhost.document-root = “/htdocs/”

##
## Format: .html
## -> …./status-404.html for ‘File not found’
#server.errorfile-prefix = “/usr/share/lighttpd/errors/status-”
#server.errorfile-prefix = “/srv/http/errors/status-”

## virtual directory listings
#dir-listing.activate = “enable”
## select encoding for directory listings
#dir-listing.encoding = “utf-8″

## enable debugging
#debug.log-request-header = “enable”
#debug.log-response-header = “enable”
#debug.log-request-handling = “enable”
#debug.log-file-not-found = “enable”

### only root can use these options
#
# chroot() to directory (default: no chroot() )
#server.chroot = “/”

## change uid to (default: don’t care)
server.username = “http”

## change uid to (default: don’t care)
server.groupname = “http”

#### compress module
#compress.cache-dir = “/var/cache/lighttpd/compress/”
#compress.filetype = (”text/plain”, “text/html”)

#### proxy module
## read proxy.txt for more info
#proxy.server = ( “.php” =>
# ( “localhost” =>
# (
# “host” => “192.168.0.101″,
# “port” => 80
# )
# )
# )

#### fastcgi module
## read fastcgi.txt for more info
## for PHP don’t forget to set cgi.fix_pathinfo = 1 in the php.ini
fastcgi.server = ( “.php” =>
( “localhost” =>
(
“socket” => “/var/run/lighttpd/php-fastcgi.socket”,
“bin-path” => “/usr/bin/php-cgi”
)
),
# for web.py
               “/main.py” =>
( (
“socket” => “/var/run/lighttpd/webpy-fastcgi.socket”,
“bin-path” => “/srv/http/main.py”,
“max-procs” => 2,
“check-local” => “disable”
) )
)

#### CGI module
cgi.assign = ( “.pl” => “/usr/bin/perl”,
“.cgi” => “/usr/bin/perl”,
“.sh” => “/bin/bash”,
“.py” => “/usr/bin/python”)
#

#### SSL engine
#ssl.engine = “enable”
#ssl.pemfile = “/etc/ssl/private/lighttpd.pem”

#### status module
#status.status-url = “/server-status”
#status.config-url = “/server-config”

#### auth module
## read authentication.txt for more info
#auth.backend = “plain”
#auth.backend.plain.userfile = “lighttpd.user”
#auth.backend.plain.groupfile = “lighttpd.group”

#auth.backend.ldap.hostname = “localhost”
#auth.backend.ldap.base-dn = “dc=my-domain,dc=com”
#auth.backend.ldap.filter = “(uid=$)”

#auth.require = ( “/server-status” =>
# (
# “method” => “digest”,
# “realm” => “download archiv”,
# “require” => “user=jan”
# ),
# “/server-config” =>
# (
# “method” => “digest”,
# “realm” => “download archiv”,
# “require” => “valid-user”
# )
# )

#### url handling modules (rewrite, redirect, access)
#url.rewrite = ( “^/$” => “/server-status” )
#url.redirect = ( “^/wishlist/(.+)” => “http://www.123.org/$1″ )
url.rewrite-once = (
“^/$” => “/index.html”,
“^(.*)$” => “/main.py/$1″
                                   )

#### both rewrite/redirect support back reference to regex conditional using %n
#$HTTP["host"] =~ “^www\.(.*)” {
# url.redirect = ( “^/(.*)” => “http://%1/$1″ )
#}

#
# define a pattern for the host url finding
# %% => % sign
# %0 => domain name + tld
# %1 => tld
# %2 => domain name without tld
# %3 => subdomain 1 name
# %4 => subdomain 2 name
#
#evhost.path-pattern = “/srv/http/vhosts/%3/htdocs/”

#### expire module
#expire.url = ( “/buggy/” => “access 2 hours”, “/asdhas/” => “access plus 1 seconds 2 minutes”)

#### ssi
#ssi.extension = ( “.shtml” )

#### rrdtool
#rrdtool.binary = “/usr/bin/rrdtool”
#rrdtool.db-name = “/var/lib/lighttpd/lighttpd.rrd”

#### setenv
#setenv.add-request-header = ( “TRAV_ENV” => “mysql://user@host/db” )
#setenv.add-response-header = ( “X-Secret-Message” => “42″ )

## for mod_trigger_b4_dl
# trigger-before-download.gdbm-filename = “/var/lib/lighttpd/trigger.db”
# trigger-before-download.memcache-hosts = ( “127.0.0.1:11211″ )
# trigger-before-download.trigger-url = “^/trigger/”
# trigger-before-download.download-url = “^/download/”
# trigger-before-download.deny-url = “http://127.0.0.1/index.html”
# trigger-before-download.trigger-timeout = 10

#### variable usage:
## variable name without “.” is auto prefixed by “var.” and becomes “var.bar”
#bar = 1
#var.mystring = “foo”

## integer add
#bar += 1
## string concat, with integer cast as string, result: “www.foo1.com”
#server.name = “www.” + mystring + var.bar + “.com”
## array merge
#index-file.names = (foo + “.php”) + index-file.names
#index-file.names += (foo + “.php”)

#### include
#include /etc/lighttpd/lighttpd-inc.conf
## same as above if you run: “lighttpd -f /etc/lighttpd/lighttpd.conf”
#include “lighttpd-inc.conf”

#### include_shell
#include_shell “echo var.a=1″
## the above is same as:
#var.a=1
# for phpmyadmin
alias.url += (”/phpmyadmin” => “/usr/share/webapps/phpMyAdmin”)

Other

[转]Unix-Center.Net需要您的帮助

2009年7月14日
Comments Off

转自http://www.unix-center.net/?p=133
虽然没有用过几次,但是希望大家踊跃帮助,毕竟这样的好网站不多阿。

我恳请诸位花一点时间读完这篇文章,因为将有数以万计的人会从您的爱心中得到帮助。

Unix-Center.Net的目标是为研究、学习和使用各种版本的Unix和类Unix操作系统的教师、学生和工程技术人员提供一个体验和测试各种版本的Unix和类Unix系统的软硬件平台。该平台能够为所有注册用户免费提供SSH/VNC服务,MySQL数据库服务,传统的C/C++、 Java、Fortran等多种语言开发环境,基于Apache、MySQL和PHP的Web应用开发环境。简单地讲,Unix-Center.Net的注册用户可以远程登录进入多个不同的操作系统,具备自己独立的用户空间和磁盘配额,享受该操作系统上普通用户的所有权限,学习和使用各种版本的Unix和类Unix操作系统的常用命令和功能,可以将自己正在开发的应用程序上载到Unix体验中心的服务器,在不同的软硬件平台上编译和运行。

到目前为止,Unix-Center.Net所提供的操作系统包括AIX 5.3,Solaris 10,OpenSolaris 2009.04,Fedora Core 10,Ubuntu 8.04,FreeBSD 6.2,Debian Linux for MIPS。这些操作系统分别运行在IBM Power 5,Sun UltraSPARC T1,AMD Opteron,Intel Xeon,龙芯2E等不同构架的处理器上。各种各样的服务器,再加上交换机、防火墙、存储等等,Unix-Center.Net的全部设备需要整整三个机柜才能够装得下。

中国大陆的网络环境很独特。拿各个大学的接入情况来看,清华北大等高校是通过中国教育科研网(CERNET)接入互联网的,以中科院为代表的一大批科研院所访问国内网站是需要先从国外绕一大圈再绕回来的,南方相当多的高校是通过公网(网通、联通、电信)接入互联网的。由于Unix- Center.Net的主要服务对象是学生,所以选择将服务器托管在互连互通条件比较好的北京赛尔机房,不然的话大部分学生访问起来都有困难。

这个网站不是政府所设置的开放实验室,也不是任何网络公司投资的创新项目。它是我的个人网站。

做这样一个网站的缘起很简单。因为工作的关系,我注意到很多高校 -- 即使是非常好的高校 --也没有办法给学生提供一个全面的环境来学习操作系统。大部分学校的机房,运行的操作系统清一色的是Windows。极少数学校的机房可以提供一两个版本的 Unix或者是Linux操作系统,但是和市面上版本繁多的操作系统相比较,可以选择的余地是在太少。在处理器构架方面,基本上都是x86/x64处理器,学生可能听说过其他种类的处理器,但是基本上没有机会见到,更不用说是使用了。因此,我萌发了一个极其简单的想法:买一些不同构架的服务器,安装上不同种类的操作系统,托管到一个机房,开放注册账号,免费地提供SSH登录服务。我是一个急性子的人,想到的事情就要赶紧去做,于是Unix- Center.Net的雏形在2007年初上线了。我没有想到的是,在短短的时间里便有上万名用户注册到这个系统,并且对系统功能提出了更多的需求。于是我赶紧添加新的服务器,并且恳求朋友帮忙开发一些必要的程序,逐渐完善这个系统的功能。

我于2000年底硕士毕业之后,在美国工作了三年,又在中国工作了六年。在过去的两年半中,这个系统烧掉了我大部分的工资和积蓄。购买各种服务器设备的费用,大概是70万人民币;北京赛尔机房的服务器托管和带宽费用,大概是每年30万人民币。(由于Unix-Center.Net对于推广我的雇主的操作系统有很大的帮助,我的雇主曾经在我的游说之下为Unix-Center.Net提供了半年的带宽费用。但是考虑到Unix-Center.Net同时提供其他种类的操作系统,我的雇主后来中止了对Unix-Center.Net的支持。)和我同年龄的人,现在大部分都有车有房了吧。而我最值钱的资产,是在保安严密的机房中的三个机柜。

我曾经和国家负责推广Linux和开源技术的机构取得联系,也曾经和某些教育部门取得联系,希望能够得到他们的支持。但是“有关部门”的负责人听取了我的陈述之后,不约而同地摇摇头,说:“你这个事情做得很好。很遗憾我们不能够给你提供任何帮助。”我也曾经考虑过将这个网站用商业化的模式来运作,但是这个公益性平台所服务的对象大部分是穷学生和穷教师,暂时并没有盈利的空间。并且,我自认为我是一个做事的人,而不是一个做生意的人。让我自己来运营一家公司的话,赚钱的可能性并不大。

中国是一个发展中国家,我们有很多教师、学生和工程人员希望能够学习Unix/Linux系统,却又苦于没有合适的环境和条件。Unix- Center.Net存在的目的,就是给这些爱好Unix/Linux的人一个学习和练习的条件。用一个简单的数据来说,到2009年6 月底,Unix-Center.Net的注册用户接近9 万人。我不知道这么多人都在这些服务器上做什么事情,但是我相信这些服务器对他们有用。譬如说,清华大学教授操作系统课程的一位教授告诉我说他让学生们到 Unix-Center.Net来对不同的操作系统进行比较。又譬如说,我收到中国科技大学一位博士生的电子邮件,说是他利用这些服务器完成了毕业论文中比较关键的一些计算。这些有限的证言,让我坚信这个系统是有其存在的意义的。尽管没有获得“有关部门”的支持,我从来都没有想过要放弃。

坦率地说,我现在遇到了一些困难。我所在的公司,在这次经济危机中被收购了。我不能够确定将来我是否还有能力将这个系统支持下去。但是我非常希望能够维持这个系统的运行,因为它确实对很多人有用。如果您也相信这一点的话,我希望您能够帮助我将这个系统维持下去。不管是10元、100元还是1000 元,对于Unix-Center.Net的用户来说都是莫大的帮助。

如果您在中国,您可以将您的捐款通过转帐支付给我的个人银行账号:

中国银行北京市分行清华园支行
蒋清野
4563-5101-0088-4741-228

招商银行北京市分行清华园支行
蒋清野
6226-0901-0156-8117

支付宝账户
13511026844

如果您在国外,您可以将您的捐款通过PayPal支付给我的个人账号(qjiang@ieee.org),或者是通过转帐支付到我在CitiBank的个人账号:

CitiBank
FDIC Routing #: 321171184
Account Name: Qingye Jiang
Account #: 40038862963
Debit Card #:5262-2519-8546-8207

我还恳请您在捐款之后给我发一封电子邮件(电子邮件地址qjiang@ieee.org),详细说明您的个人姓名以及捐款数目,以便我定期地整理和公布捐款情况。

Other