2/20/2007

TCL/TK 与 C 程序的集成

一、 简介

  比较TCL/TK 提供的快速而又容易的开发图形拥护界面,X 程序显得很烦琐。Tcl/tk 是一种脚本语言,就象其它的一些脚本语言一样,也有很多事情不能够做或很难做。解决途径是联合 C 与 tcl/tk 一起来开发. tcl/tk 系统提供C 程序调用TCL/TK 的解释器来运行TCL/TK脚本。提供的库包括初始化变量的方法,调用不同的脚本和访问变量。利用这些混合变量对它们访问X固有的特性也提供了好处。简单的回调和时间函数允许程序员制定事件,注册一个C函数为TCL/TK的过程的能力成为一个强大的工具。这篇文档覆盖了TCL/TK脚本与C 集成的一些基础知识。  编译选项部分描述了变量库并包含了建立程序的必要文件。 初始化与注册名令部分解释了怎样开始,怎样从TCL/TK脚本中调用C函数,最后一部分访问变量阐述了怎样来从C函数里来读与写TCL/TK变量。

二、编译选项

  为了能访问TCL/TK 库,必须在你的源代码中要设置一些常规的例程做并编译它。有两个调用库的头文件被声明。
  #include
  #include
  编译混合应用程序需要指出正确的编译目录,正确的库,并设置正确的连接标志。在TCL/TK顶部的设置也是必须要包含的文件。而下面的设置是在使用 g++ 时要设置的。你的系统依赖于编译器和文件的定位可能有不同的变化。
-I/software/tcl-7.4/include
-I/software/tk-4.0/include
-I/software/x11r5_dev/Include
-L/software/tcl-7.4/lib
-L/software/tk-4.0/lib
-L/software/x11r5_dev/lib
-ltk
-ltcl
-lX11

三、初始化与注册命令

  建立混合 tcl/tk & C 应用程序的中心要围绕几条选择命令。
  首先就是"Tk_Main" 函数, 它用来控制整个 tcl/tk 解释器程序。这条命令没有返回值,因此,它需在你的"main" 函数中加下划线,你所有程序的一旦初始化,"Tk_Main" 函数带来三个变量。第二个变量是一个字符串型数组,每个字符串都有一个特殊的含义。第一个变量表示在这个数组的元素个数。第三个变量是指向初始化函数的指针。此初始化函数在许多地方都要被执行。字符串数组通过"Tk_Main"来通知tcl/tk解释器应用程序的名称和tcl/tk 命令在脚本中的位置。这个数组实际上是传给解释器的命令行参数。数组的第一项给出应用程序名称,第二项给出了运行的脚本位置。如果脚本没有在相同的执行目录下,则需要完整路径。由于继承原因,tcl/tk 需要字符串在许多函数里可以修改,它也有函数作用范围的问题,避免这些问题最早的办法是传递时动态分配字符串下面的代码碎片显示了调用 利用"Hello World" 应用程序和脚本"hello.tcl"来调用 "Tk_Main"。
// prototype for the initialization function
int InitProc( Tcl_Interp *interp );
// declare an array for two strings
char ppszArg[2];
// allocate strings and set their contents
ppszArg[0] = (char )malloc( sizeof( char ) 12 );
ppszArg[1] = (char )malloc( sizeof( char ) 12 );
strcpy( ppszArg[0], "Hello World" );
strcpy( ppszArg[1], "./hello.tcl" );
// the following call does not return
Tk_Main( 2, ppszArg, InitProc );

初始化函数
  "Tk_Main" 的调用控制了你的程序在tcl/tk中的整个调用,但是在底部初始化之后和tcl/tk 脚本运行之前,能够执行用户自定义的函数。上面的例子中展示了这个类型的函数: "InitProc". 用户定义的初始化函数必须要返回一个整数类型并产生一个指向解释器的参数Tcl_Interp 。在初始化函数里面建立实际解释器调用"Tk_Init"。"Tk_Init"函数设置一个指向解释器的参数,这正是传递到初始化函数的指针。下面的代码仅只是初始化函数,更多的则是在后面列出。
int InitProc( Tcl_Interp *interp )
{
int iRet;
// Initialize tk first
iRet = Tk_Init( interp );
if( iRet != TCL_OK)
{
fprintf( stderr, "Unable to Initialize TK!\n" );
return( iRet );
} // end if
return( TCL_OK );
} // end InitProc

C函数作为 tcl/tk 过程
  现在你要熟悉在tcl/tk 脚本中的过程调用。当设计混合应用程序中有tcl/tk的过程调用C函数是可能的。完成它需要调用"Tcl_CreateCommand" 函数。这是在初始化函数里的常用做法。在tcl/tk 过程中调用函数就象调用其它的过程一样。在tcl/tk 脚本中存在就不必声明这个过程。函数注册有一个特定原型的过程。它们必须要返回一个整数类型,并设置4个变量,第一个是tcl/tk库文件类型"ClientData"。第二个变量是指向解释器的指针。最后的两个变量类似于在C "main"函数中的 "argc" 和 "argv" 这两个变量被用于传递参数给tcl/tk 过程。参数"argc" 包含了传递给tcl/tk过程的参数个数"argv" 是字符串数组,每个字符串包含了一个参数。
  int Myfunc( ClientData Data, Tcl_Interp *pInterp, int argc, char argv[] );
  当一个函数被注册作为tcl/tk 过程使用时需一个指针与之联系,指针通过"ClientData"来传递进来。"ClientData"的概念允许程序员联系数据结构和对象,调用能引用这个对象的过程。这个结构不经常需要。象早先提到的注册过程需要调用"Tcl_CreateCommand" 函数。这个函数有5个参数。第一个参数是指向解释器的指针,第二个参数是在tcl/tk 中的过程名,第三个参数是一个指向函数的指针,它在当tcl/tk过程被执行时调用。最后两个参数是 "ClientData" 项, 一个指针删除例程。它允许C函数在程序退出为了清空联系对象的结构时被调用。象指向删除函数的指针"ClientData"不经常调用。下面是tcl/tk 过程调用"hey_there" 来调用上面声明的"Myfunc"进行注册的例子。
Tcl_CreateCommand( interp, "hey_there", Myfunc, (ClientData)NULL,
(Tcl_CmdDeleteProc )NULL );

变量访问
  在执行tcl/tk过程时能调用C函数并允许你从C中获得tcl/tk的帮助,为了从tcl/tk 中获得C的帮助,这有一系列函数,其中包含了从tcl/tk变量中处理获得的信息和设置的信息。

Tcl_GetVar
  "Tcl_GetVar" 函数返回一个指向tcl/tk变量的字符串指针。这个函数有三个参数:指向解释器的指针,tcl/tk 变量的名称,一个标志flag。这个变量在执行脚本联系到解释器的当前范围被访问。如果在当前范没有局部变量则访问全局变量。如没有匹配的全局变量存在则返回一个错误。 Flags参数允许你指定TCL_GLOBAL_ONLY, 为了使这个函数仅仅访问此变量名的全局变量,下面是tcl/tk 脚本中被访问的一部分代码。
set say_hello_to "World"
下面的代码是在C里访问tcl/tk变量"say_hello_to".
char sHelloTo[30];
// after this call sHelloTo should contain "World"
strncpy( sHelloTo, Tcl_GetVar( pInterp, "say_hello_to", 0 ), 29 );

Tcl_SetVar
  "Tcl_SetVar"函数允许程序员修改tcl/tk变量的值。此函数有四个参数:第一个是解释器指针,第二个是要修改值的tcl/tk变量名称,第三个是要修改的新值,最后一个是tcl/tk标志flags。"Tcl_SetVar" 的标志flags跟"Tcl_GetVar"的相同。当设置期间遇到出错时"Tcl_SetVar"函数返回NULL值。如果变量不存在,则此函数将在解释器指针引用的脚本内建立一个新的变量。下面的代码将设置tcl/tk变量"say_hello_to"的值为"World"。
Tcl_SetVar( pInterp, "say_hello_to", "World", 0 );

集成C & tcl/tk 应用程序的例子
  这个应用程序展示了集成C和TCL/TK所需要的基础。此应用程序展示了一系列的登录框和按钮。当信息从登录框输入和按钮被按下时,其他的空域也被相应的更新。这有许多分享内存设备的接口,是调用大型应用程序的方法。这个接口需要头文件在下面没有包含进来,因此不修改而编译此应用程序是不可能的。但就阅读来说这并不是一个坏的示例。
The Makefile
The script file: pr1
The C file: proof.c
#!/.software/local/.admin/bins/bin/wish -f
#============================================================
# xmail
# by Christopher Trudeau, Copyright 1997
#
# This tcl/tk script displays a desktop clock which goes inverse video when
# new mail arrives. A pull down menu allows the user to launch remote login
# sessions on servers specified in the "hosts" variable. The sessions have
# the appropriate "xhost" and "DISPLAY" values.
#
# Comments and criticism on this program are greatly appreciated. Feel free to
# send me a note at ctrudeau@etude.uwaterloo.ca. This material is copyright
# but non-commercial institutes have permission to reproduce the program in
# its entirety, all other uses require explicit written permission of the
# author.
#============================================================
#------------------------------------------------------------
# Global Settings
#-----------------------------------------------------------
# fill in the following list for hosts that you wish to access, spaces or tabs
# separating the names of the hosts; eg:
#
# set hosts "ampere etude watt.uwaterloo.ca"
set hosts "ampere watt ohm morse novice"
#------------------------------------------------------------
# Procedures
#-------------------------------------------------------------
# proc prRefreshDisplay - called periodically to refresh the displayed time and
# status of the mail box
proc prRefreshDisplay {} {
global last
# get the time
set i [exec date]
set i [ string range $i 11 15 ]
# get the mailbox status
catch {[exec frm -q -s new]} mail
if { [string first "no" $mail] == -1 } {
# "You have new mail." results in white on black
.lTime configure -fg white -bg black -text $i
# if first time set, do the double beep thing
if { $last == 0 } {
bell
after 120
bell
}
set last 1
} else {
# "You have no new mail." results in black on white
.lTime configure -fg black -bg white -text $i
set last 0
}
after 15000 prRefreshDisplay
}
#------------------------------------------------------------
# Main Code
#------------------------------------------------------------
# create the main window and place it if specified
wm title . "xmail"
set args [lindex $argv 0]
string trim $args -if
{ $args == "geometry" } {
wm geometry . [lindex $argv 1]
}
# figure out what terminal name we are at
set userName [exec whoami]
set termName [exec who ]
set temp [string first $userName $termName]
set termName [string range $termName $temp end]
set temp [string first ( $termName]
set temp2 [string first ) $termName]
set termName [string range $termName $temp $temp2]
set termName [string trim $termName "()"]
# initialize variables and widgets
set last 0
set font "-*--medium-r-normal--*-120-*--*--*-"
set font2 "-*--medium-r-normal--*-100-*--*--*-"
label .lTime -font $font
# create the menu button
menubutton .mMenu -relief raised -font $font2 -text ">" -menu .mMenu.m
menu .mMenu.m -tearoff 0
.mMenu.m add cascade -label "xterms" -menu .mMenu.m.xterms
#create the sub menu "xterms"
menu .mMenu.m.xterms -tearoff 0
.mMenu.m.xterms add command -label "local" -command {exec xterm -title local &}
set count 0
set hostN [lindex $hosts $count]
while { $hostN != "" } {
catch { exec xhost $hostN }
set cmd "exec rsh $hostN xterm -display $termName:0 -title $hostN &"
.mMenu.m.xterms add command -label $hostN -command $cmd
incr count 1
set hostN [lindex $hosts $count]
}
.mMenu.m add separator
.mMenu.m add command -label "Exit" -command exit
pack .lTime .mMenu -side left
prRefreshDisplay
#-----------------------------------------------------------
CC = gcc
DEPEND = makedepend
TCL_DIR = /software/tcl-7.4
TK_DIR = /software/tk-4.0
INCS = -I$(TCL_DIR)/include -I$(TK_DIR)/include -I/software/x11r5_dev/Include
LIBS = -L/software/x11r5_dev/lib -L$(TCL_DIR)/lib -L$(TK_DIR)/lib
CCFLAGS= $(INCS) $(LIBS) -g -Wall
LFLAGS = -ltk -ltcl -lX11 -lsocket -lm
ALLDEFINES = -DDEBUG
.SUFFIXES: .c .o .cpp
.c.o:
$(CC) $(CCFLAGS) $(ALLDEFINES) -c $< .cpp.o: g++ -g -Wall $(ALLDEFINES) -c $*.cpp PROOF_C = proof.c PROOF_O = proof.o all: proof proof: $(PROOF_O) $(CC) $(CCFLAGS) $(ALLDEFINES) -o $@ $(PROOF_O) $(LFLAGS) clean: rm -f *.o proof core depend:: $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(PROOF_C) # DO NOT DELETE THIS LINE proof.o: /usr/include/stdio.h /usr/include/sys/feature_tests.h proof.o: /usr/include/stdlib.h /usr/include/string.h /usr/include/tcl.h proof.o: /usr/include/tk.h /usr/include/stddef.h /usr/include/sys/types.h proof.o: /usr/include/sys/isa_defs.h /usr/include/sys/machtypes.h proof.o: /usr/include/unistd.h /usr/include/sys/unistd.h ../pbx2.h proof.o: /usr/include/sys/ipc.h /usr/include/sys/msg.h /usr/include/sys/shm.h proof.o: /usr/include/sys/time.h /usr/include/errno.h proof.o: /usr/include/sys/errno.h /usr/include/signal.h proof.o: /usr/include/sys/signal.h ../he2.h #!/.software/local/.admin/bins/bin/wish -f #============================================================ # pr1 # by Christopher Trudeau, Copyright 1997 # # This tcl/tk script is used in conjunction with proof.c to test the hardware # emulator for the SX4 project. # # Comments and criticism on this program are greatly appreciated. Feel free to # send me a note at ctrudeau@etude.uwaterloo.ca. This material is copyright # but non-commercial institutes have permission to reproduce the program in # its entirety, all other uses require explicit written permission of the # author. #============================================================ wm title . "Proof" #============================================================ # main window declarations #============================================================ # create the frames for each row of entry fields for {set i 0} {$i <>
#include
#include
#include
#include
#include
#include
#include "../pbx2.h"
#include "../he2.h"
//----------------------------------------------------------
// Global Variables
struct ifmem_t ifmem_p; // pointer to shared hardware memory
//-----------------------------------------------------------
// Function Prototypes
int InitProc(Tcl_Interp interp);
int cmdDoIt( ClientData clientData, Tcl_Interp *pInterp, int argc,
char *argv[] );
//-----------------------------------------------------------
int main()
{
char ppszArg[2];
int iMemId;
printf( "Starting proof...\n" );
// get pointer to shared interface memory
iMemId = shmget( IFMEM_KEY, sizeof( struct ifmem_t ), 0644);
ifmem_p = (struct ifmem_t )shmat( iMemId, 0, 0);
if( (int)ifmem_p == -1 )
{
printf( "Error: unable to access shared interface memory\n" );
exit( 0 );
} // end if -- failed to get interface memory
// initialize arguments for Tk_Main
ppszArg[0] = (char )malloc( sizeof( char ) 8 );
ppszArg[1] = (char )malloc( sizeof( char ) 65 );
strcpy( ppszArg[0], "proof" );
strcpy( ppszArg[1], "/home3/ctrudeau/s/tcl/proof/pr1" );
printf( "Executing tcl/tk script\n" );
Tk_Main( 2, ppszArg, InitProc );
return( 0 );
} // end main
//-----------------------------------------------------------
int InitProc( Tcl_Interp interp )
{
int iRet;
// Initialize tk first
iRet = Tk_Init( interp );
if( iRet != TCL_OK)
{
printf( "Unable to Initialize TK!\n" );
return( iRet );
} // end if
// register any new tcl/tk commands
Tcl_CreateCommand( interp, "cmdDoIt", cmdDoIt, (ClientData)NULL,
(Tcl_CmdDeleteProc )NULL );
return( TCL_OK );
} // end InitProc
//-----------------------------------------------------------
// cmdDoIt
//
// This function is called as a command from tcl/tk. It is issued when the
// user pushes the "Do it" button. Each of the entry fields is checked
// for their contents and the interface memory is updated accordingly.
// The update to i/f mem is used to make connections between various cards
// and to put values into those cards (digits, loop back bits, etc)
//
int cmdDoIt( ClientData clientData, Tcl_Interp *pInterp, int argc,
char *argv[] )
{
int iSlot, iValue, iTrunk, iChan;
char sText[64];
fprintf( stderr, "****** Doing it\n" );
for( iTrunk=FIRST_TRUNK; iTrunk<=LAST_TRUNK; iTrunk++ ) { sprintf( sText, "entryTrunk(%d)", iTrunk ); iValue = atoi( Tcl_GetVar( pInterp, sText, 0 ) ); ifmem_p->serv_shelf[iTrunk] = iValue;
fprintf( stderr, "card(2)(%d)=%d\n", iTrunk, iValue );
sprintf( sText, "entryTrunkCard(%d)", iTrunk );
iSlot = atoi( Tcl_GetVar( pInterp, sText, 0 ) );
sprintf( sText, "entryTrunkChan(%d)", iTrunk );
iChan = atoi( Tcl_GetVar( pInterp, sText, 0 ) );
if( iSlot == 0 iSlot > 30 )
continue;
if( iChan == 0 iChan > 30 )
continue;
ifmem_p->timesw_in_ctrl[2][iChan] = iTrunk;
fprintf( stderr, "TM2_IN(%d)=%d\n", iChan, iTrunk );
ifmem_p->timesw_out_ctrl[2][iSlot] = iChan;
fprintf( stderr, "TM2_OUT(%d)=%d\n", iSlot, iChan );
ifmem_p->spacesw_ctrl[iChan] = 10;
fprintf( stderr, "SS(%d)=10\n", iChan );
} // end for -- loop through MFSenders
fprintf( stderr, "\n\n" );
for( iSlot=FIRST_MFSEND; iSlot<=LAST_MFSEND; iSlot++ ) { sprintf( sText, "entryMFS(%d)", iSlot ); iValue = atoi( Tcl_GetVar( pInterp, sText, 0 ) ); ifmem_p->serv_shelf[iSlot] = iValue;
fprintf( stderr, "card(2)(%d)=%d\n", iSlot, iValue );
sprintf( sText, "entryMFSTrunk(%d)", iSlot );
iTrunk = atoi( Tcl_GetVar( pInterp, sText, 0 ) );
sprintf( sText, "entryMFSChan(%d)", iSlot );
iChan = atoi( Tcl_GetVar( pInterp, sText, 0 ) );
if( iTrunk <> LAST_TRUNK )
continue;
if( iChan == 0 iChan > 30 )
continue;
ifmem_p->timesw_in_ctrl[2][iChan] = iSlot;
fprintf( stderr, "TM2_IN(%d)=%d\n", iChan, iSlot );
ifmem_p->timesw_out_ctrl[2][iTrunk] = iChan;
fprintf( stderr, "TM2_OUT(%d)=%d\n", iTrunk, iChan );
ifmem_p->spacesw_ctrl[iChan] = 10;
fprintf( stderr, "SS(%d)=10\n", iChan );
} // end for -- loop through MFSenders
// 0 - don't update the MFRs as the code should do it
if( !atoi( argv[1] ) )
return( TCL_OK );
fprintf( stderr, "\n\n" );
for( iSlot=FIRST_MFRCV; iSlot<=LAST_MFRCV; iSlot++ ) { sprintf( sText, "entryMFR(%d)", iSlot ); iValue = atoi( Tcl_GetVar( pInterp, sText, 0 ) ); ifmem_p->serv_shelf[iSlot] = iValue;
fprintf( stderr, "card(2)(%d)=%d\n", iSlot, iValue );
} // end for -- loop through MFSenders
return( TCL_OK );
} // end cmdDoIt
//------------------------------------------------------------

11/05/2005

Cadence Affirma Calculator Help

vt transient voltage
it transient current

vf frequency voltage
if frequency current

vs source sweep voltage
is source sweep current (I vs V curves)

vdc DC voltage
op DC operating point

vn noise voltage
opt transient operating point

var design variable
mp model parameter

11/03/2005

常用tcp/ip端口

This file was taken from the IANA website. It is a list of the well known port numbers.

# /etc/services:
# $Id: services,v 1.4 1997/05/20 19:41:21 tobias Exp $
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
# Updated from RFC 1700, ``Assigned Numbers'' (October 1994). Not all ports
# are included, only the more common ones.

tcpmux 1/tcp # TCP port service multiplexer
echo 7/tcp
echo 7/udp
discard 9/tcp sink null
discard 9/udp sink null
systat 11/tcp users
daytime 13/tcp
daytime 13/udp
netstat 15/tcp
qotd 17/tcp quote
msp 18/tcp # message send protocol
msp 18/udp # message send protocol
chargen 19/tcp ttytst source
chargen 19/udp ttytst source
ftp-data 20/tcp
ftp 21/tcp
fsp 21/udp fspd
ssh 22/tcp # SSH Remote Login Protocol
ssh 22/udp # SSH Remote Login Protocol
telnet 23/tcp
# 24 - private
smtp 25/tcp mail
# 26 - unassigned
time 37/tcp timserver
time 37/udp timserver
rlp 39/udp resource # resource location
nameserver 42/tcp name # IEN 116
whois 43/tcp nicname
re-mail-ck 50/tcp # Remote Mail Checking Protocol
re-mail-ck 50/udp # Remote Mail Checking Protocol
domain 53/tcp nameserver # name-domain server
domain 53/udp nameserver
mtp 57/tcp # deprecated
bootps 67/tcp # BOOTP server
bootps 67/udp
bootpc 68/tcp # BOOTP client
bootpc 68/udp
tftp 69/udp
gopher 70/tcp # Internet Gopher
gopher 70/udp
rje 77/tcp netrjs
finger 79/tcp
www 80/tcp http # WorldWideWeb HTTP
www 80/udp # HyperText Transfer Protocol
link 87/tcp ttylink
kerberos 88/tcp kerberos5 krb5 kerberos-sec # Kerberos v5
kerberos 88/udp kerberos5 krb5 kerberos-sec # Kerberos v5
supdup 95/tcp
# 100 - reserved
hostnames 101/tcp hostname # usually from sri-nic
iso-tsap 102/tcp tsap # part of ISODE.
csnet-ns 105/tcp cso-ns # also used by CSO name server
csnet-ns 105/udp cso-ns
# unfortunately the poppassd (Eudora) uses a port which has already
# been assigned to a different service. We list the poppassd as an
# alias here. This should work for programs asking for this service.
# (due to a bug in inetd the 3com-tsmux line is disabled)
#3com-tsmux 106/tcp poppassd
#3com-tsmux 106/udp poppassd
rtelnet 107/tcp # Remote Telnet
rtelnet 107/udp
pop2 109/tcp postoffice pop-2 # POP version 2
pop2 109/udp pop-2
pop3 110/tcp pop-3 # POP version 3
pop3 110/udp pop-3
sunrpc 111/tcp portmapper # RPC 4.0 portmapper TCP
sunrpc 111/udp portmapper # RPC 4.0 portmapper UDP
auth 113/tcp authentication tap ident
sftp 115/tcp
uucp-path 117/tcp
nntp 119/tcp readnews untp # USENET News Transfer Protocol
ntp 123/tcp
ntp 123/udp # Network Time Protocol
pwdgen 129/tcp # PWDGEN service
pwdgen 129/udp # PWDGEN service
netbios-ns 137/tcp # NETBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp # NETBIOS session service
netbios-ssn 139/udp
imap2 143/tcp imap # Interim Mail Access Proto v2
imap2 143/udp imap
snmp 161/udp # Simple Net Mgmt Proto
snmp-trap 162/udp snmptrap # Traps for SNMP
cmip-man 163/tcp # ISO mgmt over IP (CMOT)
cmip-man 163/udp
cmip-agent 164/tcp
cmip-agent 164/udp
mailq 174/tcp # Mailer transport queue for Zmailer
mailq 174/udp # Mailer transport queue for Zmailer
xdmcp 177/tcp # X Display Mgr. Control Proto
xdmcp 177/udp
nextstep 178/tcp NeXTStep NextStep # NeXTStep window
nextstep 178/udp NeXTStep NextStep # server
bgp 179/tcp # Border Gateway Proto.
bgp 179/udp
prospero 191/tcp # Cliff Neuman's Prospero
prospero 191/udp
irc 194/tcp # Internet Relay Chat
irc 194/udp
smux 199/tcp # SNMP Unix Multiplexer
smux 199/udp
at-rtmp 201/tcp # AppleTalk routing
at-rtmp 201/udp
at-nbp 202/tcp # AppleTalk name binding
at-nbp 202/udp
at-echo 204/tcp # AppleTalk echo
at-echo 204/udp
at-zis 206/tcp # AppleTalk zone information
at-zis 206/udp
qmtp 209/tcp # The Quick Mail Transfer Protocol
qmtp 209/udp # The Quick Mail Transfer Protocol
z3950 210/tcp wais # NISO Z39.50 database
z3950 210/udp wais
ipx 213/tcp # IPX
ipx 213/udp
imap3 220/tcp # Interactive Mail Access
imap3 220/udp # Protocol v3
rpc2portmap 369/tcp
rpc2portmap 369/udp # Coda portmapper
codaauth2 370/tcp
codaauth2 370/udp # Coda authentication server
ulistserv 372/tcp # UNIX Listserv
ulistserv 372/udp
ldap 389/tcp # Lightweight Directory Access Protocol
ldap 389/udp # Lightweight Directory Access Protocol
https 443/tcp # MCom
https 443/udp # MCom
snpp 444/tcp # Simple Network Paging Protocol
snpp 444/udp # Simple Network Paging Protocol
saft 487/tcp # Simple Asynchronous File Transfer
saft 487/udp # Simple Asynchronous File Transfer
npmp-local 610/tcp dqs313_qmaster # npmp-local / DQS
npmp-local 610/udp dqs313_qmaster # npmp-local / DQS
npmp-gui 611/tcp dqs313_execd # npmp-gui / DQS
npmp-gui 611/udp dqs313_execd # npmp-gui / DQS
hmmp-ind 612/tcp dqs313_intercell# HMMP Indication / DQS
hmmp-ind 612/udp dqs313_intercell# HMMP Indication / DQS
ipp 631/tcp # Internet Printing Protocol
ipp 631/udp # Internet Printing Protocol
#
# UNIX specific services
#
exec 512/tcp
biff 512/udp comsat
login 513/tcp
who 513/udp whod
shell 514/tcp cmd # no passwords used
syslog 514/udp
printer 515/tcp spooler # line printer spooler
talk 517/udp
ntalk 518/udp
route 520/udp router routed # RIP
timed 525/udp timeserver
tempo 526/tcp newdate
courier 530/tcp rpc
conference 531/tcp chat
netnews 532/tcp readnews
netwall 533/udp # -for emergency broadcasts
gdomap 538/tcp # GNUstep distributed objects
gdomap 538/udp # GNUstep distributed objects
uucp 540/tcp uucpd # uucp daemon
afpovertcp 548/tcp # AFP over TCP
afpovertcp 548/udp # AFP over TCP
remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem
klogin 543/tcp # Kerberized `rlogin' (v5)
kshell 544/tcp krcmd # Kerberized `rsh' (v5)
nntps 563/tcp snntp # NNTP over SSL
nntps 563/udp snntp # NNTP over SSL
ldaps 636/tcp # LDAP over SSL
ldaps 636/udp # LDAP over SSL
tinc 655/tcp # tinc control port
tinc 655/udp # tinc packet port
kerberos-adm 749/tcp # Kerberos `kadmin' (v5)
#
webster 765/tcp # Network dictionary
webster 765/udp
rsync 873/tcp # rsync
rsync 873/udp # rsync
ftps-data 989/tcp # FTP over SSL (data)
ftps 990/tcp # FTP over SSL
telnets 992/tcp # Telnet over SSL
telnets 992/udp # Telnet over SSL
imaps 993/tcp # IMAP over SSL
imaps 993/udp # IMAP over SSL
ircs 994/tcp # IRC over SSL
ircs 994/udp # IRC over SSL
pop3s 995/tcp # POP-3 over SSL
pop3s 995/udp # POP-3 over SSL
#
# From ``Assigned Numbers'':
#
#> The Registered Ports are not controlled by the IANA and on most systems
#> can be used by ordinary user processes or programs executed by ordinary
#> users.
#
#> Ports are used in the TCP [45,106] to name the ends of logical
#> connections which carry long term conversations. For the purpose of
#> providing services to unknown callers, a service contact port is
#> defined. This list specifies the port used by the server process as its
#> contact port. While the IANA can not control uses of these ports it
#> does register or list uses of these ports as a convienence to the
#> community.
#
socks 1080/tcp # socks proxy server
socks 1080/udp # socks proxy server
lotusnote 1352/tcp lotusnotes # Lotus Note
lotusnote 1352/udp lotusnotes # Lotus Note
ingreslock 1524/tcp
ingreslock 1524/udp
prospero-np 1525/tcp # Prospero non-privileged
prospero-np 1525/udp
datametrics 1645/tcp old-radius # datametrics / old radius entry
datametrics 1645/udp old-radius # datametrics / old radius entry
sa-msg-port 1646/tcp old-radacct # sa-msg-port / old radacct entry
sa-msg-port 1646/udp old-radacct # sa-msg-port / old radacct entry
radius 1812/tcp # Radius
radius 1812/udp # Radius
radius-acct 1813/tcp radacct # Radius Accounting
radius-acct 1813/udp radacct # Radius Accounting
rtcm-sc104 2101/tcp # RTCM SC-104 IANA 1/29/99
rtcm-sc104 2101/udp # RTCM SC-104 IANA 1/29/99
cvspserver 2401/tcp # CVS client/server operations
cvspserver 2401/udp # CVS client/server operations
venus 2430/tcp # codacon port
venus 2430/udp # Venus callback/wbc interface
venus-se 2431/tcp # tcp side effects
venus-se 2431/udp # udp sftp side effect
codasrv 2432/tcp # not used
codasrv 2432/udp # server port
codasrv-se 2433/tcp # tcp side effects
codasrv-se 2433/udp # udp sftp side effect
mon 2583/tcp # MON
mon 2583/udp # MON
dict 2628/tcp # Dictionary server
dict 2628/udp # Dictionary server
gds_db 3050/tcp # InterBase server
gds_db 3050/udp # InterBase server
icpv2 3130/tcp icp # Internet Cache Protocol (Squid)
icpv2 3130/udp icp # Internet Cache Protocol (Squid)
mysql 3306/tcp # MySQL
mysql 3306/udp # MySQL
rfe 5002/tcp # Radio Free Ethernet
rfe 5002/udp # Actually uses UDP only
cfengine 5308/tcp # CFengine
cfengine 5308/udp # CFengine
x11 6000/tcp x11-0 # X windows system
x11 6000/udp x11-0 # X windows system
x11-1 6001/tcp # X windows system
x11-1 6001/udp # X windows system
x11-2 6002/tcp # X windows system
x11-2 6002/udp # X windows system
x11-3 6003/tcp # X windows system
x11-3 6003/udp # X windows system
x11-4 6004/tcp # X windows system
x11-4 6004/udp # X windows system
x11-5 6005/tcp # X windows system
x11-5 6005/udp # X windows system
x11-6 6006/tcp # X windows system
x11-6 6006/udp # X windows system
x11-7 6007/tcp # X windows system
x11-7 6007/udp # X windows system
afs3-fileserver 7000/tcp bbs # file server itself
afs3-fileserver 7000/udp bbs # file server itself
afs3-callback 7001/tcp # callbacks to cache managers
afs3-callback 7001/udp # callbacks to cache managers
afs3-prserver 7002/tcp # users & groups database
afs3-prserver 7002/udp # users & groups database
afs3-vlserver 7003/tcp # volume location database
afs3-vlserver 7003/udp # volume location database
afs3-kaserver 7004/tcp # AFS/Kerberos authentication
afs3-kaserver 7004/udp # AFS/Kerberos authentication
afs3-volser 7005/tcp # volume managment server
afs3-volser 7005/udp # volume managment server
afs3-errors 7006/tcp # error interpretation service
afs3-errors 7006/udp # error interpretation service
afs3-bos 7007/tcp # basic overseer process
afs3-bos 7007/udp # basic overseer process
afs3-update 7008/tcp # server-to-server updater
afs3-update 7008/udp # server-to-server updater
afs3-rmtsys 7009/tcp # remote cache manager service
afs3-rmtsys 7009/udp # remote cache manager service
font-service 7100/tcp xfs # X Font Service
font-service 7100/udp xfs # X Font Service
wnn6 22273/tcp # wnn6
wnn6 22273/udp # wnn6

#=========================================================================
# The remaining port numbers are not as allocated by IANA.
#
# Kerberos (Project Athena/MIT) services
# Note that these are for Kerberos v4, and are unofficial. Sites running
# v4 should uncomment these and comment out the v5 entries above.
#
kerberos4 750/udp kerberos-iv kdc # Kerberos (server) udp
kerberos4 750/tcp kerberos-iv kdc # Kerberos (server) tcp
kerberos_master 751/udp # Kerberos authentication
kerberos_master 751/tcp # Kerberos authentication
passwd_server 752/udp # Kerberos passwd server
krb_prop 754/tcp # Kerberos slave propagation
krbupdate 760/tcp kreg # Kerberos registration
kpasswd 761/tcp kpwd # Kerberos "passwd"
swat 901/tcp # swat
kpop 1109/tcp # Pop with Kerberos
knetd 2053/tcp # Kerberos de-multiplexor
zephyr-srv 2102/udp # Zephyr server
zephyr-clt 2103/udp # Zephyr serv-hm connection
zephyr-hm 2104/udp # Zephyr hostmanager
eklogin 2105/tcp # Kerberos encrypted rlogin
# Hmmm. Are we using Kv4 or Kv5 now? Worrying.
# The following is probably Kerberos v5 --- ajt@debian.org (11/02/2000)
kx 2111/tcp # X over Kerberos
#
# Unofficial but necessary (for NetBSD) services
#
supfilesrv 871/tcp # SUP server
supfiledbg 1127/tcp # SUP debugging
#
# Datagram Delivery Protocol services
#
rtmp 1/ddp # Routing Table Maintenance Protocol
nbp 2/ddp # Name Binding Protocol
echo 4/ddp # AppleTalk Echo Protocol
zip 6/ddp # Zone Information Protocol
#
# Services added for the Debian GNU/Linux distribution
#
linuxconf 98/tcp # LinuxConf
poppassd 106/tcp # Eudora
poppassd 106/udp # Eudora
imsp 406/tcp # Interactive Mail Support Protocol
imsp 406/udp # Interactive Mail Support Protocol
ssmtp 465/tcp smtps # SMTP over SSL
nqs 607/tcp # Network Queuing system
moira_db 775/tcp # Moira database
moira_update 777/tcp # Moira update protocol.
moira_ureg 779/udp # Moira user registration.
omirr 808/tcp omirrd # online mirror
omirr 808/udp omirrd # online mirror
customs 1001/tcp # pmake customs server
customs 1001/udp # pmake customs server
rmiregistry 1099/tcp # Java RMI Registry
skkserv 1178/tcp # skk jisho server port
predict 1210/udp # predict -- satellite tracking
rmtcfg 1236/tcp # Gracilis Packeten remote config server
xtel 1313/tcp # french minitel
xtelw 1314/tcp # french minitel
support 1529/tcp # GNATS
sieve 2000/tcp # Sieve mail filter daemon
cfinger 2003/tcp lmtp # GNU Finger / Local Mail Transfer Protocol
ndtp 2010/tcp # Network dictionary transfer protocol
ninstall 2150/tcp # ninstall service
ninstall 2150/udp # ninstall service
zebrasrv 2600/tcp # zebra service
zebra 2601/tcp # zebra vty
ripd 2602/tcp # RIPd vty
ripngd 2603/tcp # RIPngd vty
ospfd 2604/tcp # OSPFd vty
bgpd 2605/tcp # BGPd vty
ospf6d 2606/tcp # OSPF6d vty
afbackup 2988/tcp # Afbackup system
afbackup 2988/udp # Afbackup system
afmbackup 2989/tcp # Afmbackup system
afmbackup 2989/udp # Afmbackup system
xtell 4224/tcp # xtell server
fax 4557/tcp # FAX transmission service (old)
hylafax 4559/tcp # HylaFAX client-server protocol (new)
pcrd 5151/tcp # PCR-1000 Daemon
noclog 5354/tcp # noclogd with TCP (nocol)
noclog 5354/udp # noclogd with UDP (nocol)
hostmon 5355/tcp # hostmon uses TCP (nocol)
hostmon 5355/udp # hostmon uses UDP (nocol)
postgres 5432/tcp # POSTGRES
postgres 5432/udp # POSTGRES
mrtd 5674/tcp # MRT Routing Daemon
bgpsim 5675/tcp # MRT Routing Simulator
canna 5680/tcp # cannaserver
sane 6566/tcp saned # SANE network scanner daemon
ircd 6667/tcp # Internet Relay Chat
ircd 6667/udp # Internet Relay Chat
ircd-dalnet 7000/tcp # IRC - Dalnet
ircd-dalnet 7000/udp # IRC - Dalnet
webcache 8080/tcp # WWW caching service
webcache 8080/udp # WWW caching service
tproxy 8081/tcp # Transparent Proxy
tproxy 8081/udp # Transparent Proxy
omniorb 8088/tcp # OmniORB
omniorb 8088/udp # OmniORB
mandelspawn 9359/udp mandelbrot # network mandelbrot
amanda 10080/udp # amanda backup services
kamanda 10081/tcp # amanda backup services (Kerberos)
kamanda 10081/udp # amanda backup services (Kerberos)
amandaidx 10082/tcp # amanda backup services
amidxtape 10083/tcp # amanda backup services
smsqp 11201/tcp # Alamin SMS gateway
smsqp 11201/udp # Alamin SMS gateway
xpilot 15345/tcp # XPilot Contact Port
xpilot 15345/udp # XPilot Contact Port
isdnlog 20011/tcp # isdn logging system
isdnlog 20011/udp # isdn logging system
vboxd 20012/tcp # voice box system
vboxd 20012/udp # voice box system
binkp 24554/tcp # Binkley
binkp 24554/udp # Binkley
asp 27374/tcp # Address Search Protocol
asp 27374/udp # Address Search Protocol
dircproxy 57000/tcp # Detachable IRC Proxy
tfido 60177/tcp # Ifmail
tfido 60177/udp # Ifmail
fido 60179/tcp # Ifmail
fido 60179/udp # Ifmail

10/27/2005

Tcl与SWIG

可能大家不是很熟悉swig这个名字,它的全称是Simple Wrapper and Interface Generator.它是干什么用的呢?是用来把C语言子程序包装成一些脚本语言的命令用的.比如,不少人喜欢使用Tcl/Tk来写点界面,但Tcl/Tk的数学功能实在太差,有时候就想自己给它扩充一些数学函数.又比如说,用Perl写个CGI程序,想用一个已经现成的自己编好的C语言子程序来处理用户返回的数据.这时候就用得上swig了.
其实刚才举的那些脚本语言都有自己的扩充接口,比如Perl有XS格式,Tcl/Tk有一套扩充内核用的C语言函数库.例如,要给Tcl扩充一个myfract命令,用来实现阶乘,可以这样做:

(1)写一个C语言程序,假设叫做fract.c,内容如下:

#include "tcl.h"

int Tcl_myfract(ClientData notUsed, Tcl_Interp interp, int argc, char
{
int i, j;
double res=1.0;
char re[30];
if (argc > 2)
{
Tcl_AppendResult(interp, "wrong args: should be myfract
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[1], &i) != TCL_OK)
{
return TCL_ERROR;
}
for (j=1;j<=i;j++)
res = j;
sprintf(re,"%le",res);
Tcl_SetResult(interp, re, TCL_VOLATILE);
return TCL_OK;
}

int Fract_Init(Tcl_Interp Interp) {
Tcl_CreateCommand (Interp, "myfract", Tcl_myfract, (ClientData)
return TCL_OK;
}

(2)运行以下命令:
gcc -c fract.c
gcc -shared -o fract.so fract.o
生成fract.so动态连接库

(3)在tcl程序中加上"load ./fract.so"一句话,就可以用myfract命令了.

这种做法可以实现Tcl/Tk的任意扩充,功能强大,但实在是太麻烦了.而且,如果又想扩充Perl,Python等,那又得用它们的接口重写一遍.swig可以提供比较方便的统一扩充接口,而不需要对各种语言的特点有所了解,所以在很多情况下很适合使用.

下面我们看看swig怎样完成刚才的工作.

(1)写一个C语言函数提供阶乘功能,例如写一个fract.c,内容为:

double myfract(int n)
{
double res=1.0;
int j;
for (j=1;j<=n;j++)
res = j;
return(res);
}

(2)写一个通用接口文件,后缀为.i,例如fract.i,内容为:

%module myfract
extern double myfract(int);

第一句的意思是生成的模块叫myfract,第二句就是按C语言格式声明要输出的函数,加上一个extern.

(3)运行swig -tcl fract.i,生成fract_wrap.c和fract_wrap.c(自动生成的文档)

(4)运行

gcc -c fract.c fract_wrap.c
gcc -ltcl -shared -o myfract.so fract.o fract_wrap.o
生成myfract.so

(5)在Tcl程序中加上"load ./myfract.so"即可.

显然比刚才的办法好懂多了.

如果要生成的是Perl模块,那么第三步改成"swig -perl fract.i",这时还会生成一个myfract.pm文件.运行第四步时,前一个命令要改成:

gcc -c fract.c fract_wrap.c -I/usr/lib/perl5/i586-linux/5.00404/CORE/ -Dbool=char

其中的路径是perl.h所在的目录,每台机器可能不一样.最后在Perl程序中加上"use myfract"即可.

swig的功能其实很强大,它可以分析C/C++源程序,可以生成HTML/LaTex/text文档,等等.大家可以看它的文档(很多的pdf文件).就说这些.

8/17/2005

解决在windows英文版下打开chm文件出现mk:@msitstore错误

我在安装的windows 2003 英文版下,直接点击打开*.chm文件时提示错误:cannot open mk:@msitstore:x盘:\文件名.chm

解决办法:(chm文件类型与HH.EXE程序关联正常的情况下)到系统控制面板中,把“Regional and Language Options”中的区域设置改为“Chinese(PRC)”即可。

6/18/2005

squid proxy server设置

1. 修改/etc/squid/squid.conf,可以修改端口等等常规配置
2. htpasswd /etc/squid/passwd username1,然后按照提示设置密码,然后可以重复加其他用户名和密码
3. 找到http_access deny all,修改成如下:
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd
acl alloweduser proxy_auth username1 username2 ...
http_access allow alloweduser

最后将squid服务设置成自动启动,更改了设置的,运行/etc/init.d/squid reload即可

6/06/2005

smalltalk学习笔记

Smalltalk是一门完全基于对象和消息的语言,在smalltalk中,一切都是对象。

Literal对象:这些对象的名字就决定了对象本身,比如数字,字符串。

Number对象:数字对象,比如7, 16rFF, 3.1415等等;

Char对象:字符对象,如$A,$7,$$等等;

String对象:字符串对象,如'This is a string','a string with an ''embedded string';

Array对象:如#(this is an array),#(12 'abc' (embedded array));

Symbol对象:如#aSymbol;

Identifiers标志符:分为三类,实例变量、类名、伪变量,类名首字母一定大写。

实例变量名必须声明才能使用,可以用<-来赋值;

伪变量无需声明,比如self、super、selfProcess、true、false、nil、smalltalk;

Messages消息:在smalltalk里,所有的操作都是通过给对象发送消息实现的。任何消息分为三个部分:一个receiver,一个消息selector,0个或者几个arguments。Message分为三类:unary消息,binary消息和keyword消息。

unary消息:没有argument,如7 sign,7 factorial;

binary消息:有一个argument,如7 + 4。从左到右的优先级,7 + 4 * 3返回33而不是19。但是unary消息比binary消息有更高的优先级;

keyword消息:keyword消息的selector包含一个或者多个keyword,每个keyword后边跟':',然后有一个argument。如7 max: 14,7 between:2 and: 24。keyword消息优先级更低;

Blocks:.意味着语句的结束,可以用[]将几个语句组合起来形成一个block,如[i<-i+1. i print]。Block可以被看作一个in-line的过程,所以它也可以有参数:[ :x :y | (x+y) print ]。

注释和续行:"This is a comment",\用于续行。

5/31/2005

WinXP优化大全

1、 缩短等待时间

打开注册表编辑器,找到 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control,将 WaitToKillServiceTimeout 设为:1000或更小(原设定值:20000)。

找到 HKEY_CURRENT_USER\Control Panel\Desktop 键,将右边窗口的 WaitToKillAppTimeout 改为 1000(原设定值:20000),即关闭程序时仅等待1秒。将 HungAppTimeout 值改为:200(原设定值:5000),表示程序出错时等待0.5秒。

2、 让系统自动关闭停止响应的程序

打开注册表 HKEY_CURRENT_USER\Control Panel\Desktop 键,将 AutoEndTasks 值设为 1(原设定值:0)。

3、 加快菜单显示速度

打开注册表编辑器,找到 HKEY_CURRENT_USER\Control Panel\Desktop,将其下的 MenuShowDelay 项改为:0,你的菜单将会出乎意料地快。

4、 加速共享查看

打开注册表编辑器,把HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace下的

{D6277990-4C6A-11CF-8D87-00AA0060F5BF} 删掉

5、 加快窗口显示速度:

打开注册表编辑器,找到HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics子键分支,在右边的窗口中找到MinAniMate键值,其类型为REG_SZ,默认情况下此健值的值为1,表示打开窗口显示的动画,把它改为0,则禁止动画的显示,接下来从开始菜单中选择“注销”命令,激活刚才所作的修改即可。



7、 删除共享文档:

默认情况下,在Windows XP中打开我的电脑,会看到在硬盘图标上方有一些文件夹。这些就是“共享文件夹”,这里有每一个用来户共享文件所用的文件夹。这些文件夹特别烦人,毫无必要。我们可以让这些文件夹在我的电脑中消失:

打开注册表编辑器,把HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\DelegateFolders下的

{59031a47-3f72-44a7-89c5-5595fe6b30ee}删掉,下次打开我的电脑,这些烦人的文件夹就不复存在了。

8、 加快Windows XP的启动:

(1)Windows XP自带了一个名为Prefetcher的服务,这个服务管理着Windows启动时的程序初始(即启动时滚动的蓝条),其中指定的程序可以在以后使用中快速载入。Prefetcher在默认情况下就是打开的,不过它的性能还可以进一步提升。打开注册表编辑器,在注册表中找到:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\MemoryManagement\PrefetchParameters,其中有一个键值名为EnablePrefetcher,多数情况下它的值是3。推荐设置值是5——在我的机子上,设为5的时候工作状态最佳。可以随便试试不同的数值,直到找到最适合自己机子的值为止。也可以把Prefetcher禁用掉,只需把值设为0就可以了。不过,除非是为了测试用途,一般人都不会傻到把它设为0。

(2)"我的电脑"->"属性"->"高级"->"启动和故障修复"中,点"错误报告",选择"禁用错误汇报"、"但在发生严重错误时通知我"。
(3)去掉"将事件写入系统日志","发送管理警报","自动重新启动"选项;将"写入调试信息"设置为"无"。

(4)点击"编辑",在弹出记事本文件中:
[Operating Systems]
timeout=30 //把缺省时间 30 秒改为 0 秒
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect //把缺省 fastdetect 改为 nodetect
注册表修改方法:"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control" ,SystemStartOptions键值改为NODETECT。

9、 加快Windows XP的重启和关机:

按下CTRL+ALT+DELETE打开Windows 任务管理器,然后选择关机(U),先按下CTRL,再按下关闭(U)或重新启动(R),就可以快速地关机或重启。

10、关闭计算机时自动结束任务:

在关机的时候,有时会弹出讨厌的对话框,提醒某个程序仍在运行,是否结束任务。其实完全可以通过一点点修改让Windows自动结束这些仍在运行的程序。在注册表中打开HKEY_CURRENT_USER\Control Panel\Desktop 目录,把里面的AugoEndTasks键值改为1
注:可能会找不到AutoEndTasks键值,如果是这样的话,自己建一个串值并把它改为这个名字,值设为1就可以了。

11、优化程序运行:

程序运行有他们各自的优先次序,所有程序都要占用处理器资源,处理器处理任务有一个先后次序,一般的计算机中有31个优先等级,系统的内核占据了最高的一些等级,这样就能保证系统的稳定,而普通的应用程序一般在比较后面的等级。在普通应用程序中间也有优先次序,他们本来在处理器面前是人人平等的,但还是有些细微的差别,前台的程序(当前正在使用)的优先级要比后台的程序高。你可以自己调节应用程序的优先级,打开任务管理器,点到“进程”选项卡,选一个应用程序的进程,点击右键,会弹出一个快捷菜单,选择“设置优先级”,这里有6个等级:实时,高,高与标准,标准,低于标准,低。你可以让你的程序强行调度到更高或更低(自然为别的程序腾出了资源)的等级。如果你不知道某个应用程序的具体进程,可以如下操作:点到“应用程序”选项卡,右键点中一个任务,选择“转到进程”,就会转到该程序的进程,这样你就找到了该程序的进程了。  

12、优化“启动和故障恢复”设置:

如果在你的系统崩溃时发现你的硬盘使劲儿的响,那是因为Windows XP正在写DUMP文件呢,对我们来说,如果你不打算把这个文件寄给微软(浪费电话费),那么它又有什么用呢?所以我的建议是关闭。右键单击“我的电脑”,点击属性,点击“高级”,在“启动和故障恢复”一栏中,点击“设置”,其中的“系统失败”一栏中,只选择“自动重新启动”,写入调试信息选择“无”。

13、禁用“错误汇报”功能:

这个功能可以在你的Windows XP发生错误的时候,系统自动收集一些错误资料然后发送给微软公司,以便其完善他们的操作系统(又一个浪费电话费且没用的功能),建议关掉它。如果这个功能对你没有用,那又何必让它占用着你的内存呢?右键单击“我的电脑”,点击属性,点击“高级”→“错误汇报”,选择“禁用错误汇报”功能。

14、关闭“Internet时间同步”功能:

如果启用了同步,你的计算机时钟每周就会和 Internet 时间服务器进行一次同步,建议关掉它(一个没多大用的功能)。请依次单击“开始”→“控制面板”→“日期、时间、语言和区域选项”,然后单击“日期和时间”→“Internet时间”。

15、关闭华医生Dr.Watson:

在"开始"->"运行"中输入"drwtsn32"命令,或者"开始"->"程序"->"附件"->"系统工具"->"系统信息"->"工具"->"Dr Watson",调出系统里的华医生Dr.Watson ,只保留"转储全部线程上下文"选项,否则一旦程序出错,硬盘会读很久,并占用大量空间。如以前有此情况,请查找user.dmp文件,删除后可节省几十MB空间。

16、设置IDE设备的DMA模式:

出于某些原因,Windows XP有时会在IDE通道上使用PIO并行输入输出传输模式,而不是DMA模式。如果有这种情况,用户可以手动把IDE通道改为DMA模式,这样可以减少该设备占用的CPU周期。打开设备管理器(右键点击我的电脑,选属性,点选硬件选项卡,点击“设备管理器”打开),然后点击展开“IDE ATA/ATAPI 控制器”分支,双击“Primary IDE Channel”,点击高级设置。检查“传输模式”下拉菜单,把它们全部设为DMA If Available(允许情况下使用DMA),点击确定。再用同样的方式修改每一个IDE控制器。

17、取消对zip文件的支持:

这是一个相当好的优化,Windows XP内置了对.ZIP文件的支持,我们可以把zip文件当成文件夹浏览。不过,系统要使用部分资源来实现这一功能,因此禁用这一功能可以提升系统性能。实现方法非常简单,只需取消zipfldr.dll的注册就可以了,点击开始—>运行,敲入:regsvr32 /u zipfldr.dll 然后回车即可。

18、关掉快速切换功能:

Win XP的一个很引人注目的功能叫做“快速切换”,这个功能为许多人在同一时间使用电脑提供了可能,但是要注意每一项功能总是伴随着资源的损失,如果你的内存少与64M,Win XP在装的时候就被自动禁止掉了,因为这样会使本来就已捉襟见肘的内存的压力更加大,对128M的用户来说,开这个功能虽然没什么关系,但是你又不是很需要这项功能,所以建议把这个功能给关掉。方法如下:控制面板-->用户帐户,点击“更改用户登陆或注销方式”,去掉“使用快速用户切换”就可以了。

19、为IRQ中断请求排优先次序:

这是一项非常有效的优化。计算机的每一个主要部件都设了个IRQ中断号。这里就是要通过修改每个IRQ请求的优先次序达到优化目的。这里主要的优化对象是系统/CMOS实时钟,它通过主板来提升性能。首先,要确定你想要哪个组件获得更高的性能,然后找到这个硬件正在使用的IRQ中断号。怎么找呢?打开控制面板里的系统属性(也可以按键盘上的Windows+Break热键组合打开它)。选中“硬件”选项卡,然后点击“设备管理器”按钮。右键点击要查IRQ号的组件,选择“属性”,然后点击“资源”选项卡。 这里可以看到设备正在使用的IRQ中断号(如果没有IRQ中断号,选择另一个设备)。把中断号记下来,然后运行注册表编辑器regedit,找到注册表中的HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\PriorityControl 位置。我们要在这里建立一个名为IRQ#Priority(其中“#”是具体的IRQ中断号)的DWORD双字节值,然后把它的值设为1。譬如说,我的系统CMOS实时钟的IRQ中断号是8,我要建立的键名就是IRQ8Priority。重新启动计算机之后,就会发现刚优化过的组件性能有所提高。笔者强烈建议用这个方法优化系统CMOS实时钟,因为它能改善整块主板的性能。当然也可以把多个IRQ中断号优先级提高,但这样做的效果没那么好,而且有可能造成系统不稳定。要把这个优化设置撤消的话,只要把刚才建立的注册表键值删掉就OK了。


6、 关掉不必要的服务:

如果你只是在单机使用WindowsXP,那么很多服务组件是根本不需要的,额外的服务程序大大拖慢了系统的速度,完全可以将这些多余的服务组件禁用。

下面我们就来看一下怎样关掉不必要的服务。单击“开始”→“设置”→“控制面板”。双击“管理工具”→“服务”,打开后将看到服务列表,有些服务已经启动,有些则没有。右键单击要配置的服务,然后单击“属性”。在“常规”选项卡上选择“自动”、“手动”或“禁用”,其中“自动”表示每次系统启动时,Windows XP都自动启动该服务;“手动”表示WindowsXP不会自动启动该服务,而是在你需要该服务时手动启动该服务;而“禁用”则表示不允许启动该服务。在实际配置时,选择“手动”或者“禁用”都可以实现关闭该服务的目的,推荐使用手动功能,这样你随时可以启动一些临时需要的服务。有些服务是WindowsXP所必需的,不能关闭,否则将会造成系统崩溃。至于各项服务的功能,我们可以通过双击该服务或将鼠标悬停在该服务名上查看。下面我们就先来看一看这些服务的说明,最后再看哪些服务可以关掉(见下表)。对于我们这些单机使用WindowsXP的普通用户来说,可以把表中服务关闭,如果你有特殊要求,可以参照表中说明自行配置Windows XP的服务,以便达到最优状态。

服务名称
如果符合下列条件,你可以将之关闭

alerter
你未连上局域网并且不需要管理警报

clipbook
你不需要查看远程剪贴簿的剪贴页面

distributed linktracking client
若不使用ntfs分区并且没有联入局域网

distributed transactioncoordinator
不需要同时处理多个数据库或者文件系统

fax service
不用windows 2000发送或者接收传真

ftp publishing service
你的计算机不做ftp服务器

iis admin service
你的计算机不做www服务器

indexing service
你的计算机不提供远程文件索引和快速访问或者没有连上局域网

internet connectionsharing
你不准备用windows2000做路由服务器,让多人共享一条线路上网

ipsec policy agent
你未连接到windows 2000的域

logical disk manageradministrative service
你不准备使用磁盘配额

message queuing
你未连接到windows 2000的域

messenger
你未连接到windows2000的域并且不需要管理警报

net logon
你不想让局域网上的其他用户登录

netmeeting remotedesktop sharing
你不想使用netmeeting远程管理计算机

network dde
你没有连入局域网

network dde dsdm
你没有连入局域网

performance logs andalerts
若不想知道计算机每一秒都干什么

qos rsvp
你没有使用依赖于qos的程序

remote access autoconnection manager
你不想在程序企图读取网络信息时自动连接到网络

remote procedure call (rpc)locator
你不需要管理rpc名称服务数据库

routing and remoteaccess
你的计算机不做路由器

runas service
你不需要在某一用户下以另外一个用户的身份执行一个程序

simple mail transportprotocol (smtp)
你的计算机不做邮件发送服务器

smart card
你没有智能卡阅读器

smart card helper
你没有旧式智能卡阅读器

snmp trap service
你没有连接到windows 2000的域

tcp/ip netbios helperservice
你的计算机不准备让别人共享

tcp/ip print server
不让你的计算机成为网络打印服务器

telnet
不想远程控制计算机执行控制台命令

uninterruptible powersupply
没使用ups或ups不支持双向传输信号

utility manager
不从一个窗口中启动和配置辅助工具

windows managementinstrumentation
你不看你的系统管理信息

world wide webpublishing service
你的计算机不做www服务器

5/13/2005

如何优化WinXP

1、减少磁盘空间占用
2、终止不常用的系统服务
3、安全问题
4、另外一些技巧

首先问一下,你是不是很想激活XP,不。。。准确的说你是不是想在ms的站上能够升级。如果答案是肯定的话,那我们就先来探讨一下安装的问题,目前流行的 V4、V5、V6版本我还是比较推荐的,尤其是V5和V6这两个。安装的过程中有个序列号的问题,我建议你先在机子上算好,然后用这个序列号安装,通常这样安装的XP都可以到MS的站点自由更新。
如果你是已经安装好的XP了,但用的序列号是里到处流传人人都用的那些,也没关系,我们后面会说用sysrep来重新封装的时候会解决序列号更换的问题。

我假设你已经安装完XP了

一、瘦身行动

1、在各种软硬件安装妥当之后,其实XP需要更新文件的时候就很少了。删除系统备份文件吧:开始→运行→sfc.exe /purgecache 近3xxM。

2、删除驱动备份: %windows%driver cachei386目录下的driver.cab文件,通常这个文件是76M。

3、偶没有看help的习惯,所以保留着%windows%help目录下的东西对我来说是一种伤害,呵呵。。。都干掉,近4xM。

4、一会在升级完成后你还会发现%windows%多了许多类似$NtUninstallQ311889$这些目录,都干掉吧,1x-3xM。

5、正好硬盘中还有win2000/server等,所以顺便把pagefile.sys文件都指向一个地方:控制面板→系统→性能—高级→虚拟内存→更改,注意要点“设置”才会生效。

6、卸载不常用组件:用记事本修改%windows%infsysoc.inf,用查找/替换功能,在查找框中输入,hide,全部替换为空。这样,就把所有的,hide都去掉了,存盘退出后再运行“添加-删除程序”,就会看见“添加/删除 Windows 组件”中多出不少选项;删除掉游戏啊,码表啊等不用的东西。

7、刪除windowsime下不用的輸入法,8xM。我重新安装了自己用的zrm输入法,赫赫。

8、如果实在空间紧张,启用NTFS的压缩功能,这样还会少用2x% 的空间,不过我没作。

9、关了系统还原,这破功能对我这样常下载、测试软件的人来说简直是灾难,用鼠标右健单击桌面上的“我的电脑”,选择“属性”,找到“系统还原”,选择“在所有驱动器上关闭系统还原”呵呵,又可以省空间了。

10、还有几个文件,挺大的,也没什么用。。。。忘了名字 :( ,刚安装的系统可以用查找功能查找大于50M的文件来看看,应该能找到的。

如果你能按照上面的过程做完,你的原本1.4G的XP,完全可以减少到800以下。

二、加速计划

WinXP的启动会有许多影响速度的功能,尽管ms说已经作最优化处理过,但对我们来说还是有许多可定制之处。我一般是这样来做的。

1、修改注册表的run键,取消那几个不常用的东西,比如Windows Messenger 。启用注册表管理器:开始→运行→Regedit→找到 “HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRunMSMSGS” /BACKGROUND 这个键值,右键→删除,世界清静多了,顺便把那几个什么cfmon的都干掉吧。

2、修改注册表来减少预读取,减少进度条等待时间,效果是进度条跑一圈就进入登录画面了,开始→运行→regedit启动注册表编辑器,找 HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerMemory ManagementPrefetchParameters,有一个键EnablePrefetcher把它的数值改为“1”就可以了。另外不常更换硬件的朋友可以在系统属性中把总线设备上面的设备类型设置为 none(无)。

3、关闭系统属性中的特效,这可是简单有效的提速良方。点击开始→控制面板→系统→高级→性能→设置→在视觉效果中,设置为调整为最佳性能→确定即可。这样桌面就会和win2000很相似的,我还是挺喜欢XP的蓝色窗口,所以在“在窗口和按钮上使用视觉样式”打上勾,这样既能看到漂亮的蓝色界面,又可以加快速度。

4、我用Windows commadner+Winrar来管理文件,Win XP的ZIP支持对我而言连鸡肋也不如,因为不管我需不需要,开机系统就打开个zip支持,本来就闲少的系统资源又少了一分,点击开始→运行,敲入: “regsvr32 /u zipfldr.dll”双引号中间的,然后回车确认即可,成功的标志是出现个提示窗口,内容大致为:zipfldr.dll中的Dll UnrgisterServer成功。

5、据说XP的一个系统服务Qos,这个调度要占用一定的网络带宽,像我这样的一毛不拔的人是无法忍受的,去掉方法是:开始菜单→运行→键入 gpedit.msc ,出现“组策略”窗口, 展开 "管理模板”→“网络” , 展开 "QoS 数据包调度程序",在右边窗右键单击“限制可保留带宽" ,在属性中的“设置”中有“限制可保留带宽" ,选择“已禁用”,确定即可。当上述修改完成并应用后,用户在网络连接的属性对话框内的一般属性标签栏中如果能够看到"QoS Packet Scheduler(QoS 数据包调度程序)"。说明修改成功,否则说明修改失败,顺便把网络属性中的那个Qos 协议也一起干掉(卸载)吧。

6、快速浏览局域网络的共享
通常情况下,Windows XP在连接其它计算机时,会全面检查对方机子上所有预定的任务,这个检查会让你等上30秒钟或更多时间。去掉的方法是开始→ 运行→Regedit→在注册表中找到 HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrent VersionExplorerRemoteComputerNameSpace。在此键值下,会有个{D6277990-4C6A-11CF-87- 00AA0060F5BF}键,把它删掉后,重新启动计算机,Windows XP就不再检查预定任务了,hoho~~~ ,速度明显提高啦!

7、关掉调试器Dr. Watson
我好像从win95年代开始一次也没用过这东西,可以这样取消:打开册表,找到 HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionAeDebug子键分支,双击在它下面的Auto键值名称,将其“数值数据”改为0,最后按F5刷新使设置生效,这样就取消它的运行了。沿用这个思路,我们可以把所有具备调试功能的选项取消,比如蓝屏时出现的memory.dmp,在“我的电脑→属性→高级→设置→写入调试信息→选择无”等等。

8、被我终止的服务列表以及相关说明

1)alerter 错误警报
2)automatic updates windows 自动更新
3)background intelligent transfer service 微软说使用空闲的网络带宽传数据
4)clipbook 与远程电脑来共享剪贴板内容,我看还是免了吧
5)Computer browser 说什么要维护网络更新列表
6)DHCP client 我不需要这东西
7)Distributed link tracking client 保持局域网连接更新等信息,偶很少用局域网,这东西占用4M左右内存。
8)Distributed Transaction coordinator 协调xxx,和上面的差不多
9)DNS Client 我不需要这东西
10)Error reporting service 错误报告
11)Event Log 系统日志纪录
12)Fast user switching compatibility 用户切换
13)help and support 帮助
14)Human interface device access 据说是智能设备。。。
15)IMAPI CD-burning COM service 偶不用这个刻碟
16)Indexing service 索引,索引什么呢?
17)Internet Connection Firewall(ICF) ICF防火墙
18)IPSEC Services 这个我不懂,你想知道问Quack去
19)Logical Disk manager administrative service 配置磁盘
20)messenger 好像net send 等东西用的就是这个功能
21)MS software shadow copy provider 卷复制备份的
22)Net Logon 我可不想让黑客远程登录进来,关!
23)Netmeeting remote desktop sharing 我不用netmeeting
24)Network DDE  动态数据交换传输
25)Network DDE DSDM 和上面差不多
26)Network Location Awareness 关,我的机子不作共享
27)NTLM Security support provider-telnet 呵呵,关!
28)Performance logs and alert 将系统状态写日志或发警告
29)Portable media serial number 关!
30)Print Spooler 打印机,不幸的是我的机子不连接Print ~
31) QoS RSVP 关!
32)Remote desktop help session manager 远程帮助服务
33)remote Procedure Call LOCATOR 管理RPC
34)remote registry 远程管理注册表
35)removable storage 
36)routing and remote access 我干脆禁用了它
37)security accounts manager 我的系统只是一个客户系统,不用iis。
38)smart card
39)smart card helper 关!!!
40)SSDP Discovery service 我用不到这个
41)system event notification 如果是服务器肯定要记录的
42)system restore service 系统还原服务
43)task scheduler windows 计划服务
44)Telephony 拨号服务,我不拨号还不行吗?
45)telnet
46)terminal services 终端服务
47)uninterruptible power supply UPS,我没有呀
48)universal plug and play device host 太先进了点,用不到
49)upload manager 关了也能传输文件的
50)volume shadow copy 又是备份,晕
51)webclient 没用过
52)Windows Installer MSI服务,我一直关着。
53)windows image acquisition (WIA) 数码设备用的
54)windows management instrumentation driver extensions 关了
55)windows time 时间服务
56)wireless zero configuration 无线网络,偶用不到的
57)WMI perfromance adapter 关!

这里面的一些服务是刚开始就是关的,但我忘了,所以只好把现在系统中关闭的服务基本都列了出来。你根据自己的情况酌情处理吧。

三、我安全吗

多了不谈,基本的共享还是得关的:

修改注册表为以下两个样式:
去除共享
——————————————————————
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServiceslanmanserverparameters]
"AutoShareServer"=dword:00000000
"AutoSharewks"=dword:00000000
——————————————————————
去除IPC$管理
——————————————————————
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLsa]
"restrictanonymous"=dword:00000001
——————————————————————
或者将上面两个保存成个.REG文件,然后双击导入就可以了。

顺便把不要脸的的3721也屏蔽,在hosts文件中加入:

127.0.0.1 cnsmin.3721.com
127.0.0.1 http://www.3721.net/

四、其他技巧

1、给鼠标右键增加个复制到.../移动到...功能
—————————————————————
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREClassesAllFilesystemObjectsshellex]

[HKEY_LOCAL_MACHINESOFTWAREClassesAllFilesystemObjectsshellexContextMenuHandlers]

[HKEY_LOCAL_MACHINESOFTWAREClassesAllFilesystemObjectsshellexContextMenuHandlersCopy To]
@="{C2FBB630-2971-11D1-A18C-00C04FD75D13}"

[HKEY_LOCAL_MACHINESOFTWAREClassesAllFilesystemObjectsshellexContextMenuHandlersMove To]
@="{C2FBB631-2971-11D1-A18C-00C04FD75D13}"
————————————————————————
将上面内容保存成add.reg文件,然后双击导入就可以了。

2、关了错误报告,KAO !这东西搞得我像个微软免费的测试员似的:点击控制面板---->系统---->高级---->右下角--->错误报告---->禁用错误汇报——>确定!
3、取消分组显示:右键单击任务栏的空白区域,在弹出的菜单中选择“属性”,在弹出的窗口中,取消“分组相似任务栏按钮”前面的对钩,确定就可以了。
4、找回经典的登录窗口,WinXP默认的登录界面虽然漂亮,但如果你想用一个列表中没有的用户登录,你会发现无从下手,改回经典窗口的方法是:点击“开始”→“控制面板”→“用户账户”→“更改用户登录或注销的方式”→把“使用欢迎屏幕”前面的对钩取消,最后点“应用选项”就OK啦。
5、将自己最常用的输入法设置一个快捷键:点击“开始”→“控制面板”→“区域和语言选项”→在弹出的窗口中选择“语言”→“详细信息”→“键设置”在弹出的窗口中找到自己用的输入法,点“更改按键顺序”→在这里选一个快捷键就可以了。
6、关闭计算机时自动结束不响应的任务,注册表:HKEY_CURRENT_USERControl PanelDesktop 中的“AugoEndTasks”的键值改为“1”
7、关闭自动更新:右键单击“我的电脑”,点击属性,点击“自动更新”,在“通知设置”一栏选择“关闭自动更新。我将手动更新计算机”一项。
8、减少开机磁盘扫描等待时间,开始→运行,键入“chkntfs/t:0”

然后连接到ms站点顺便升级一次就算优化基本完成,对于XP而言,可以采用许多内部命令来看看优化情况,比如tasklist.exe /svc 可以查看系统服务实际使用情况。
优化一个系统,挺麻烦的。所以我们把他保存起来,我们用Ghost生成.GHO文件,这样就可以拿给别人炫耀一下啦,在Ghost之前先要作一个事情,清除系统硬件、注册等信息,否则克隆到不同的机子上将无法启动,在Winxp安装盘上找Deploy.cab 中的sysprep.exe文件。
执行sysprep.exe,选择“重新封装”,下面的标记中可以选择“已提前激活”,还可以选择封装完成后是关机还是重新启动。封装完成后,我们再用带有Ghost的系统盘启动,用Ghost来生成备份.GHO镜像,备份完成!
在执行封装后,重新开机,XP会让我们输入序列号,文中开头所提到的换序列号的办法就是这样换

4/09/2005

一个完整WebServer的建立过程

平台为Fedora Core/Apache, 动态页面是PHP5.x, 数据库是mysql4.X

--------------------------------------------------------------------------------
登陆webserver,以root身份打开httpd
打开进入/etc/httpd/conf/httpd.conf,找到UserDir disable,关闭此项;同时找到#UserDir public_html,去掉注释;找到index.html,加上index.php
在自己用户下建立一public_html目录,讲自己的用户主目录权限改成至少711,public_html目录改成至少755
如果希望以http://hostname/username/方式访问,可以在/var/www/html/下建立一个soft link指向/home/username/public_html,link名字叫username
测试webserver是否工作正常
--------------------------------------------------------------------------------
下载php5.x软件包,解压,然后配置:./configure --with-apxs2=/usr/sbin/apxs --with-libxml-dir --with-openssl --with-zlib --with-zlib-dir --enable-bcmath --with-bz2 --enable-calendar --with-jpeg-dir --with-tiff-dir --with-curl --with-curlwrappers --with-inifile --with-flatfile --enable-dio --enable-exif --with-fam --enable-filepro --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-ttf --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --without-iconv --with-imap --with-kerberos --with-imap-ssl --with-ldap --with-ldap-sasl --enable-mbstring --with-libmbfl --with-openssl-dir --with-mysql --with-mysql-sock --enable-shmop --enable-sqlite-utf8 --with-sqlite --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-expat-dir --with-iconv-dir --with-pcre-regex --with-pear --enable-maintainer-zts --enable-memory-limit
编译make然后安装make install
在public_html目录下建立一个index.php,里面就一个函数: phpinfo(),用浏览器访问,看看php是否工作正常,这时应该看到php版本是4.3.x,因为/etc/http/conf.d/php.conf文件中已经加载了libphp4.so,而/etc/httpd/conf/httpd.conf中加载了libphp5.so,会互相冲突,所以应该注释掉libphp4.so,这样再测试,就是5.0.4版本了,而且配置也全了。
--------------------------------------------------------------------------------
增加一个usergroup: mysql
增加一个用户: mysql
将下载的mysql-xx-xx.tar.gz解压到/usr/local/mysql目录下
./scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
chgrp -R mysql data
bin/mysqld_safe --user=mysql & (注意用户必须对data目录有读写权限)
--------------------------------------------------------------------------------
下载phpMyAdmin
解压到自己的用户目录,设置好用户权限
通过浏览器访问这个目录http://hostname/phpmyadmin/
按提示完成设置
在phpmyadmin目录下,编辑config.inc.php文件:
$cfg['PmaAbsoluteUri'] = ' ' 改成 $cfg['PmaAbsoluteUri'] = 'https://hostname/phpmyadmin/';
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password 改成
$cfg['Servers'][$i]['user'] = 'mysql'; // MySQL user
$cfg['Servers'][$i]['password'] = 'password'; // MySQL password