linux下执行脚本,提示Command not found解决办法

遇上了这个坑,搞了好久没搞定,参考了前辈的文章,终于搞好了,分享如下

原文地址:http://www.cnblogs.com/GordonWorld/archive/2012/03/19/2406225.html

Linux下执行.sh脚本错误:bin/sh^M: bad interpreter: No such file or directory

      原因是.sh脚本在windows系统下用记事本文件编写的。不同系统的编码格式引起的。

转行文件的编码格式:

1、确保用户对文件有读写及执行权限

     oracle@linux-106:~/RMAN/bin> chmod a+x test.sh

2、然后修改文件格式

   (1)使用vi工具

     oracle@linux-106:~/RMAN/bin> vi test.sh

    (2)利用如下命令查看文件格式 
     :set ff 或 :set fileformat 
     可以看到如下信息 
     fileformat=dos 或 fileformat=unix 
     (3) 利用如下命令修改文件格式 
     :set ff=unix 或 :set fileformat=unix 
     :wq (存盘退出)

3、最后再执行

    oracle@linux-106:~/RMAN/bin> ./test.sh

Linux下执行.sh脚本错误:command not found

      command not found这个问题一般都是像我这样的新手才会犯的,所以刚学linux的童鞋们遇到这个问题可以看看我的解释,可能会给你帮助。

      其实这个问题可能是很多原因引起的,今天我碰到原因很值得关注,一般我们在写java代码的时候定义变量都喜欢这样写” String  test  =  “ ”; ”。今天我写了一个shell脚本,在脚本里定义了一个变量,(“host = “””),结果执行的时候出现了这个command not found。我是冥思苦想啊,怎么想也想不出为什么,后来我终于发现问题的所在了就是一个空格在作怪,其实在定义shell脚本的变量时在变量名和等号之间是不允许有空格的,而我写的是test和=之间有空格,所以系统默认为,test是一个命令,所以系统找不到这个命令。切记切记,小问题有时候也会让你停滞不前的。

  • 21
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
rootkit后门检测工具RKHunter RKHunter是一款专业的检测系统是否感染rootkit的工具,它通过执行一系列的脚本来确认服务器是否已经感染rootkit。在官方的资料中,RKHunter可以作的事情有: MD5校验测试,检测文件是否有改动 检测rootkit使用的二进制和系统工具文件 检测特洛伊木马程序的特征码 检测常用程序的文件属性是否异常 检测系统相关的测试 检测隐藏文件 检测可疑的核心模块LKM 检测系统已启动的监听端口 下面详细讲述下RKHunter的安装与使用。 1、安装RKHunter RKHunter的官方网页地址为:http://www.rootkit.nl/projects/rootkit_hunter.html,建议从这个网站下载RKHunter,这里下载的版本是rkhunter-1.4.0.tar.gz。RKHunter的安装非常简单,过程如下: 1 2 3 4 5 6 7 [root@server ~]# ls rkhunter-1.4.0.tar.gz [root@server ~]# pwd /root [root@server ~]# tar -zxvf rkhunter-1.4.0.tar.gz [root@server ~]# cd rkhunter-1.4.0 [root@server rkhunter-1.4.0]# ./installer.sh --layout default --install 这里采用RKHunter的默认安装方式,rkhunter命令被安装到了/usr/local/bin目录下。 2、使用rkhunter指令 rkhunter命令的参数较多,但是使用非常简单,直接运行rkhunter即可显示此命令的用法。下面简单介绍下rkhunter常用的几个参数选项。 [root@server ~]#/usr/local/bin/rkhunter–help Rkhunter常用参数以及含义如下所示。 参数 含义 -c, –check必选参数,表示检测当前系统 –configfile 使用特定的配置文件 –cronjob作为cron任务定期运行 –sk, –skip-keypress自动完成所有检测,跳过键盘输入 –summary显示检测结果的统计信息 –update检测更新内容 -V, –version显示版本信息 –versioncheck检测最新版本 下面是通过rkhunter对某个系统的检测示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 [root@server rkhunter-1.4.0]# /usr/local/bin/rkhunter -c [ Rootkit Hunter version 1.4.0 ] #下面是第一部分,先进行系统命令的检查,主要是检测系统的二进制文件,因为这些文件最容易被rootkit攻击。显示OK字样表示正常,显示Warning表示有异常,需要引起注意,而显示“Not found”字样,一般无需理会 Checking system commands... Performing 'strings' command checks Checking 'strings' command [ OK ] Performing 'shared libraries' checks Checking for preloading variables [ None found ] Checking for preloaded libraries [ None found ] Checking LD_LIBRARY_PATH variable [ Not found ] Performing file properties checks Checking for prereq
1. 概要 这是嵌入式PowerPC, ARM和MIPS系统中使用DENX U-Boot和Linux的指导手册。文档中描述了如何在嵌入式PowerPC, ARM和MIPS系统上配置、编译、使用Das U-Boot(常常缩写为“U-Boot”)和Linux操作系统。文档中涵盖了所有你可能需要的用于配置、编译、运行U-Boot和Linux的工具。 2. 绪论 首先,我们介绍如何安装交叉编译开发工具Embedded Linux Development Kit(ELDK),这个开发套件你很有可能会用到——至少当你在标准的x86 PC上使用Linux或者Sun Solaris系统作为开发环境的时候,你会需要它的。 然后,我们会阐述通过串口与你的目标板连接:你需要配置一个终端控制程序,如cu或者kermit。 你常常需要通过网线把映像文件下载到你的目标板上。为了实现这个目的,你需要TFTP和DHCP/BOOTP服务器。文档中提供了简要的相关配置说明。 接下来则是描述如何配置和编译U-Boot使之适用于某个特定的平台,以及如何安装和在该硬件平台上运行。 下一步的工作是配置、建立和安装Linux。我们使用SELF(Simple Embedded Linux Framework)来展示如何建立一个开发环境(包括通过NFS挂载的根文件系统)和一个嵌入式目标板配置(从基于busybox的ramdisk映像文件中运行)。 本文档不会给出如何把U-Boot或者Linux移植到一个新的硬件平台,而是默认你的开发板已经被U-Boot和Linux所支持。 本手册各种文档格式的最新版本可以从以下网址获取: · HTML http://www.denx.de/wiki/publish/DULG/DULG-canyonlands.html · plain ASCII text http://www.denx.de/wiki/publish/DULG/DULG-canyonlands.txt · PostScript European A4 format http://www.denx.de/wiki/publish/DULG/DULG-canyonlands.ps · PDF European A4 format http://www.denx.de/wiki/publish/DULG/DULG-canyonlands.pdf 3. 嵌入式Linux开发工具套件 嵌入式Linux开发工具套件(ELDK)包括GNU交叉开发工具,如编译器、binutils、gdb等工具,和一些已经编译好的目标工具以及负责提供在目标平台上函数调用的库文件。还免费提供了所有的源代码,包括全部补丁、扩展文件、以及用于编译开发工具使用的程序和脚本。安装包都是基于RPM包管理器。 3.1 获取ELDK 可以通过以下方式获得ELDK。 ·DENX计算机系统光盘 ·从以下服务器中下载 FTP方式 ftp://mirror.switch.ch/mirror/eldk/eldk/ ftp://sunsite.utk.edu/pub/linux/eldk/ ftp://ftp.sunet.se/pub/Linux/distributions/eldk/ ftp://ftp.leo.org/pub/eldk/ HTTP方式 http://mirror.switch.ch/ftp/mirror/eldk/eldk/ http://ftp.sunet.se/pub/Linux/distributions/eldk/ http://archiv.leo.org/pub/comp/os/unix/linux/eldk/ 3.2 初始安装 初始安装可以使用放在ELDK目录树根目录下的安装工具。安装工具使用语法如下; $ ./install [-d ] [] [] … -d 确定ELDK安装在哪个目录。如果省略ELDK会安装在当前目录。 确定目标平台的CPU。如果此项设置了一项以上的参数,则会将这些CPU的支持都安装。如果省略将会安装所有CPU的支持。你也可以把ELDK安装到任何空目录下,这么做的唯一条件是你有那个目录的写和执行权限。安装过程并不需要超级用户的特权。由安装时的参数决定安装几个目标组件集合。ELDT包是肯定会安装的。 $ export CROSS_COMPILE=ppc_4xx- //加入环境变量 $ PATH=$PATH:/opt/eldk/usr/bin:/opt/eldk/bin //加入PATH 这样加入的话,每次重启系统后必须重新加入,一劳永逸的办法是编辑/root/.bashrc 加上 export CROSS_COMPILE=ppc_4xx- export PATH=$PATH:/opt/eldk/usr/bin:/opt/eldk/bin 重启系统后即可使用ELDK。 4. 系统设置 在目标平台上安装和配置U-Boot和Linux需要一些工具。特别是在开发过程中,你需要和目标平台保持联系。这一节将告诉你如何配置你的主机以达到上述目的。 4.1 设置串口 为了更好地使用U-Boot和Linux,你需要通过串口将目标板和你的主机连接。U-Boot和Linux可以配置成自动执行而不需要任何用户的干涉。 通过串口有很多种方法来控制你的目标板,比如说使用终端服务器。不过最常见的做法是使用你本机的串口,这时,你主机需要安装一个终端程序,如cu或者kermit。 4.2 配置“kermit” kermit这个名字就代表了它是连接串口和网络的通信软件。事实上在很多计算机和操作系统上使用它,能够很好地满足我们的目的。 kermit在执行其它命令之前,会执行你的用户目录下的初始文件.kermrc,所以可以非常简单的通过初始化命令来定制kermit。下面是使用U-Boot和Linux时推荐配置: ~/.kermrc: set line /dev/ttyS0 set speed 115200 set carrier-watch off set handshake none set flow-control none robust set file type bin set file name lit set rec pack 1000 set send pack 1000 set window 5 这个设置假定你使用的是主机第一个串口(/dev/ttyS0),以115200这个波特率与目标板的串口连接。 然后你可以连接目标板了: $ kermit -c Connecting to /dev/ttyS0, speed 115200. The escape character is Ctrl-\ (ASCII 28, FS) Type the escape character followed by C to get back, or followed by ? to see other options. —————————————————- 下载kermit这个软件时,你会发现有两个kermit包。你只需要安装ckermit。其中gkermit仅仅是实现kermit传输协议的一个命令行工具。如果你主机上的Linux系统没有安装kermit,你可以到kerimt的官方网站 http://www.columbia.edu/kermit/ 下载。 4.3 使用minicom minicom是另外一种非常流行的串口通信终端。很遗憾的是,很多用户发现在使用U-Boot和Linux时,minicom有很多问题,尤其是试图使用它来下载image的时候。因此,不推荐大家使用minicom。 4.4 配置TFTP服务器 使用U-Boot下载Linux内核或者应用程序的最快捷的方法是通过网络传输。为了这一目的,U-Boot实现了TFTP协议(参见U-Boot中的tftpboot命令)。为了使主机支持TFTP,你必须确保TFTP后台程序/usr/sbin/in.tftpd已经安装。在RedHat系统中,你可以运行下面的命令来确认: $ rpm -q tftp-server 如果没有安装,请从你的Linux安装盘或者其它媒介安装。 大多数的Linux发行版都默认关闭TFTP服务。以RedHat系统为例,如果要使能TFTP服务,编辑文件/etc/xinetd.d/tftp,移除这一行: disable = yes 或者注释掉它,或者修改disable = no 此外,确保/tftpboot目录存在,而且有访问权限(至少应该"dr-xr-xr-x")。 5. Das U-Boot 5.1 当前版本 Das U-Boot(或者简称“U-Boot”)是针对嵌入式PowerPC, ARM, MIPS和x86处理器的开放源代码软件。U-Boot项目已经在Sourceforge设立,你可以访问这个官方网站:http://www.denx.de/wiki/UBoot U-Boot最新版的源代码可以在Sourcefoge通过匿名CVS得到。当要求输入匿名用户anonymous的密码时只需要直接按下回车键。 $ cvs -d:pserver:[email protected]:/cvsroot login $ cvs -z6 -d:pserver:[email protected]:/cvsroot co -P u-boot 官方发布的U-Boot也可以通过FTP方式获取。你可以到ftp://ftp.denx.de/pub/u-boot/下载tar形式的压缩包。 或者通过git的方式获取: git clone git://www.denx.de/git/u-boot.git u-boot/ git clone http://www.denx.de/git/u-boot.git u-boot/ git clone rsync://www.denx.de/git/u-boot.git u-boot/ 5.2 源代码包的解压 如果你是通过CVS得到的U-Boot源代码,你可以跳过这一步,因为你得到的已经是解压后的目录树了。如果你是从FTP服务器上下载的tar压缩包,那么你需要按照以下步骤解压: $ cd /opt/eldk/usr/src $ wget ftp://ftp.denx.de/pub/u-boot/u-boot-1.3.2.tar.bz2 $ rm -f u-boot $ bunzip2 < u-boot-0.4.5.tar.bz2 | tar xf - $ ln -s u-boot-0.4.5 u-boot $ cd u-boot 5.3 配置 $ export BUILD_DIR=/opt/eldk/build //指定编译的输出目录 进入U-Boot源代码根目录后,可以先使用如下命令确保已经清除以前编译的结果: $ make distclean 下一步是为Makalu板配置U-Boot: $ make makalu_config (译者注:应该根据你自己的具体开发板配置,如$ make _config,如果没有相应的开发板,应该自己照着建立相应的目录和配置文件。) 最后我们可以开始编译U-Boot了: $ make all 5.4 安装 5.4.1 动手之前 5.4.1.1 安装所需 以下的章节假定你的开发板使用flash作为存储设备。如果不是,则以下的指令不会工作。如果你想使用U-Boot,需要换掉存储设备。 5.4.1.2 开发板识别数据 所有的Makalu开发板使用一个序列号加以识别。而且开发板需要分配一个以太网MAC地址。如果这些数据丢失,你可能会失去授权。在安装U-Boot或者改变开发板的配置之前,你需要搜集足够的信息。 5.4.2 使用BDM/JTAG调试器安装U-Boot.bin 把数据烧入flash中的一个简单而又快速的办法是通过BDM或者JTAG接口的调试器或者flash烧写器。当flash中没有任何数据(比如说一块新的开发板),这种方法是唯一的选择。 我们(强烈推荐)使用Abatron公司的BDI2000(见http://www.abatron.ch/BDI/bdiGDB.html )。 其它的BDM/JTAG调试器也可以使用,但是如何操作它们不是本文档要讨论的范围。如果你想使用别的工具请参照它们的说明文档。(我没有使用BDI2000,故略去操作BDI2000的方法。我烧写u-boot.bin就是简单地通过JTAG口。) 5.4.3 使用U-Boot安装U-Boot.bin 如果U-Boot已经在你的板子上安装运行,你可以使用这些命令来下载新的U-Boot映像来代替当前的。 警告:在你安装新的映像之前,你必须擦除当前的u-boot.bin。如果出现什么差错,你的开发板将不能运行。因此强烈建议: 做一个能工作的U-Boot映像文件的备份; 你清楚如何在一个新的开发板上安装u-boot.bin。 过程如下: => tftp 100000 /tftpboot/uboot.bin ARP broadcast 1 TFTP from server 10.0.0.2; our IP address is 10.0.0.100 Filename ””/tftpboot/uboot.bin””. Load address: 0×100000 Loading: ############################### done Bytes transferred = 155376 (25ef0 hex) => protect off 40000000 4003FFFF Un-Protected 5 sectors => era 40000000 4003FFFF Erase Flash from 0×40000000 to 0x4003ffff ……… done Erased 5 sectors => cp.b 100000 40000000 $(filesize) Copy to Flash… done => setenv filesize => saveenv Saving Enviroment to Flash… Un-Protected 1 sectors Erasing Flash… .. done Erased 1 sectors Writing to Flash… done Protected 1 sectors => reset 5.5 工具的安装 U-Boot加载Linux内核、Ramdisk或者其它映像时使用一种特殊的映像格式。这种格式包含了一些信息,如创建时间、操作系统、压缩格式、映像类型、映像名和CRC32校验和。 mkimage用来创建这种格式的映像文件或者显示它包含的信息。如果使用ELDK,那么mkimage这个命令已经包含在ELDK中。 如果你不想使用ELDK,你应该把mkimage安装在某个能够直接执行的目录里,比如: $ cp tools/mkimage /usr/local/bin/ 5.6 初始化 初始化你的Makalu板上的U-Boot,你需要通过终端连接板子的串口。 Makalu板的串口默认配置是波特率为115200/8N1(115200bps,每个字符8bit,无奇偶校验,1bit停止位,无握手)。 如果你的主机是Linux操作系统,我们建议你用kermit或者cu作为终端控制程序。确定硬件和软件控制流都已经关闭。 5.7 开始的步骤 在默认配置中,U-Boot运行在一种互动模式,它通过串口“UART1”提供命令行形式的用户接口。 这意味着U-Boot显示一个提示符(默认是:=>),等待着接受用户的输入。然后你输入一个命令,按下回车键。U-Boot将运行这个命令,然后又出现提示符等待下一条命令。 你可以使用help(或者简单地一个?)来查看所有的U-Boot命令。它将会列出在你当前配置下所有支持的命令。[请注意到尽管U-Boot提供了很多配置选项,并不是所有选项都支持各种处理器和开发板,有些选项可能在你的配置中并没有被选上。] => help ? – alias for ‘help’ askenv – get environment variables from stdin autoscr – run script from memory base – print or set address offset bdinfo – print Board Info structure boot – boot default, i.e., run ‘bootcmd’ bootd – boot default, i.e., run ‘bootcmd’ bootelf – Boot from an ELF image in memory bootm – boot application image from memory bootp – boot image via network using BootP/TFTP protocol bootstrap – program the I2C bootstrap EEPROM bootvx – Boot vxWorks from an ELF image cmp – memory compare coninfo – print console devices and information cp – memory copy crc32 – checksum calculation date – get/set/reset date & time dhcp – invoke DHCP client to obtain IP/boot params dtt – Digital Thermometer and Thermostat echo – echo args to console eeprom – EEPROM sub-system erase – erase FLASH memory exit – exit script ext2load- load binary file from a Ext2 filesystem ext2ls – list files in a directory (default /) fatinfo – print information about filesystem fatload – load binary file from a dos filesystem fatls – list files in a directory (default /) fdt – flattened device tree utility commands flinfo – print FLASH memory information getdcr – Get an AMCC PPC 4xx DCR’s value getidcr – Get a register value via indirect DCR addressing go – start application at address ‘addr’ help – print online help icrc32 – checksum calculation iloop – infinite loop on address range imd – i2c memory display iminfo – print header information for application image imls – list all images found in flash imm – i2c memory modify (auto-incrementing) imw – memory write (fill) imxtract- extract a part of a multi-image inm – memory modify (constant address) iprobe – probe to discover valid I2C chip addresses irqinfo – print information about IRQs isdram – print SDRAM configuration information itest – return true/false on integer compare loadb – load binary file over serial line (kermit mode) loads – load S-Record file over serial line loady – load binary file over serial line (ymodem mode) loop – infinite loop on address range loopw – infinite write loop on address range md – memory display mdc – memory display cyclic mii – MII utility commands mm – memory modify (auto-incrementing) mtest – simple RAM test mw – memory write (fill) mwc – memory write cyclic nand – NAND sub-system nboot – boot from NAND device nfs – boot image via network using NFS protocol nm – memory modify (constant address) pci – list and access PCI Configuration Space ping – send ICMP ECHO_REQUEST to network host printenv- print environment variables protect – enable or disable FLASH write protection rarpboot- boot image via network using RARP/TFTP protocol reginfo – print register information reset – Perform RESET of the CPU run – run commands in an environment variable saveenv – save environment variables to persistent storage setdcr – Set an AMCC PPC 4xx DCR’s value setenv – set environment variables setidcr – Set a register value via indirect DCR addressing sleep – delay execution for some time test – minimal test like /bin/sh tftpboot- boot image via network using TFTP protocol usb – USB sub-system usbboot – boot from USB device version – print monitor version =>使用help 你可以得到更多的命令信息: => help tftpboot tftpboot [loadAddress] [[hostIPaddr:]bootfilename] => => help setenv printenv setenv name value … - set environment variable ‘name’ to ‘value …’ setenv name - delete environment variable ‘name’ printenv - print values of all environment variables printenv name … - print value of environment variable ‘name’ => 大多数命令可以缩写,只要字符串的内容仍然可以被确定: => help fli tftp flinfo - print information for all FLASH memory banks flinfo N - print information for FLASH memory bank # N tftpboot [loadAddress] [[hostIPaddr:]bootfilename] => 5.8 首次上电 把主机指定的串口和在Makalu板上标有UART1的端口连接,运行终端程序,给Makalu板接上电源。你可以看到如下信息: => reset U-Boot 1.3.3-rc2-01466-g4f27098 (May 1 2008 – 13:57:57) CPU: AMCC PowerPC 460EX Rev. A at 600 MHz (PLB=200, OPB=100, EBC=100 MHz) Security/Kasumi support Bootstrap Option H – Boot ROM Location I2C (Addr 0×52) Internal PCI arbiter disabled 32 kB I-Cache 32 kB D-Cache Board: Canyonlands – AMCC PPC460EX Evaluation Board, 2*PCIe, Rev. 13 I2C: ready DTT: 1 is 48 C DRAM: 256 MB (ECC not enabled, 400 MHz, CL3) FLASH: 64 MB NAND: 32 MiB PCI: Bus Dev VenId DevId Class Int PCIE0: link is not up. PCIE0: initialization as root-complex failed PCIE1: link is not up. PCIE1: initialization as root-complex failed Net: ppc_4xx_eth0, ppc_4xx_eth1 Type run flash_nfs to mount root filesystem over NFS Hit any key to stop autoboot: 0 => => 你可以按下任意键来中止倒计数。如果你不那么做,你可能会看到一些(无关紧要的)错误,因为系统没有初始化。 有时你可能会看到一种信息: *** Warning – bad CRC, using default environment 这条信息没有害处,只要你初始化和保存环境变量之后,它就不会出现了。 首先,你必须输入你的开发板的序列号和网卡地址。需要特别注意的是,这些参数是写保护的,一旦保存了就无法改变(通常制造商已经设置好了)。使用U-Boot的setenv命令可以输入数据,命令后面跟上变量名和值,参数之间用空格(或者Tab符)隔开。例如,使用变量名serial#设置开发板的ID或者说序列号,变量名ethaddr用于设置以太网地址: => => setenv ethaddr !!!!!!FILL_THIS!!!!!! => setenv serial# CF56-216F-400A 使用printenv确认你已经输入正确的值: => printenv serial# ethaddr ## Error: "serial#" not defined ethaddr=5e:ed:18:38:81:85 => 请仔细核查显示值是否正确!等保存之后你将不能更正任何错误。如果发现错误,请重新启动开发板。如果检查无误,你可以使用saveenv命令永久保存这些参数。 => saveenv Saving Environment to Flash… Un-Protected 1 sectors Un-Protected 1 sectors Erasing Flash… . done Erased 1 sectors Writing to Flash… done Protected 1 sectors Protected 1 sectors => 5.9 U-Boot命令介绍 这一节将介绍U-Boot中最重要的指令。U-Boot可配置性非常强,所以并不是所有的命令都已经在你的硬件平台上安装,此外可能也有这儿没提到的命令。你可以使用help命令来显示根据你的配置所有可用的命令列表。 对于大多数命令,你不必打全这些命令,只需输入一些字符足以。比如,help可以简写为h。 一些命令的执行依赖于U-Boot的配置以及U-Boot中一些环境变量的定义。 所有的U-Boot命令都把输入的数字当作十六进制的格式。 不要使用除了退格键之外的其它编辑键,因为在诸如环境变量中隐藏的字符是很难被发现的。 具体命令略 6. Linux内核的编译 6.1 下载Linux内核 可以通过git下载到最新的内核,命令如下: $ cd /opt/eldk/usr/src $ git clone git://www.denx.de/git/linux-2.6-denx.git linux-2.6-denx $ cd linux-2.6-denx 6.2 内核的配置及编译 下面的步骤需要powerpc的交叉开发工具,所以您必须确认您的PATH变量中有ELDK的编译工具的地址。 首先使用下面的命令清除以前的编译信息: $ make mrproper 使用下面的命令导入适合Makalu开发板的默认配置,这些配置是经过官方多次测试的: $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- makalu_defconfig //导入默认配置 注:这些默认的配置文件位于arch/powerpc/configs/XXX_defconfig ,根据您的开发板的型号选择。如果找不到相应的配置文件,可以去arch/ppc/configs/中寻找相应的配置文件,那里还有一些。makalu_defconfig这个就是位于arch/ppc/configs/下面,而arch/powerpc/configs/中没有。 当然您还可以自己去修改内核的配置,使用如下命令: $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- config //手动改动配置 或者 $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- menuconfig //手动改动配置 注:因为一些问题(尤其是老版本的内核),"make xconfig"这个命令不被推荐 使用下面的命令编译内核: $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- uImage //编译 编译生成的目标文件uImage是通过mkimage(位于U-Boot包中) 创建的,位于/opt/eldk/usr/src/linux-2.6-denx/arch/powerpc/boot/uImage,它可以通过U-Boot来下载和引导 配置和安装模块使用如下命令: $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- modules $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- INSTALL_MOD_PATH=/opt/eldk/ppc_4xx modules_install 6.3 安装 将文件复制到tftpboot目录下面,然后通过tftp烧写: $ cp arch/powerpc/boot/uImage /tftpboot/uImage 7. 根文件系统的设计与编译 7.1 根文件系统的设计 嵌入式开发中根文件系统的设计并不是很容易的事,主要的问题是: (1)里面要包括哪些内容 (2)使用哪种文件系统类型 (3)怎样存储和引导 现在假设根文件系统中的内容我们已经知道,那么我们主要关注后面两点。 我们使用ELDK安装时生成的镜像 SELF (Simple Embedded Linux Framework),它位于 /opt/eldk//images/ 文件夹下,ramdisk_image.gz这个文件便是。 (1)解压ramdisk: $ gzip -d -c -v /opt/eldk/ppc_4xx/images/ramdisk_image.gz >/tmp/ramdisk_image //解压 (2)挂载ramdisk $ mount -o loop /tmp/ramdisk_image /mnt/tmp //挂载 (3)创建压缩文件,为了避免下面步骤需要root权限,不包括设备文件 $ cd /mnt/tmp $ tar -zc –exclude=’dev/*’ -f /tmp/rootfs.tar.gz * //创建tarball,为了避免下面步骤需要root权限,不包括设备文件 (4)将设备文件创建成单独的压缩文件(使用cramfs) $ tar -zcf /tmp/devices.tar.gz dev/ //将设备文件创建成单独的tarball $ cd /tmp (5)取消挂载 $ umount /mnt/tmp //取消挂载 7.2 根文件系统的编译 我们使用ramdisk的形式来生成根文件系统的镜像文件,一般情况下,它使用ext2文件系统。 (1)创建目录,解压压缩文件 $ cd /opt/eldk/ $ mkdir rootfs $ cd rootfs $ tar zxf /tmp/rootfs.tar.gz (2)我们使用genext2fs来创建ramdisk镜像文件,因为它使用一个简单的文本文件来描述设备,因而不需要root权限。使用设备表rootfs_devices.tab: # /dev d 755 0 0 – - – - - /dev/console c 640 0 0 5 1 – - - /dev/fb0 c 640 0 0 29 0 – - - /dev/full c 640 0 0 1 7 – - - /dev/hda b 640 0 0 3 0 – - - /dev/hda b 640 0 0 3 1 1 1 16 /dev/kmem c 640 0 0 1 2 – - - /dev/mem c 640 0 0 1 1 – - - /dev/mtd c 640 0 0 90 0 0 2 16 /dev/mtdblock b 640 0 0 31 0 0 1 16 /dev/mtdr c 640 0 0 90 1 0 2 16 /dev/nftla b 640 0 0 93 0 – - - /dev/nftla b 640 0 0 93 1 1 1 8 /dev/nftlb b 640 0 0 93 16 – - - /dev/nftlb b 640 0 0 93 17 1 1 8 /dev/null c 640 0 0 1 3 – - - /dev/ptyp c 640 0 0 2 0 0 1 10 /dev/ptypa c 640 0 0 2 10 – - - /dev/ptypb c 640 0 0 2 11 – - - /dev/ptypc c 640 0 0 2 12 – - - /dev/ptypd c 640 0 0 2 13 – - - /dev/ptype c 640 0 0 2 14 – - - /dev/ptypf c 640 0 0 2 15 – - - /dev/ram b 640 0 0 1 0 0 1 2 /dev/ram b 640 0 0 1 1 – - - /dev/rtc c 640 0 0 10 135 – - - /dev/tty c 640 0 0 4 0 0 1 4 /dev/tty c 640 0 0 5 0 – - - /dev/ttyS c 640 0 0 4 64 0 1 8 /dev/ttyp c 640 0 0 3 0 0 1 10 /dev/ttypa c 640 0 0 3 10 – - - /dev/ttypb c 640 0 0 3 11 – - - /dev/ttypc c 640 0 0 3 12 – - - /dev/ttypd c 640 0 0 3 13 – - - /dev/ttype c 640 0 0 3 14 – - - /dev/ttypf c 640 0 0 3 15 – - - /dev/zero c 640 0 0 1 5 – - - 具体的格式描述请参见genext2fs的帮助文档。 (3)使用genext2fs来创建一个ext2文件系统的镜像: $ ROOTFS_DIR=/opt/eldk/rootfs # 路径 $ ROOTFS_SIZE=8192 # 文件系统镜像的大小,如果此值太小,当生成的文件超过此值时,会报错 $ ROOTFS_FREE=100 # free space wanted $ ROOTFS_INODES=380 # number of inodes $ ROOTFS_DEVICES=rootfs_devices.tab # device description file $ ROOTFS_IMAGE=ramdisk.img # generated file system image $ genext2fs -U \ -d ${ROOTFS_DIR} \ -D ${ROOTFS_DEVICES} \ -b ${ROOTFS_SIZE} \ -r ${ROOTFS_FREE} \ -i ${ROOTFS_INODES} \ ${ROOTFS_IMAGE} (4)压缩文件 $ gzip -v9 ramdisk.img (5)创建适合U-Boot的images: $ mkimage -T ramdisk -C gzip -n ‘Test Ramdisk Image’ \> -d ramdisk.img.gz uRamdisk 至此,ELDK的开发环境便基本搭建完成。
百度首页 | 百度空间 | 登录 广告停放提高网站流量,centos学习 主页博客相册|个人档案 查看文章 <br>.htaccess怎么用2007-05-16 14:04(文章来源)http://www.dnpark.com.cn/news/mm/www/1179329504375ZKlMSgYr.html<br><br>Apache服务器的.htaccess是一个非常强大的分布式配置文件,学会使用.htaccess,对虚拟主机用户来说,可以实现众多的功能。这里有一篇很容易让人理解的.htaccess介绍,作为入门文章非常的适合。文章最初来自freewebmasterhelp.com,QiRan作了简单的中文翻译,我将加以完善。<br><br>Part 1 – Introduction介绍 <br>Part 2 - .htaccess Commande命令 <br>Part 3 - Password protection密码保护 <br>Part 1 – Introduction介绍<br><br>Introduction 介绍<br><br>In this tutorial you will find out about the .htaccess file and the power it has to improve your website. Although .htaccess is only a file, it can change settings on the servers and allow you to do many different things, the most popular being able to have your own custom 404 error pages. .htaccess isn't difficult to use and is really just made up of a few simple instructions in a text file.<br>从本指南中,你将可以学习到有关.htaccess文件及其功能的知识,并用以优化你的网站。尽管.htaccess只是一个文件,但它可以更改服务器的设置,允许你做许多不同的事情,最流行的功能是您可以创建自定义的“404 error”页面。.htaccess 并不难于使用,归根结底,它只是在一个text文档中添加几条简单的指令而已。<br><br>Will My Host Support It? 我的主机支持它吗?<br><br>This is probably the hardest question to give a simple answer to. Many hosts support .htaccess but don't actually publicise it and many other hosts have the capability but do not allow their users to have a .htaccess file. As a general rule, if your server runs Unix or Linux, or any version of the Apache web server it will support .htaccess, although your host may not allow you to use it.<br>这可能很难用简单的答案来回答。许多主机支持.htaccess,但实际上并不会特别声明,许多其他类型的主机有能力但并不允许他们的用户使用.htaccess。一般来说,如果你的主机使用Unix或Linux系统,或任何版本的Apache网络服务器,从理论上都是支持.htaccess的,尽管你的主机服务商可能不允许你使用它。<br><br>A good sign of whether your host allows .htaccess files is if they support password protection of folders. To do this they will need to offer .htaccess (although in a few cases they will offer password protection but not let you use .htaccess). The best thing to do if you are unsure is to either upload your own .htaccess file and see if it works or e-mail your web host and ask them.<br>判断你的主机是否允许.htaccess,一个标志很好的是它是否支持文件夹密码保护。为达到此功能,主机服务商需要使用.htaccess(当然,少数情况下他们虽提供密码保护功能,但却并不允许你使用.htaccess)。如果你不确定自己的主机是否支持.htaccess,最好的办法是上传你自己的.htaccess文件看看是否有用,或者直接发送e-mail向你的主机服务商咨询。<br><br>What Can I Do? 我该怎么做?<br><br>You may be wondering what .htaccess can do, or you may have read about some of its uses but don't realise how many things you can actually do with it.<br>你可能疑惑.htaccess到底能做些什么,或者你可能曾知道它的一些功能但并不真正了解你实际到底可以用它来做多少事情。<br><br>There is a huge range of things .htaccess can do including: password protecting folders, redirecting users automatically, custom error pages, changing your file extensions, banning users with certian IP addresses, only allowing users with certain IP addresses, stopping directory listings and using a different file as the index file.<br>.htaccess可以做大量的事情,包括:文件夹密码保护、用户自动重定向、自定义错误页面、改变你的文件扩展名、封禁特定IP地址的用户、只允许特定IP地址的用户、禁止目录列表,以及使用其他文件作为index文件。<br><br>Creating A .htaccess File 创建一个.htaccess文档<br><br>Creating a .htaccess file may cause you a few problems. Writing the file is easy, you just need enter the appropriate code into a text editor (like notepad). You may run into problems with saving the file. Because .htaccess is a strange file name (the file actually has no name but a 8 letter file extension) it may not be accepted on certain systems (e.g. Windows 3.1). With most operating systems, though, all you need to do is to save the file by entering the name as:<br>创建.htaccess文件也许会给你带来一些困难。写文件很容易,你只需要在文字编缉器(例如:写字板)里写下适当的代码。真正困难的可能是文件的保存,因为.htaccess是一个古怪的文件名(它事实上没有文件名,只有一个由8个字母组成的扩展名),而在一些系统(如windows 3.1)中无法接受这样的文件名。在大多数的操作系统中,你需要做的是将文档保存成名为:<br><br>".htaccess"<br>(including the quotes). If this doesn't work, you will need to name it something else (e.g. htaccess.txt) and then upload it to the server. Once you have uploaded the file you can then rename it using an FTP program.<br>(包括引号)。如果这也不行,你需要将其先命名为其它名字(例如htaccess.txt),再将其上传到服务器上,之后直接使用FTP软件来重命名。<br><br>Warning 警告<br><br>Before beginning using .htaccess, I should give you one warning. Although using .htaccess on your server is extremely unlikely to cause you any problems (if something is wrong it simply won't work), you should be wary if you are using the Microsoft FrontPage Extensions. The FrontPage extensions use the .htaccess file so you should not really edit it to add your own information. If you do want to (this is not recommended, but possible) you should download the .htaccess file from your server first (if it exists) and then add your code to the beginning.<br>在使用.htaccess之前,我必须给你一些警告。虽然在服务器上使用.htaccess绝对不太可能给你带来任何麻烦(如果有些东西错了,它只是没效用罢了),但如果你使用Microsoft FrontPage Extensions,就必须特别小心。因为FrontPage Extensions本身使用了.htaccess,因此你不能编辑它并加入你自己的信息。如果确实有这方面的需要(并不推荐,但是可能),你应该先从服务器上下载.htaccess文档(如果存在),之后在前面加上你的代码。<br><br>Custom Error Pages 自定义错误页<br><br>The first use of the .htaccess file which I will cover is custom error pages. These will allow you to have your own, personal error pages (for example when a file is not found) instead of using your host's error pages or having no page. This will make your site seem much more professional in the unlikely event of an error. It will also allow you to create scripts to notify you if there is an error (for example I use a PHP script on Free Webmaster Help to automatically e-mail me when a page is not found).<br>我要介绍的.htaccess的第一个应用是自定义错误页面,这将使你可以拥有自己的、个性化的错误页面(例如找不到文件时),而不是你的服务商提供的错误页或没有任何页面。这会让你的网站在出错的时候看上去更专业。你还可以利用脚本程序在发生错误的时候通知你(例如我使用Free Webmaster Help的PHP脚本程序,当找不到页面的时候自动e-mail给我)。<br><br>You can use custom error pages for any error as long as you know its number (like 404 for page not found) by adding the following to your .htaccess file:<br>你所知道的任何页面错误代码(像404找不到页面),都可以通过在.htaccess文件里加入下面的文字将其变成自定义页面:<br><br>rrorDocument errornumber /file.html<br>For example if I had the file notfound.html in the root direct<br>ory of my site and I wanted to use it for a 404 error I would use:<br>举例来说,如果我的根目录下有一个nofound.html文件,我想使用它作为404 error的页面:<br><br>ErrorDocument 404 /notfound.html<br>If the file is not in the root directory of your site, you just need to put the path to it:<br>如果文件不在网站的根目录下,你只需要把路径设置为:<br><br>ErrorDocument 500 /errorpages/500.html<br>These are some of the most common errors:<br>以下是一些最常用的错误:<br><br>401 - Authorization Required 需要验证<br>400 - Bad request 错误请求<br>403 - Forbidden 禁止<br>500 - Internal Server Error 内部服务器错误<br>404 - Wrong page 找不到页面<br>Then, all you need to do is to create a file to display when the error happens and upload it and the .htaccess file.<br>接下来,你要做的只是创建一个错误发生时显示的文件,然后把它们和.htaccess一起上传。<br><br><br>Part 2 - .htaccess 命令<br><br>Introduction 介绍<br><br>In the last part I introduced you to .htaccess and some of its useful features. In this part I will show you how to use the .htaccess file to implement some of these.<br>在上一部分,我已经简单介绍了.htaccess以及它的一些有用功能,在这一部分,我将向你演示如何使用.htaccess文档去实现这些功能。<br><br>Stop A Directory Index From Being Shown 停示显示目录列表<br><br>Sometimes, for one reason or another, you will have no index file in your directory. This will, of course, mean that if someone types the directory name into their browser, a full listing of all the files in that directory will be shown. This could be a security risk for your site.<br>有些时候,由于某种原因,你的目录里没有index文件,这意味着当有人在浏览器地址栏键入了该目录的路径,该目录下所有的文件都会显示出来,这会给你的网站留下安全隐患。<br><br>To prevent against this (without creating lots of new 'index' files, you can enter a command into your .htaccess file to stop the directory list from being shown:<br>为避免这种情况(而不必创建一堆的新index文件),你可以在你的.htaccess文档中键入以下命令,用以阻止目录列表的显示:<br><br>Options -Indexes<br>Deny/Allow Certian IP Addresses 阻止/允许特定的IP地址<br><br>In some situations, you may want to only allow people with specific IP addresses to access your site (for example, only allowing people using a particular ISP to get into a certian directory) or you may want to ban certian IP addresses (for example, keeping disruptive memembers out of your message boards). Of course, this will only work if you know the IP addresses you want to ban and, as most people on the internet now have a dynamic IP address, so this is not always the best way to limit usage.<br>某些情况下,你可能只想允许某些特定IP的用户可以访问你的网站(例如:只允许使用特定ISP的用户进入某个目录),或者想封禁某些特定的IP地址(例如:将低级用户隔离于你的信息版面外)。当然,这只在你知道你想拦截的IP地址时才有用,然而现在网上的大多数用户都使用动态IP地址,所以这并不是限制使用的常用方法。<br><br>You can block an IP address by using:<br>你可以使用以下命令封禁一个IP地址:<br><br>deny from 000.000.000.000<br>where 000.000.000.000 is the IP address. If you only specify 1 or 2 of the groups of numbers, you will block a whole range.<br>这里的000.000.000.000是被封禁的IP地址,如果你只指明了其中的几个,则可以封禁整个网段的地址。如你输入210.10.56.,则将封禁210.10.56.0~210.10.56.255的所有IP地址。<br><br>You can allow an IP address by using:<br>你可以使用以下命令允许一个IP地址访问网站:<br><br>allow from 000.000.000.000<br>where 000.000.000.000 is the IP address. If you only specify 1 or 2 of the groups of numbers, you will allow a whole range.<br>被允许的IP地址则为000.000.000.000,你可以象封禁IP地址一样封禁整个网段。<br><br>If you want to deny everyone from accessing a directory, you can use:<br>如果你想阻止所有人访问该目录,则可以使用:<br><br>deny from all<br>but this will still allow scripts to use the files in the directory.<br>不过这并不影响脚本程序使用这个目录下的文档。<br><br>Alternative Index Files 替换index文件<br><br>You may not always want to use index.htm or index.html as your index file for a directory, for example if you are using PHP files in your site, you may want index.php to be the index file for a directory. You are not limited to 'index' files though. Using .htaccess you can set foofoo.blah to be your index file if you want to!<br>也许你不想一直使用index.htm或index.html作为目录的索引文件。举例来说,如果你的站点使用PHP文件,你可能会想使用index.php来作为该目录的索引文档。当然也不必局限于“index”文档,如果你愿意,使用.htaccess你甚至能够设置foofoo.balh来作为你的索引文档!<br><br>Alternate index files are entered in a list. The server will work from left to right, checking to see if each file exists, if none of them exisit it will display a directory listing (unless, of course, you have turned this off).<br>这些互为替换的索引文件可以排成一个列表,服务器会从左至右进行寻找,检查哪个文档在真实的目录中存在。如果一个也找不到,它将会把目录列表显示出来(除非你已经关闭了显示目录文件列表)。<br><br>DirectoryIndex index.php index.php3 messagebrd.pl index.html index.htm<br>Redirection 重定向<br><br>One of the most useful functions of the .htaccess file is to redirect requests to different files, either on the same server, or on a completely different web site. It can be extremely useful if you change the name of one of your files but allow users to still find it. Another use (which I find very useful) is to redirect to a longer URL, for example in my newsletters I can use a very short URL for my affiliate links. The following can be done to redirect a specific file:<br>.htaccess最有用的功能之一就是将请求重定向到同站内或站外的不同文档。这在你改变了一个文件名称,但仍然想让用户用旧地址访问到它时,变的极为有用。另一个应用(我发现的很有用的)是重定向到一个长URL,例如在我的时事通讯中,我可以使用一个很简短的URL来指向我的会员链接。以下是一个重定向文件的例子:<br><br>Redirect /location/from/root/file.ext<br>http://www.othersite.com/new/file/location.xyz<br>In this above example, a file in the root directory called oldfile.html would be entered as:<br>上述例子中,访问在root目录下的名为oldfile.html可以键入:<br><br>/oldfile.html<br>and a file in the old subdirectory would be entered as:<br>访问一个旧次级目录中的文件可以键入:<br><br>/old/oldfile.html<br>You can also redirect whole directoires of your site using the .htaccess file, for example if you had a directory called olddirectory on your site and you had set up the same files on a new site at: http://www.newsite.com/newdirectory/ you could redirect all the files in that directory without having to specify each one:<br>你也可以使用.htaccess重定向整个网站的目录。假如你的网站上有一个名为olddirectory的目录,并且你已经在一个新网站 http://www.newsite.com/newdirectory/上建立了与上相同的文档,你可以将旧目录下所有的文件做一次重定向而不必一一声明:<br><br>Redirect /olddirectory http://www.newsite.com/newdirectory<br>Then, any request to your site below /olddirectory will bee redirected to the new site, with the<br>extra information in the URL added on, for example if someone typed in:<br>这样,任何指向到站点中/olddirectory目录的请求都将被重新指向新的站点,包括附加的额外URL信息。例如有人键入:<br><br>http://www.youroldsite.com/olddirecotry/oldfiles/images/image.gif<br>They would be redirected to:<br>请求将被重定向到:<br><br>http://www.newsite.com/newdirectory/oldfiles/images/image.gif<br>This can prove to be extremely powerful if used correctly.<br>如果正确使用,此功能将极其强大。<br><br>Part 3 – 密码保护<br><br>Introduction 介绍<br><br>Although there are many uses of the .htaccess file, by far the most popular, and probably most useful, is being able to relaibly password protect directories on websites. Although JavaScript etc. can also be used to do this, only .htaccess has total security (as someone must know the password to get into the directory, there are no 'back doors')<br>尽管有各种各样的.htaccess用法,但至今最流行的也可能是最有用的做法是将其用于网站目录可靠的密码保护。尽管JavaScrip等也能做到,但只有.htaccess具有完美的安全性(即访问者必须知晓密码才可以访问目录,并且绝无“后门”可走)。<br><br>The .htaccess File 密码保护的.htaccess文件<br><br>Adding password protection to a directory using .htaccess takes two stages. The first part is to add the appropriate lines to your .htaccess file in the directory you would like to protect. Everything below this directory will be password protected:<br>利用.htaccess将一个目录加上密码保护分两个步骤。第一步是在你的.htaccess文档里加上适当的几行代码,再将.htaccess文档放进你要保护的目录下:<br><br>AuthName "Section Name"<br>AuthType Basic<br>AuthUserFile /full/path/to/.htpasswd<br>Require valid-user<br>There are a few parts of this which you will need to change for your site. You should replace "Section Name" with the name of the part of the site you are protecting e.g. "Members Area".<br>你可能需要根据你的网站情况修改一下上述内容中的一些部分,如用被保护部分的名字"Members Area",替换掉“Section Name”。<br><br>The /full/parth/to/.htpasswd should be changed to reflect the full server path to the .htpasswd file (more on this later). If you do not know what the full path to your webspace is, contact your system administrator for details.<br>/full/parth/to/.htpasswd则应该替换为指向.htpasswd文件(后面详述该文档)的完整服务器路径。如果你不知道你网站空间的完整路径,请询问一下你的系统管理员。<br><br>The .htpasswd File 密码保护的.htpasswd文件<br><br>Password protecting a directory takes a little more work than any of the other .htaccess functions because you must also create a file to contain the usernames and passwords which are allowed to access the site. These should be placed in a file which (by default) should be called .htpasswd. Like the .htaccess file, this is a file with no name and an 8 letter extension. This can be placed anywhere within you website (as the passwords are encrypted) but it is advisable to store it outside the web root so that it is impossible to access it from the web.<br>目录的密码保护比.htaccess的其他功能要麻烦些,因为你必须同时创建一个包含用户名和密码的文档,用于访问你的网站,相关信息(默认)位于一个名为.htpasswd的文档里。像.htaccess一样,.htpasswd也是一个没有文件名且具有8位扩展名的文档,可以放置在你网站里的任何地方(此时密码应加密),但建议你将其保存在网站Web根目录外,这样通过网络就无法访问到它了。<br><br>Entering Usernames And Passwords 输入用户名和密码<br><br>Once you have created your .htpasswd file (you can do this in a standard text editor) you must enter the usernames and passwords to access the site. They should be entered as follows:<br>创建好.htpasswd文档后(可以通过文字编辑器创建),下一步是输入用于访问网站的用户名和密码,应为:<br><br>username:password<br>where the password is the encrypted format of the password. To encrypt the password you will either need to use one of the premade scripts available on the web or write your own. There is a good username/password service at the KxS site which will allow you to enter the user name and password and will output it in the correct format.<br>“password”的位置应该是加密过的密码。你可以通过几种方法来得到加密过的密码:一是使用一个网上提供的permade脚本或自己写一个;另一个很不错的username/password加密服务是通过KxS网站,这里允许你输入用户名及密码,然后生成正确格式的密码。<br><br>For multiple users, just add extra lines to your .htpasswd file in the same format as the first. There are even scripts available for free which will manage the .htpasswd file and will allow automatic adding/removing of users etc.<br>对于多用户,你只需要在.htpasswd文档中新增同样格式的一行即可。另外还有一些免费的脚本程序可以方便地管理.htpasswd文档,可以自动新增/移除用户等。<br><br>Accessing The Site 访问网站<br><br>When you try to access a site which has been protected by .htaccess your browser will pop up a standard username/password dialog box. If you don't like this, there are certain scripts available which allow you to embed a username/password box in a website to do the authentication. You can also send the username and password (unencrypted) in the URL as follows:<br>当你试图访问被.htaccess密码保护的目录时,你的浏览器会弹出标准的username/password对话窗口。如果你不喜欢这种方式,有些脚本程序可以允许你在页面内嵌入username/password输入框来进行认证,你也可以在浏览器的URL框内以以下方式输入用户名和密码(未加密的):<br><br>http://username:[email protected]/directory/<br>Summary 小结<br><br>.htaccess is one of the most useful files a webmaster can use. There are a wide variety of different uses for it which can save time and increase security on your website.<br>.htaccess是一个站点管理员可以应用的强大工具,有更多的变化以适应不同的用途,可以节约时间及提高网站的安全性。<br><br>相关阅读:<br><br><br>KxS Password Encrypter <br>Apache .htaccess Documentation <br>More .htaccess Sites <br>Related Reading <br><br>.htaccess的特别说明<br><br><br>启用.htaccess,需要修改httpd.conf,启用AllowOverride,并可以用AllowOverride限制特定命令的使用 <br>如果需要使用.htaccess以外的其他文件名,可以用AccessFileName指令来改变。例如,需要使用.config ,则可以在服务器配置文件中按以下方法配置:<br><br>AccessFileName .config <br>一般情况下,不应该使用.htaccess文件,除非你对主配置文件没有访问权限。有一种很常见的误解,认为用户认证只能通过.htaccess文件实现,其实并不是这样,把用户认证写在主配置文件中是完全可行的,而且是一种很好的方法。.htaccess文件应该被用在内容提供者需要针对特定目录改变服务器的配置而又没有root权限的情况下。如果服务器管理员不愿意频繁修改配置,则可以允许用户通过.htaccess文件自己修改配置,尤其是ISP在同一个机器上运行了多个用户站点,而又希望用户可以自己改变配置的情况下。虽然如此,一般都应该尽可能地避免使用.htaccess文件。任何希望放在.htaccess文件中的配置,都可以放在主配置文件的<Directory>段中,而且更高效。避免使用.htaccess文件有两个主要原因,即性能和安全。 <br> <br><br>类别:php+mysql+apache+zend | 添加到搜藏 | 浏览(40) 网友评论: 发表评论:姓 名: 注册 | 登录 *姓名最长为50字节 <br> <br>网址或邮箱: (选填) <br> <br>内 容: <br> <br>验证码: 请输入下图中的四位验证码,字母不区分大小写。<br> 看不清? <br> <br><br> <br><br>©2007 Baidu

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值