| |
Utilize shell scripts,linux commands, open source tools,java, to Maximize the Power of Linux.
Focused on working with linux and shell, search engine technology including Chinese segmenter
Any questions please contact me at gmail: david.ullua
Labels
- working with linux (9)
- tools for developer (7)
- java (4)
- common tools (3)
- php (3)
- shell (3)
- linux (1)
- linux virtualization (1)
- mysql (1)
2/04/2007
Shell Programming FAQ(为什么shell脚本无法运行?)
使用fdisk -l 快速查找可用的移动设备(移动硬盘,优盘,SD/MMC卡等)
有时候是在/sdb1下面,有时候是在/sdc1, 或者/sda5下,也可能是其他的路径标识。在尝试了"mount /dev/sdxn /mnt/udisk" 3次,5次都没有找到后,任何人都可能感觉到泄气。
其实在我们可以用fdisk -l (注意是小写的-L,list的意思) 命令查看系统的所有存储设备信息。fdisk是磁盘格式化工具,所以在磁盘,包括移动存储设备还没有mount的时候,就可以检测到这些设备。
下面是我的电脑插上优盘约30秒(接上优盘后,会有片刻的检测时间)后,运行fdisk -l的结果:
Disk /dev/sda: 512 MB, 512229376 bytes
9 heads, 8 sectors/track, 13895 cylinders
Units = cylinders of 72 * 512 = 36864 bytes
Device Boot Start End Blocks Id System
/dev/sda1 4 13896 500107+ 6 FAT16
Disk /dev/hda: 80.0 GB, 80023182848 bytes
255 heads, 63 sectors/track, 9728 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 1736 13944388+ 7 HPFS/NTFS
/dev/hda2 1737 9729 64203772+ f W95 Ext'd (LBA)
/dev/hda5 1737 2884 9221278+ b W95 FAT32
/dev/hda6 2885 3648 6136798+ 83 Linux
/dev/hda7 3649 8512 39070048+ 7 HPFS/NTFS
/dev/hda8 * 8513 9156 5172898+ 83 Linux
/dev/hda9 * 9157 9666 4096543+ 83 Linux
/dev/hda10 9667 9729 506016 82 Linux swap
这里可以看到/dev/sda1是有盘,可以mount /dev/sda1 /mnt/udisk加载u盘。
JAVA (JDK 1.5, slackware/debian linux)中文显示乱码问题的解决
标题: 再提 Ubuntu/Debian 下 JAVA 中文显示 作者:jhuangjiahua
来自:http://www.linuxsir.org/bbs/
IRC 上又有朋友问到这 JAVA 的 ,
1.
在 jre/lib/fonts/ 下建立个目录 fallback
比如我这儿就是
mkdir /usr/lib/j2sdk1.5-sun/jre/lib/fonts/fallback/
2.
在 fallback 里弄个中文字体
拷贝或链接都可以
比如我这就是
ln -s /usr/share/fonts/truetype/arphic/uming.ttf /usr/lib/j2sdk1.5-sun/jre/lib/fonts/fallback/
3.
进入 jre/lib/fonts/fallback/ 执行 mkfontscale
再把 jre/lib/fonts/fonts.scale 的内容加到 jre/lib/fonts/fonts.dir
我这儿就是
cd /usr/lib/j2sdk1.5-sun/jre/lib/fonts/fallback/
mkfontscale
cd ..
cat fallback/fonts.scale >> fonts.dir
原文地址 http://www.linuxsir.org/bbs/
2/02/2007
Apache 2.2.4, tomcat5.0.28 整合,以及中文乱码问题解决
Author: David Euler, 2007, david.ullua _at_ gmail (请用gmail.com替换gmail)
这篇文章主要参考从google搜索到的整合方法和问题解决方法,以及apache.org官方网站的文档。
并经过实际的验证 (os: slackware 11, 软件版本参考安装)。
目录
I.安装Apache, Tomcat, tomcat-connector (mod_jk) , 并整合apache与tomcat
II.tomcat, apache整合后,去掉tomcat的8080端口服务,用户只能通过80端口访问服务器
III.Tomcat/Apache乱码问题解决.
IV.虚拟主机配置
---------------------------------------------------------------------------------------------------------------
I.安装Apache, Tomcat, tomcat-connector (mod_jk) , 并整合apache与tomcat
共分5个步骤,详述如下
1、准备,下载需要的文件。这里假定你已经正确安装配置好了JDK。
到Apache官方网站下载所需要的文件:
httpd-2.2.4.tar.gz , apache的httpd server包 (需要编译安装,安装时)
apache-tomcat-5.5.20.tar.gz, apache的tomcat包, 不需要编译安装(解压即可)
tomcat-connectors-1.2.20-src.tar.gz (mod_jk的安装包)
2、安装Apache。
# tar xzvf httpd-2.2.4.tar.gz
或 tar jxvf httpd-2.2.4.tar.bz2
# cd httpd-2.2.4
参考INSTLL安装文档,如下即可安装apache(自带有cgi,perl, apxs的支持):
# ./configure --prefix=/usr/local/apache2 (不需要加--enable-so参数,
# make
# make install
3、安装Tomcat (解压即可)
# cp apache-tomcat-5.5.20.tar.gz /usr/local/
# cd /usr/local
# tar xzvf apache-tomcat-5.5.20.tar.gz
# ln -s apache-tomcat-5.5.20 tomcat
4、编译生成mod_jk
# tar xzvf tomcat-connectors-1.2.20-src.tar.gz
# cd tomcat-connectors-1.2.20-src/jk/native
# ./configure --with-apxs=/usr/local/apache2/bin/apxs
# make
# cp ./apache-2.0/mod_jk.so /usr/local/apache2/modules/
5、配置
在/usr/local/apache2/conf/下面建立两个配置文件mod_jk.conf和workers.properties。
# vi mod_jk.conf
添加以下内容:
# 指出mod_jk模块工作所需要的工作文件workers.properties的位置
JkWorkersFile /usr/local/apache2/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache2/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount /servlet/* worker1
JkMount /*.jsp worker1
# vi workers.properties
添加以下内容:
# Defining a worker named worker1 and of type ajp13,
# 注意8009是tomcat的ajp13端口,注意不是8080
worker.list=worker1
# Set properties for worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
#worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
6.再配置httpd.conf,作以下修改:
将Listen 80 修改为 Listen 127.0.0.1:80
将ServerName 修改为 ServerName localhost:80
在DirectoryIndex中添加 index.jsp, 假设网页放在/var/wwwroot下,要修改DocumentRoot
DocumentRoot "/var/wwwroot"
<Directory "/var/wwwroot">
Options Includes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
XBitHack on
</Directory>
<Directory "/var/wwwroot/WEB-INF">
Order deny,allow
Deny from all
</Directory>
增加关于加载mod_jk的语句:
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf
在/var/wwwroot下建立一个index.jsp,启动Apache和Tomcat,用浏览器访问http://localhost/,应可看到正确的页面。
---------------------------------------------------------------------------------------------------------------
II.tomcat, apache整合后,去掉tomcat的8080端口服务,用户只能通过80端口访问服务器 (以统一日志分析等的处理):
找到server.xml, 去掉port="8080"
<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="5000" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
URIEncoding="UTF-8" useBodyEncodingForURI="true" />
---------------------------------------------------------------------------------------------------------------
III.Tomcat/Apache乱码问题解决
首先,确保 httpd.conf中的下面一行的注释没有打开(未配置AddDefaultCharset ):
#AddDefaultCharset ISO-8859-1
然后依情况按步骤1), 2)操作
如果你的网页中定义的charset为UTF-8, 如下
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
那么步骤1-2用UTF-8替代GBK
1)如果你将apache和tomcat整合了,那么修改tomcat/conf中的server.xml
<Connector port="8009" enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" URIEncoding="GBK"/>
添加URIEncoding="GBK",请确保你的jsp的开头:
<%@page contentType="text/html;charset=GBK"%>
里的charset和URIEncoding一致。 (均为GBK或UTF-8)
2)如果没有将tomcat和apache整合,那么修改如下的标签:
<Connector
port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" URIEncoding="GBK"/>
参考:
http://www.gbunix.com/htmldata/2006_08/15/23/article_1383_1.html
http://dev.cbw.com/web/apache/2005524308_3480676.shtml
---------------------------------------------------------------------------------------------------------------
IV.虚拟主机配置:
删除掉下面这一行的#(取消注释)
#Include conf/extra/httpd-vhosts.conf
vi conf/extra/httpd-vhosts.conf, 根据文件中的例子添加虚拟主机。
参考:
http://httpd.apache.org/docs/2.2/vhosts/name-based.html
http://httpd.apache.org/docs/2.2/vhosts/examples.html
hacking linux - find an unkown command for a desired function in a special linux distribution
I met the problem sometimes. and got the solution by "man -k command" .
Case 1: when i use ant files to build eclipse project, error occurred as "ant: /bin/sh^M: bad interpreter: No such file or directory." , which is described on the post:
Use eclipse with ant to deploy your java project -- from beginning of env setup to ant build .
I googled and find a post on apache mailing list, people suggest use unixdos to convert text file "ant" from dos format to unix format. I type unixdos, failed with "command not found". After thinking a while, I type :
$ man -k dos |grep -i unix
ExtUtils::MM_DOS (3) - DOS specific subclass of ExtUtils::MM_Unix
fromdos (1) - convert DOS text file format to UNIX
mcopy (1) - copy MSDOS files to/from Unix
mtools (1) - utilities to access DOS disks in Unix
todos (1) - convert UNIX text file format to DOS
Yes, fromdos, it is what i am finding. here i use man and grep to find the proper command.
Case 2: I need to convert GBK encoded text file to UTF-8 format. and googled around several times, couldn't get any useful info.
%man -k convert |grep -i encoding
the command could not find any useful command, thought it a lit while, hmmm, i need a command for character conversion
%man -k convert | grep -i character
...
%man -k conversion |grep -i character
fwprintf [wprintf] (3) - formatted wide character output conversion
iconv (3) - perform character set conversion
iconv_close (3) - deallocate descriptor for character set conversion
iconv_open (3) - allocate descriptor for character set conversion
...
Yes, iconv is exactly what i need.
Google is dangerous
new things. If you post an article on a newsgroup saying that you use yahoo
or baidu.com to hack a problem, someone would tell you "developers all use
google to solve problem".
Yes, it is true, google has been more 'n more important in our life, and it
does help, especially for developers. Sometimes, I spend a whole day or more
in googling a solution (it does has great help).
The problem is, when I use google more and more, someday I found that even I
need google to find some common knowledge. But I think these googled common
knowledge and other similar( ungoogled ) should be learned from books or an
official web site.
The keypoint is, there are lots of common knowledge, if I don't know these
things, even i don't kown what to google; Also when using google to learn a
new technology, it would cost much time than deserved when you know little
about the technology.
So if i use google more 'n more, i would be more 'n more lazy, impetuous.
The solution: to read more books, and learn from newgroups, some website.
SVN 项目管理使用FAQ
* Author David Lv Euler
* Createddate 2007-2-1
* Contact david.ullua at gmail (please add .com to gmail)
* You can redistribute the total file wherever you like, but pls keep the
author's info. The document is provided WITHOUT any warranty.
****************************************************************/
1.如何将eclipse的项目添加到SVN管理:
a.对于建立好的项目(未受SVN管理),在eclipse中,右键点击项目名,点"ShareProject", 选"SVN",点"下一步"
b.选择"创建新的资源库位置",或者"使用已有的资源库位置",选择资源库后点"下一步",
c.假定选择或者创建的资源库位置为svn://172.16.100.26, 通常要选择服务器上特定的目录下面保存项目,
比如在svn://172.16.100.26/dev-source/app/下面,那么就选择"使用指定的模块名",
点浏览并选择:svn://172.16.100.26/dev-source/app/,
这个时候在输入框里面会有一个"New Folder"被选中, 把New Folder改为项目的名称。点"下一步"。
2.如何利用eclipse(已安装subclipse插件), 从SVN上取得项目到本地的Workspace中:
a. Eclipse 中点"File" -> "New" -> "other" , 选择SVN, "从SVN取出项目".
b. 选择"创建新的资源库位置",或者"使用已有的资源库位置",选择资源库后点"下一步"
c. 选择要导出的项目在SVN上的路径,比如dev-source/monternet/Server,
点"Next", 选择"做为新项目取出,
并使用新建项目向导进行配置", 点Finish. 这时会弹出New Project的向导,
因为项目在SVN上,本地上没有,所以会出现这个向导。
d. 在新建项目向导中,选择"Java" -> "Java Project"(比如ServerCore可能需要选择这个),
或者 "Web" -> "Dynamic Web Project" (比如LinuxWebSite项目可能需要选择这个).
点"Next", 输入Project name, 比如RobooProject. 点Next, 点"Finish"。
这样就完成了从SVN服务器上取出项目到Eclipse的workspace中
3. 为什么提交总是失败。
需要注意两点:
a.若与Tortoise 同时使用,那么尽量不要同时使用Tortoise和eclipse对一个目录进行操作。
b.在把其他目录的文件拷贝到受SVN管理的项目中时, 需要按目录提交,而不是按文件提交。
c.在对类名/文件名进行重构时,需要按目录(文件所在的目录)提交,而不是对单个的文件进行提交。
4.SVN客户端的常用命令有哪些?
如果装了Subversion, 在windows和linux下都可以用命令行来获取SVN上的信息。 有几个命令比较常用:
svn co
svn list
svn info
svn add
svn commit
比如
svn list svn://172.16.100.26/dev-doc/ , 显示服务器上指定目录的内容
svn co svn://172.16.100.26/dev-doc/ , 获取服务器上的内容
svn info svn://172.16.100.26/dev-doc/tools/subversion/svn_tutorial.txt , 显示SVN
上指定文件的信息。
svn info 显示当前受SVN 管理的目录信息。
svn add files_on_local_disk 添加本地文件到SVN 管理(此命令尚未将文件上传到SVN中)
svn commit (提交所做的改动, 上传用svn add 命令添加的文件)
5. 如何使用命令获取SVN的项目到eclipse中进行管理?
用命令获取项目, 再从eclipse打开项目会更方便。比如获取ServerCore项目, 我这样做:
1. svn co svn://172.16.100.26/dev-src/ServerCore(获取服务器上的项目到当前目录下,会产生RobooCore
目录)
2.从eclipse新建项目, 指定步骤1中获取到的项目目录. 这样就完成了从SVN获取项目到Eclipse.
比前面问题2中的a, b, c, d 四步要方便很多。
6. 为什么会遇到 Authentication Failed?
Authentication Failed通常是因为没有对应目录的权限所导致。
7. 为什么我遇到 Out of date: '/dev-src/xxx/yyy' in transaction '102-1'
当本机修改的文件不是服务器上的最新版本,修改本机文件后commit, 会提示out of date的错误。
需要先从服务器上获取最新版本(update), 然后进行修改,这时候再提交就可以了。
About Me
- euler
- I am a senior developer and a team leader with 3 years development experience in Suzhou, China, focus on mobile web search, linux, Java and machine learning in NLP (natural language processing). My goal is to improve people's life with computer technology.