NameVirtualHost *:80但把虚拟主机的那些配置拷贝到 Apache 2.0 中的配置文件之后,启动 Apache 得到报错"No VirtualHost found for NameVirtualHost *:80"。
"<"VirtualHost *">"
...
排错,将所有的 VirtualHost * 替换为 VirtualHost *:80 即可。
NameVirtualHost *:80但把虚拟主机的那些配置拷贝到 Apache 2.0 中的配置文件之后,启动 Apache 得到报错"No VirtualHost found for NameVirtualHost *:80"。
"<"VirtualHost *">"
...
sh$ find `pwd`/lamp01 >i-files会发现很多重复的项,而且 tar 归档的大小是普通情况下的 3 倍,这意味着同时使用 -T/-X 选项会有问题。因此如果要排除某个目录,只能将希望放在 find 上了——如果使用 shell script 或在 python 中使用 os.popen() 直接调用这些命令来实现的时候。
sh$ echo "/tmp/temp/lamp01/profiles" >x-files
sh$ tar -c -z -f lamp01.tgz -T i-files -X x-files /tmp/temp/lamp01
sh$ tar tfz lamp01.tgz | grep profiles | sort
tmp/temp/lamp01/.svn/prop-base/profiles.svn-base
tmp/temp/lamp01/.svn/prop-base/profiles.svn-base
tmp/temp/lamp01/.svn/prop-base/profiles.svn-base
tmp/temp/lamp01/.svn/prop-base/profiles.svn-base
tmp/temp/lamp01/.svn/prop-base/profiles.svn-base
tmp/temp/lamp01/.svn/props/profiles.svn-work
tmp/temp/lamp01/.svn/props/profiles.svn-work
tmp/temp/lamp01/.svn/props/profiles.svn-work
tmp/temp/lamp01/.svn/props/profiles.svn-work
tmp/temp/lamp01/.svn/props/profiles.svn-work
tmp/temp/lamp01/.svn/text-base/profiles.svn-base
tmp/temp/lamp01/.svn/text-base/profiles.svn-base
tmp/temp/lamp01/.svn/text-base/profiles.svn-base
tmp/temp/lamp01/.svn/text-base/profiles.svn-base
tmp/temp/lamp01/.svn/text-base/profiles.svn-base
find `pwd`/lamp01 -path `pwd`/lamp01/profiles -prune -o -print | grep profiles这里最好使用绝对路径,在备份的这个脚本设计中也最好使用绝对路径,能够避免很多混乱的情况!可以使用 tar -P 参数。
find `pwd`/lamp01 \( -path `pwd`/lamp01/profiles -o -path /tmp/temp/lamp01/confiles \) -prune -o -print | grep profiles对一个目录也同样可以使用 \(\):
find `pwd`/lamp01 \( -path `pwd`/lamp01/profiles \) -prune -o -print即便是有不相干的目录加入进来也没有关系
find `pwd`/lamp01 \( -path `pwd`/lamp01/profiles -o -path /etc \) -prune -o -print不过可以认真考虑一下 backup list 应该以怎样的形式为好?
/dev/VolGroup00/LogVol00 / ext3 defaults,usrquota,grpquota 1 1然后重新挂载分区:
# mount -a -o remount接着运行:
# quotacheck -cug /这不一定会成功,你可能会得到下面的错误提示:
-c,create, -u,user, -g,group
quotacheck: Mountpoint (or device) / not found.这是因为指定的分区没有在 mount 时施加 usrquota,grpquota 选项,用 mount 或 cat /etc/mtab 应该可以看到:
quotacheck: Can't find filesystem to check or filesystem not mounted with quota option.
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw,usrquota,grpquota)
否则就只能重启或在 remount 是手工添加这两个参数。# quotaon /
[root@localhost ~]# quota sysadm
Disk quotas for user sysadm (uid 501): none
[root@localhost ~]# quota magic
Disk quotas for user magic (uid 500):
Filesystem blocks quota limit grace files quota limit grace
/dev/mapper/VolGroup00-LogVol00
301600* 8192 8192 17489 0 0
[root@localhost ~]# repquota /
*** Report for user quotas on device /dev/mapper/VolGroup00-LogVol00
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 8092660 0 0 181769 0 0
daemon -- 20 0 0 3 0 0
lp -- 8 0 0 1 0 0
rpm -- 36688 0 0 111 0 0
netdump -- 16 0 0 2 0 0
rpcuser -- 8 0 0 1 0 0
smmsp -- 12 0 0 2 0 0
apache -- 52 0 0 10 0 0
squid -- 16 0 0 2 0 0
webalizer -- 32 0 0 4 0 0
xfs -- 0 0 0 1 0 0
ntp -- 16 0 0 2 0 0
magic +- 301600 8192 8192 6days 17489 0 0
sysadm -- 40 0 0 11 0 0
admin -- 40 0 0 11 0 0
test -- 40 0 0 11 0 0
$ echo "fjiajefi" >test
dm-0: write failed, user block limit reached.
# edquota -p magic admin test即可将 admin 和 test 用户的配额设置为 magic 用户的模式。
# edquota -p bob `awk -F: '$3 > 499 {print $1}' /etc/passwd`在这里,user_* 是由程序自动生成的(根据网站页面注册提供的一种服务,并会自动添加系统帐户,来自于一个商业软件),数量是比较大的。
# edquota -p ftpd `awk -F: '$1~/^user_.*$/ {print $1}' /etc/passwd`
httpd.conf将(1),(2)分别放置于全局和 VirtualHost 内,就可以看到差异。即使在 VirtualHost 之前增加如下的规则也无效:
NameVirtualHost 192.168.0.98:80
"<"VirtualHost 192.168.0.98:80">"
ServerName www1.test.com
DocumentRoot /var/www/html/dir
RewriteEngine on (1)
RewriteRule "^/index\.html" "/test.html" (2)
"<"/VirtualHost">"
"<"VirtualHost 192.168.0.98:80">"
ServerName www2.test.com
DocumentRoot /var/www/html/dir2
# RewriteEngine on
# RewriteRule "^/index.html" "/test.html"
"<"/VirtualHost">"
"<"VirtualHost 192.168.0.98:80">"
ServerName www.test.com
DocumentRoot /var/www/html/test
"<"/VirtualHost">"
$ cat /var/www/html/dir/index.html
Index of TEST 1
$ cat /var/www/html/dir/test.html
TEST 1
$ cat /var/www/html/dir2/test2.html
TEST 2
$ cat /var/www/html/test/index.html
INDEX at TEST
$ cat /var/www/html/test/test.html
$ cat /etc/hosts
...
192.168.0.98 www1.test.com
192.168.0.98 www2.test.com
192.168.0.98 www.test.com
192.168.0.98 www.example.com
RewriteEngine on这是希望把所有不是到 www.test.com 的请求重定向到 www.test.com(记得修改 /etc/hosts 文件如上),则理论上到 www.example.com 的请求应该会转向 www.test.com,如果这样可以做到,那么我只需要增加一个虚拟主机,然后在这里定义所有的 RewriteRule,再 Rewrite 回去也许是可以的。
RewriteCond %{HTTP_HOST} "!^www.test.com$" [NC,OR]
RewriteCond %{SERVER_NAME} "!^www.test.com$" [NC]
RewriteRule "(.*)" "http://www.test.com$1
$ cat httpd.conf注意这里的正则表达式是"^index\.html"而不是象全局和 VirtualHost 段中使用的 "^/index\.html",这是因为 .htaccess 是在指定的 Directory 中,所以其使用的是一个类似于相对路径的概念,当然这里是 URL 的一个相对路径。所以"^/index\.html"将得不到任何匹配。而 RewriteRule 部分的正则匹配串则是 URL 部分去除主机名后的那部分路径,并一定以"/"开头──也就是 DocumentRoot。
"<"Directory "/www/users"">"
AllowOverride FileInfo
Order Allow, Deny
Allow From All
"<"/Directory">"
$ cat /www/users/www.test04.com/.htaccess
RewriteEngine on
RewriteRule "^index\.html" "/index.php"
COMMAND:> [2007-1-31 10:55:18] PORT 192,168,0,64,11,208
[2007-1-31 10:55:18] 200 PORT command successful. Consider using PASV.
# Kickstart file automatically generated by anaconda.这样,通过在 %package 部分定制需要的包,在 %post 部分运行需要的命令(这里是给内核升级并关闭一些服务,因为原来的 2.6.9-SMP 内核有问题,不能正常重启),可以勉强达到对软件环境的定制和复用需求。
install
url --url ftp://192.168.0.98/pub/
lang en_US.UTF-8
langsupport --default=en_US.UTF-8 en_US.UTF-8 zh_CN.UTF-8 zh_TW.UTF-8
keyboard us
xconfig --card "ATI Rage XL" --videoram 8128 --hsync 30-61 --vsync 50-120 --resolution 800x600 --depth 16 --startxonboot --defaultdesktop kde
# network --device eth0 --bootproto dhcp
network --device eth0 static --ip 192.168.0.99 --netmask 255.255.255.0 --gateway 192.168.0.1 --nameserver 192.168.0.230 --hostname shopex
network --device eth1 --bootproto dhcp
rootpw --iscrypted $1$ntYDkgk/$AY.RmHTCjLUFJWzHlPYfF1
firewall --enabled --port=22:tcp --port=80:tcp
selinux --disabled
authconfig --enableshadow --enablemd5
timezone Asia/Shanghai
bootloader --location=mbr
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --drives=sda
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.5 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.5
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxsize=2000
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
%packages
@ editors
@ emacs
@ text-internet
@ dialup
@ compat-arch-support
@ chinese-support
@ development-tools
grub
kernel-smp
kernel-smp-devel
kernel-devel
e2fsprogs
lvm2
subversion
ntp
samba-common
samba-client
vsftpd
%post --interpreter /bin/bash
PKGSTORE=192.168.0.98
cd /opt
wget ftp://$PKGSTORE/pub/linux-2.6.14.2.tar.bz2 \
&& tar xfj linux-2.6.14.2.tar.bz2 \
&& cd linux-2.6.14.2 \
&& wget ftp://$PKGSTORE/pub/config-2.6.14.2.SMP -O ./.config \
&& make oldconfig \
&& make \
&& make modules \
&& make modules_install \
&& cp -vbf arch/i386/boot/bzImage /boot/vmlinuz-2.6.14.2.SMP \
&& cp -vf System.map /boot/System.map-2.6.14.2.SMP \
&& cp -vbf .config /boot/config-2.6.14.2.SMP \
&& mkinitrd -v -f /boot/initrd-2.6.14.2.SMP.img 2.6.14.2 \
&& /sbin/depmod -ae -F System.map 2.6.14.2 \
&& echo -e "title Red Hat Linux AS4 (2.6.14.2.SMP)
\troot (hd0,0)
\tkernel /vmlinuz-2.6.14.2.SMP ro root=/dev/VolGroup00/LogVol00
\tinitrd /initrd-2.6.14.2.SMP.img" >>/boot/grub/grub.conf \
&& sed -i "s/default=0/default=2/" /boot/grub/grub.conf
cd ..
sed -i 's/id:5:initdefault:/id:3:initdefault:/' /etc/inittab
wget ftp://$PKGSTORE/pub/trun-off.list
for SERVICE in `cat turn-off.list`
do
/sbin/chkconfig $SERVICE off
done
pkgname = "docbook-xml";这中间有许多 xmlcatalog(属于 libxml2 包),只是为了创建 /etc/xml/catalog 和 /etc/xml/docbook 这两个文件。这两个文件本身也是 XML 文件,只是比较特殊,是专门的 catalog 文件:!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"。所谓 catalog,实际上是一些映射文件,将 Public Identifier 映射为 System Identifier。
version = "4.4";
user = "docbook-xml";
groups = "";
group = "docbook-xml";
archive = "docbook-xml-4.4.zip";
command = "mkdir docbook-xml";
command = "cd docbook-xml";
command = "unzip ../docbook-xml-4.4.zip";
command = "install -v -d -m755 /usr/share/xml/docbook/xml-dtd-4.4";
command = "install -v -d -m755 /etc/xml";
command = "cp -v -af docbook.cat *.dtd ent/ *.mod /usr/share/xml/docbook/xml-dtd-4.4";
command = "if [ ! -e /etc/xml/docbook ]; then xmlcatalog --noout --create /etc/xml/docbook; fi";
command = "xmlcatalog --noout --add "public" "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" /etc/xml/docbook";
command = "xmlcatalog --noout --add "public" "-//OASIS//DTD DocBook XML CALS Table Model V4.4//EN" "file:///usr/share/xml/docbook/xml-dtd-4.4/calstblx.dtd" /etc/xml/docbook";
command = "xmlcatalog --noout --add "public" "-//OASIS//DTD XML Exchange Table Model 19990315//EN" "file:///usr/share/xml/docbook/xml-dtd-4.4/soextblx.dtd" /etc/xml/docbook";
command = "xmlcatalog --noout --add "public" "-//OASIS//ELEMENTS DocBook XML Information Pool V4.4//EN" "file:///usr/share/xml/docbook/xml-dtd-4.4/dbpoolx.mod" /etc/xml/docbook";
command = "xmlcatalog --noout --add "public" "-//OASIS//ELEMENTS DocBook XML Document Hierarchy V4.4//EN" "file:///usr/share/xml/docbook/xml-dtd-4.4/dbhierx.mod" /etc/xml/docbook";
command = "xmlcatalog --noout --add "public" "-//OASIS//ELEMENTS DocBook XML HTML Tables V4.4//EN" "file:///usr/share/xml/docbook/xml-dtd-4.4/htmltblx.mod" /etc/xml/docbook";
command = "xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Notations V4.4//EN" "file:///usr/share/xml/docbook/xml-dtd-4.4/dbnotnx.mod" /etc/xml/docbook";
command = "xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Character Entities V4.4//EN" "file:///usr/share/xml/docbook/xml-dtd-4.4/dbcentx.mod" /etc/xml/docbook";
command = "xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Additional General Entities V4.4//EN" "file:///usr/share/xml/docbook/xml-dtd-4.4/dbgenent.mod" /etc/xml/docbook";
command = "xmlcatalog --noout --add "rewriteSystem" "http://www.oasis-open.org/docbook/xml/4.4" "file:///usr/share/xml/docbook/xml-dtd-4.4" /etc/xml/docbook";
command = "xmlcatalog --noout --add "rewriteURI" "http://www.oasis-open.org/docbook/xml/4.4" "file:///usr/share/xml/docbook/xml-dtd-4.4" /etc/xml/docbook";
command = "if [ ! -e /etc/xml/catalog ]; then xmlcatalog --noout --create /etc/xml/catalog; fi";
command = "xmlcatalog --noout --add "delegatePublic" "-//OASIS//ENTITIES DocBook XML" "file:///etc/xml/docbook" /etc/xml/catalog";
command = "xmlcatalog --noout --add "delegatePublic" "-//OASIS//DTD DocBook XML" "file:///etc/xml/docbook" /etc/xml/catalog";
command = "xmlcatalog --noout --add "delegateSystem" "http://www.oasis-open.org/docbook/" "file:///etc/xml/docbook" /etc/xml/catalog";
command = "xmlcatalog --noout --add "delegateURI" "http://www.oasis-open.org/docbook/" "file:///etc/xml/docbook" /etc/xml/catalog";
command = "cd ..";
command = "rm -rf docbook-xml";
time = "20070121 22:12:35 Sun";
"<"!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"这里是一个文档类型申明,即 DTD,PUBLIC 后面是一个 PUBLIC Identifier,然后是一个 SYSTEM Identifier,这里实际上是一个映射,将 PUBLIC Identifier 映射为 SYSTEM Identifier,所以 System Identifier 并不是指只有系统内部的 DTD!如上,只要是一个 URI 就行,当然必须是实际有效的。另外,XML 只能使用 System Identifier,所以必然会有这样一个映射,或者直接使用 SYSTEM:
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"">"
"<"!DOCTYPE chapter SYSTEM "/usr/share/sgml/docbook/xml-dtd-4.2-1.0-25/docbookx.dtd"">"所以编写一个 XML 文档,通常包括如下步骤:
pkgname = "mysql";那么 /data/mysql 的属主和这个包本身的属主就都是 mysql 这个用户了。这在安装的时候固然是方便了,但在删除的时候就会有问题,因为你基本上只会希望删除包的的程序,而不是它产生的其他数据。
version = "4.1.22";
user = "mysql";
groups = "";
group = "mysql";
archive = "mysql-4.1.22.tar.gz";
command = "tar xfz mysql-4.1.22.tar.gz";
command = "cd mysql-4.1.22";
command = "./configure --without-debug --with-extra-charsets=gb2312 --enable-assembler --without-isam --without-innodb --with-pthread --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --localstatedir=/data/mysql";
command = "make";
command = "make install";
command = "scripts/mysql_install_db --user=mysql";
command = "cp support-files/mysql.server /etc/rc.d/init.d/mysqld";
command = "chmod 0700 /etc/rc.d/init.d/mysqld";
command = "cd ..";
command = "rm -rf mysql-4.1.22";
command = "cd /usr/local/libexec";
command = "cp mysqld mysqld.backup";
command = "strip mysqld";
time = "20070107 21:22:55 Sun";
$ mysql_fix_privilege_tables --host=127.0.0.1 --password='******'5.5.1. mysql_fix_privilege_tables — Upgrade MySQL System Tables
$ mysqld_multi stop 01
$ mysqld_multi --mysqld=mysqld_safe start 01
import MySQLdb
import _mysql_exceptions
......
goaldb = MySQLdb.connect(user=dbuser, passwd=dbpass, host=dbhost, port=dbport, db=dbname)
SQL = "select ..."
goaldb.query(SQL)
rows = goaldb.store_result().fetch_row(maxrows=0)
if rows:
for r in rows:
......
SQL = "update ..."
goaldb.query(SQL)
else:
SQL = "insert ..."
goaldb.query(SQL)
except _mysql_exceptions.ProgrammingError, (errno, errstr):
strerr = "SQL Error: %d, %s" % (errno, errstr)
print strerr >> sys.stderr
except _mysql_exceptions.MySQLError, (errno, errstr):
strerr = "MySQL DB Error: %d, %s" % (errno, errstr)
print strerr >> sys.stderr
client$ ssh -L $local_port:server:$server_port forwarder sleep 60例如托管的网络有一台主机拥有外网地址,假设是 123.45.67.89,而另外一台是内网的数据库 192.168.0.3,没有外网地址,并且也没有做防火墙的映射,那么可以通过如下方式来登录内网数据库以进行维护:
client$ telnet localhost $local_port
$ ssh -L 2022:192.168.0.3:22 123.45.67.89 sleep 60注意第一个也必须登录,如果第一个登录退出,则第二个也会中断链接。
$ ssh $user@localhost 2022
forwarder$ ssh -R $client_port:server:$server_port client限制和禁止转发:
client$ telnet localhost $client_port
forwarder:/etc/hosts.deny
ALL:ALL
forwarder:/etc/hosts.allow
sshdfwd-$port: client
/etc/ssh/sshd_config:
AllowTcpForwarding yes/no
# Apache Configuration for PHP
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php
"<"Files *.php">"
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 9524288
"<"/Files">"