5 月 102013
 

[root@localhost conf]# rpm -lq bind-utils
/usr/bin/dig
/usr/bin/host
/usr/bin/nslookup
/usr/bin/nsupdate
/usr/share/man/man1/dig.1.gz
/usr/share/man/man1/host.1.gz
/usr/share/man/man1/nslookup.1.gz
/usr/share/man/man1/nsupdate.1.gz
[root@localhost conf]#

[root@localhost conf]# rpm -lq jwhois
/etc/jwhois.conf
/usr/bin/jwhois
/usr/bin/whois
/usr/share/doc/jwhois-4.0
/usr/share/doc/jwhois-4.0/AUTHORS
/usr/share/doc/jwhois-4.0/COPYING
/usr/share/doc/jwhois-4.0/ChangeLog
/usr/share/doc/jwhois-4.0/NEWS
/usr/share/doc/jwhois-4.0/README
/usr/share/doc/jwhois-4.0/TODO
/usr/share/info/jwhois.info.gz
/usr/share/locale/es/LC_MESSAGES/jwhois.mo
/usr/share/locale/fr/LC_MESSAGES/jwhois.mo
/usr/share/locale/hu/LC_MESSAGES/jwhois.mo
/usr/share/locale/id/LC_MESSAGES/jwhois.mo
/usr/share/locale/it/LC_MESSAGES/jwhois.mo
/usr/share/locale/nl/LC_MESSAGES/jwhois.mo
/usr/share/locale/pl/LC_MESSAGES/jwhois.mo
/usr/share/locale/pt_BR/LC_MESSAGES/jwhois.mo
/usr/share/locale/ro/LC_MESSAGES/jwhois.mo
/usr/share/locale/ru/LC_MESSAGES/jwhois.mo
/usr/share/locale/rw/LC_MESSAGES/jwhois.mo
/usr/share/locale/sv/LC_MESSAGES/jwhois.mo
/usr/share/locale/tr/LC_MESSAGES/jwhois.mo
/usr/share/locale/vi/LC_MESSAGES/jwhois.mo
/usr/share/locale/zh_TW/LC_MESSAGES/jwhois.mo
/usr/share/man/man1/jwhois.1.gz
/usr/share/man/man1/whois.1.gz
/usr/share/man/sv/man1/jwhois.1.gz
[root@localhost conf]#

5 月 102013
 

Alternative PHP Cache (APC) 是一个开放自由的PHP opcode 缓存。它的目标是提供一个自由、 开放,和健全的框架用于缓存和优化PHP的中间代码。

http://pecl.php.net/package/apc

[root@localhost ~]# yum install php-pear

[root@localhost ~]# rpm -lq php-pear |grep /usr/bin/pear
/usr/bin/pear
/usr/bin/peardev
[root@localhost ~]# rpm -lq php-pear |grep /usr/bin/pecl
/usr/bin/pecl
[root@localhost ~]#

[root@localhost ~]# yum install php-devel

[root@localhost ~]# rpm -lq php-devel |less |grep phpize
/usr/bin/phpize
/usr/lib/php/build/phpize.m4
/usr/share/man/man1/phpize.1.gz
[root@localhost ~]#

[root@localhost ~]# yum install gcc make

[root@localhost ~]# yum install pcre-devel

[root@localhost ~]# pecl install http://pecl.php.net/get/APC-3.1.9.tgz

Build process completed successfully
Installing ‘/usr/include/php/ext/apc/apc_serializer.h’
Installing ‘/usr/lib/php/modules/apc.so’
install ok: channel://pecl.php.net/APC-3.1.9
configuration option “php_ini” is not set to php.ini location
You should add “extension=apc.so” to php.ini
[root@localhost ~]#

[root@localhost ~]# vi /etc/php.ini
extension=apc.so

php-apc-01 php-apc-02

eAccelerator is a free open-source PHP accelerator & optimizer. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.

eAccelerator stores compiled PHP scripts in shared memory and executes code directly from it. It creates locks only for a short time, while searching for a compiled PHP script in the cache, so one script can be executed simultaneously by several engines. Files that can’t fit in shared memory are cached on disk only.

eAccelerator was born in December 2004 as a fork of the Turck MMCache project. Turck MMCache was created by Dmitry Stogov and much of the eAccelerator code is still based on his work.

[root@localhost ~]# wget https://github.com/eaccelerator/eaccelerator/tarball/master

[root@localhost ~]# tar xzf eaccelerator-eaccelerator-42067ac.tar.gz
[root@localhost ~]# cd eaccelerator-eaccelerator-42067ac
[root@localhost eaccelerator-eaccelerator-42067ac]# ls
AUTHORS        doc                     ea_restore.h   opcodes.c
bugreport.php  eaccelerator.c          ea_store.c     opcodes.h
ChangeLog      eaccelerator.h          ea_store.h     optimize.c
config.m4      eaccelerator.ini        fnmatch.c      PHP_Highlight.php
config.w32     eaccelerator_version.h  fnmatch.h      README
control.php    ea_dasm.c               Makefile.frag  README.win32
COPYING        ea_dasm.h               Makefile.in    win32
dasm.php       ea_info.c               mm.c
debug.c        ea_info.h               mm.h
debug.h        ea_restore.c            NEWS
[root@localhost eaccelerator-eaccelerator-42067ac]#php-eaccelerator-01

php-eaccelerator-02 php-eaccelerator-03

[root@localhost eaccelerator-eaccelerator-42067ac]# yum install php-devel gcc make

[root@localhost eaccelerator-eaccelerator-42067ac]# phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
[root@localhost eaccelerator-eaccelerator-42067ac]#

[root@localhost eaccelerator-eaccelerator-42067ac]# ./configure –enable-eaccelerator=shared –with-php-config=/usr/bin/php-config
[root@localhost eaccelerator-eaccelerator-42067ac]# make
[root@localhost eaccelerator-eaccelerator-42067ac]# make install

[root@localhost eaccelerator-eaccelerator-42067ac]# vi /etc/php.ini
extension=eaccelerator.so

[root@localhost eaccelerator-eaccelerator-42067ac]# vi /var/www/html/index.php
<?php phpinfo(); ?>

php-eaccelerator-04

[root@localhost httpd-2.2.24]# yum install gcc make perl
[root@localhost httpd-2.2.24]# ./configure –prefix=/usr/local/apache \
> –enable-so –enable-rewrite
[root@localhost httpd-2.2.24]# make
[root@localhost httpd-2.2.24]# make install

[root@localhost php-5.2.17]# yum install libxml2-devel
[root@localhost php-5.2.17]# ./configure –prefix=/usr/local/php \
> –with-apxs2=/usr/local/apache/bin/apxs \
[root@localhost php-5.2.17]# make
[root@localhost php-5.2.17]# make install

[root@localhost php-5.2.17]# cp php.ini-dist /usr/local/php/lib/php.ini
[root@localhost php-5.2.17]# export PATH=/usr/local/php/bin:$PATH

修改Apache配置文件以支持PHP
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>

AddType application/x-httpd-php .php

[root@localhost ~]# /usr/local/apache/bin/apachectl start

[root@localhost ~]# vi /usr/local/apache/htdocs/index.php
<?php phpinfo(); ?>

[root@localhost ~]# tar xzf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
[root@localhost ~]# cd ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp
[root@localhost 5_2_x_comp]# cp ZendOptimizer.so /usr/local/php/lib/php

[root@localhost 5_2_x_comp]# vi /usr/local/php/lib/php.ini
extension=/usr/local/php/lib/php/ZendOptimizer.so

 

 

 

 

php-zendoptimizer-01 php-zendoptimizer-02 php-zendoptimizer-03

 

相关下载:
(1)APC 3.1.9 (2) eAccelerator 42067ac (3)ZendOptimizer 3.3.9 i386 (4) ZendOptimizer 3.3.9 x86_64

5 月 102013
 

Changes with nginx 1.4.1                                         07 May 2013

*) Security: a stack-based buffer overflow might occur in a worker
process while handling a specially crafted request, potentially
resulting in arbitrary code execution (CVE-2013-2028); the bug had
appeared in 1.3.9.
Thanks to Greg MacManus, iSIGHT Partners Labs.

Changes with nginx 1.4.0                                         24 Apr 2013

*) Bugfix: nginx could not be built with the ngx_http_perl_module if the
–with-openssl option was used; the bug had appeared in 1.3.16.

*) Bugfix: in a request body handling in the ngx_http_perl_module; the
bug had appeared in 1.3.9.

Changes with nginx 1.2.8                                         02 Apr 2013

*) Bugfix: new sessions were not always stored if the “ssl_session_cache
shared” directive was used and there was no free space in shared
memory.
Thanks to Piotr Sikora.

*) Bugfix: responses might hang if subrequests were used and a DNS error
happened during subrequest processing.
Thanks to Lanshun Zhou.

*) Bugfix: in the ngx_http_mp4_module.
Thanks to Gernot Vormayr.

*) Bugfix: in backend usage accounting.

5 月 092013
 

使用NFS作为web服务共享存储
192.168.244.129

安装NFS软件包

[root@nfs ~]# yum install nfs-utils

创建共享存储挂载点并输出共享

[root@nfs ~]# mkdir /shared
[root@nfs ~]# chmod 777 /shared/
[root@nfs ~]# vi /etc/exports
 /shared 192.168.244.0/24(rw,sync)

启动NFS服务

[root@nfs ~]# service nfs start
 Starting NFS services:                                     [  OK  ]
 Starting NFS mountd:                                       [  OK  ]
 Starting NFS daemon:                                       [  OK  ]
[root@nfs ~]#

查看当前输出共享信息

[root@nfs ~]# showmount -e
 Export list for nfs:
 /shared 192.168.244.0/24
[root@nfs ~]#

配置第一台apache主机
192.168.244.130

安装PHP与HTTPD软件包

[root@ap1 ~]# yum install httpd php

编辑apache配置文件

[root@ap1 ~]# vi /etc/httpd/conf/httpd.conf
 Listen 8001
 ServerName 192.168.244.130:8001

查看NFS主机共享存储状态

[root@ap1 ~]# showmount -e 192.168.244.129
 Export list for 192.168.244.129:
 /shared 192.168.244.0/24
[root@ap1 ~]#

挂载NFS共享存储并查看挂载状态

[root@ap1 ~]# mount -t nfs 192.168.244.129:/shared /var/www/html/
[root@ap1 ~]# mount
 /dev/mapper/VolGroup-lv_root on / type ext4 (rw)
 proc on /proc type proc (rw)
 sysfs on /sys type sysfs (rw)
 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
 tmpfs on /dev/shm type tmpfs (rw)
 /dev/sda1 on /boot type ext4 (rw)
 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
 sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
 192.168.244.129:/shared on /var/www/html type nfs (rw,vers=4,addr=192.168.244.129,clientaddr=192.168.244.130)
[root@ap1 ~]#

修改分区挂载文件保证重启后自动挂载

[root@ap1 ~]# vi /etc/fstab
 192.168.244.129         /var/www/html           nfs     defaults        0 0

创建第一个PHP测试文件

[root@ap1 ~]# touch /var/www/html/ap1.php
 [root@ap1 ~]# echo "<?php phpinfo(); ?>" > /var/www/html/ap1.php
 [root@ap1 ~]# service httpd start
 Starting httpd:                                            [  OK  ]
[root@ap1 ~]#

配置第二台apache主机
192.168.244.131

[root@ap2 ~]# yum install httpd php
[root@ap2 ~]# vi /etc/httpd/conf/httpd.conf
 Listen 8002
 ServerName 192.168.244.131:8002
[root@ap2 ~]# mount -t nfs 192.168.244.129:/shared /var/www/html/
[root@ap2 ~]# vi /etc/fstab
 192.168.244.129         /var/www/html           nfs     defaults        0 0
[root@ap2 ~]# touch /var/www/html/ap2.php
[root@ap2 ~]# echo "<?php phpinfo(); ?>" > /var/www/html/ap2.php
[root@ap2 ~]# service httpd start
 Starting httpd:                                            [  OK  ]
[root@ap2 ~]#

配置第一台nginx主机
192.168.244.132

[root@ng1 ~]# yum install gcc make
[root@ng1 ~]# groupadd nginx
 [root@ng1 ~]# useradd -g nginx nginx -s /sbin/nologin
[root@ng1 ~]# yum install gcc-c++ perl
[root@ng1 ~]# cd nginx-1.4.0
 [root@ng1 nginx-1.4.0]# ./configure --prefix=/usr/local/nginx \
 > --with-http_ssl_module \
 > --with-pcre=../pcre-8.32/ --with-zlib=../zlib-1.2.8 \
 > --with-openssl=../openssl-1.0.1e
 [root@ng1 nginx-1.4.0]# make
 [root@ng1 nginx-1.4.0]# make install
[root@ng1 nginx-1.4.0]# export PATH=/usr/local/nginx/sbin:$PATH

修改nginx配置文件

[root@ng1 nginx-1.4.0]# cd /usr/local/nginx/conf/
[root@ng1 conf]# vi nginx.conf
user nginx;

server {
listen          8003;
server_name     192.168.244.132;
access_log      logs/ng1.access.log;

location / {
root   html;
index  index.html index.htm;
}
}

检测nginx配置文件语法正确性

[root@ng1 conf]# nginx -t -c /usr/local/nginx/conf/nginx.conf
 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
 nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@ng1 conf]#

挂载NFS共享存储

[root@ng1 conf]# mount -t nfs 192.168.244.129:/shared /usr/local/nginx/html/
[root@ng1 conf]# vi /etc/fstab
 192.168.244.129         /usr/local/nginx/html   nfs     defaults        0 0
[root@ng1 conf]#

创建nginx静态测试文件
[root@ng1 conf]# touch ../html/ng1.html
[root@ng1 conf]# echo “hello nginx” > ../html/ng1.html

nginx-proxy-0509-01

查看已上传测试文件及图片
[root@ng1 ~]# ls /usr/local/nginx/html/
ap1.php  ap2.php  ng1.html  nginx.gif  nginx.html
[root@ng1 ~]#

配置nginx反向代理服务器
192.168.244.140

使用两台后端apache主机的单一负载均衡配置

[root@rproxy ~]# cd /usr/local/nginx/conf/

upstream apache {
 server 192.168.244.130:8001;
 server 192.168.244.131:8002;
 }

server {
 listen 80;
 server_name 192.168.244.140;

location / {
 proxy_pass  http://apache;
 }
 }

nginx-proxy-0509-02

[root@ap1 ~]# cat /var/log/httpd/access_log
192.168.244.140 – – [09/May/2013:14:12:32 +0800] “GET /icons/apache_pb.gif HTTP/1.0” 200 2326 “http://192.168.244.140/” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”

[root@ap2 ~]# cat /var/log/httpd/access_log
192.168.244.140 – – [09/May/2013:14:12:32 +0800] “GET / HTTP/1.0” 403 5039 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”
192.168.244.140 – – [09/May/2013:14:12:32 +0800] “GET /icons/poweredby.png HTTP/1.0” 200 3956 “http://192.168.244.140/” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”

nginx-proxy-0509-03

[root@ap1 ~]# cat /var/log/httpd/access_log
192.168.244.140 – – [09/May/2013:14:17:37 +0800] “GET /nginx.html HTTP/1.0” 200 333 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”
192.168.244.140 – – [09/May/2013:14:17:37 +0800] “GET /favicon.ico HTTP/1.0” 404 283 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”

[root@ap2 ~]# cat /var/log/httpd/access_log
192.168.244.140 – – [09/May/2013:14:17:37 +0800] “GET /nginx.gif HTTP/1.0” 200 524 “http://192.168.244.140/nginx.html” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”

使用两台apache主机与一台nginx主机分别处理动态和静态文件,同时负载均衡apache主机

动态文件需要服务器额外处理后通过浏览器将结果返回给客户
静态文件不需要额外服务器处理可以直接将结果给客户

upstream apache {
server 192.168.244.130:8001;
server 192.168.244.131:8002;
}

server {
listen       80;
server_name  localhost;

location / {
proxy_pass http://192.168.244.132:8003;
expires 7d;
}

location ~ \.php$ {
proxy_pass  http://apache;
}
}

nginx-proxy-0509-04

[root@ng1 ~]# cat /usr/local/nginx/logs/error.log
2013/05/09 14:41:46 [error] 19504#0: *1 open() “/usr/local/nginx/html/ningix.html” failed (2: No such file or directory), client: 192.168.244.140, server: 192.168.244.132, request: “GET /ningix.html HTTP/1.0”, host: “192.168.244.132:8003”

[root@ng1 ~]# cat /usr/local/nginx/logs/ng1.access.log
192.168.244.140 – – [09/May/2013:14:43:23 +0800] “GET /nginx.html HTTP/1.0” 200 333 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”
192.168.244.140 – – [09/May/2013:14:43:23 +0800] “GET /nginx.gif HTTP/1.0” 200 524 “http://192.168.244.140/nginx.html” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”
192.168.244.140 – – [09/May/2013:14:43:24 +0800] “GET /favicon.ico HTTP/1.0” 404 570 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”

[root@ap1 ~]# cat /var/log/httpd/access_log |grep 14:43:
[root@ap1 ~]#

[root@ap2 ~]# cat /var/log/httpd/access_log |grep 14:43:
[root@ap2 ~]#

nginx-proxy-0509-05

[root@ap1 ~]# cat /var/log/httpd/access_log
192.168.244.140 – – [09/May/2013:14:46:45 +0800] “GET /ap2.php HTTP/1.0” 200 45086 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”
192.168.244.140 – – [09/May/2013:14:46:45 +0800] “GET /ap2.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.0” 200 2146 “http://192.168.244.140/ap2.php” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”

[root@ap2 ~]# cat /var/log/httpd/access_log
192.168.244.140 – – [09/May/2013:14:46:45 +0800] “GET /ap2.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 HTTP/1.0” 200 2524 “http://192.168.244.140/ap2.php” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”

nginx-proxy-0509-06

[root@ng1 ~]# cat /usr/local/nginx/logs/ng1.access.log
192.168.244.140 – – [09/May/2013:15:56:03 +0800] “GET /ng1.html HTTP/1.0” 200 12 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”

5 月 072013
 

查看当前网络接口IP信息

[root@localhost ~]# ifconfig
 eth0      Link encap:Ethernet  HWaddr 00:0C:29:2F:3B:EA
 inet addr:192.168.244.134  Bcast:192.168.244.255  Mask:255.255.255.0
 inet6 addr: fe80::20c:29ff:fe2f:3bea/64 Scope:Link
 UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 RX packets:65028 errors:0 dropped:0 overruns:0 frame:0
 TX packets:49997 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:73780559 (70.3 MiB)  TX bytes:4130968 (3.9 MiB)
 Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback
 inet addr:127.0.0.1  Mask:255.0.0.0
 inet6 addr: ::1/128 Scope:Host
 UP LOOPBACK RUNNING  MTU:16436  Metric:1
 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@localhost ~]#

查看eth0配置文件信息

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# vi ifcfg-eth0
 DEVICE="eth0"
 BOOTPROTO="static"
 HWADDR="00:0C:29:2F:3B:EA"
 NM_CONTROLLED="yes"
 ONBOOT="yes"
 TYPE="Ethernet"
 UUID="8c8eb461-11b0-445f-b67b-8d78111c2589"
 IPADDR=192.168.244.134
 PREFIX=24
 GATEWAY=192.168.244.1
 DNS1=202.96.128.86

添加第一IP绑定配置文件

[root@localhost network-scripts]# vi ifcfg-eth0:1
 DEVICE="eth0:1"
 BOOTPROTO="static"
 ONBOOT="yes"
 TYPE="Ethernet"
 IPADDR=192.168.244.136
 PREFIX=24
 GATEWAY=192.168.244.1

添加第二个IP绑定配置文件

[root@localhost network-scripts]# vi ifcfg-eth0:2
 DEVICE="eth0:1"
 BOOTPROTO="static"
 ONBOOT="yes"
 TYPE="Ethernet"
 IPADDR=192.168.244.136
 PREFIX=24
 GATEWAY=192.168.244.1

查看当前系统下所有网络接口信息

[root@localhost network-scripts]# ifconfig
 eth0      Link encap:Ethernet  HWaddr 00:0C:29:2F:3B:EA
 inet addr:192.168.244.134  Bcast:192.168.244.255  Mask:255.255.255.0
 inet6 addr: fe80::20c:29ff:fe2f:3bea/64 Scope:Link
 UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 RX packets:65992 errors:0 dropped:0 overruns:0 frame:0
 TX packets:50693 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:73868397 (70.4 MiB)  TX bytes:4234444 (4.0 MiB)
 Interrupt:19 Base address:0x2000

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:2F:3B:EA
 inet addr:192.168.244.136  Bcast:192.168.244.255  Mask:255.255.255.0
 UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 Interrupt:19 Base address:0x2000

eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:2F:3B:EA
 inet addr:192.168.244.138  Bcast:192.168.244.255  Mask:255.255.255.0
 UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback
 inet addr:127.0.0.1  Mask:255.0.0.0
 inet6 addr: ::1/128 Scope:Host
 UP LOOPBACK RUNNING  MTU:16436  Metric:1
 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@localhost network-scripts]#

通过命令行进行IP绑定

[root@localhost network-scripts]# ifconfig eth0:3 192.168.244.140 netmask 255.255.255.0
 [root@localhost network-scripts]# ifconfig eth0:3
 eth0:3    Link encap:Ethernet  HWaddr 00:0C:29:2F:3B:EA
 inet addr:192.168.244.140  Bcast:192.168.244.255  Mask:255.255.255.0
 UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 Interrupt:19 Base address:0x2000

[root@localhost network-scripts]#

基于IP地址的虚拟主机配置

[root@localhost ~]# cd /usr/local/nginx/conf/

[root@localhost conf]# mkdir ../html/ipv1
[root@localhost conf]# touch ../html/ipv1/index.html
[root@localhost conf]# echo “IP based virtual host 1 OK”>../html/ipv1/index.html
[root@localhost conf]# mkdir ../html/ipv2
[root@localhost conf]# touch ../html/ipv2/index.html
[root@localhost conf]# echo “IP based virtual host 2 OK”>../html/ipv2/index.html

在nginx配置文件中添加基于IP的虚拟机主机配置
[root@localhost conf]# vi nginx.conf
server {
listen       192.168.244.136:80;
server_name  192.168.244.136;
access_log   logs/ipv1_access.log;

location / {
root   html/ipv1;
index  index.html index.htm;
}
}

server {
listen       192.168.244.138:80;
server_name  192.168.244.138;
access_log   logs/ipv2_access.log;

location / {
root   html/ipv2;
index  index.html index.htm;
}
}

确认修改后的配置文件语法正确性
[root@localhost conf]# nginx -t -c /usr/local/nginx/conf/nginx.conf
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost conf]#

nginx-vhost-0507-01 nginx-vhost-0507-02

基于主机名的虚拟机主机配置

建立测试目录及文件

[root@localhost conf]# mkdir ../html/nv1
[root@localhost conf]# touch ../html/nv1/index.html
[root@localhost conf]# echo “Name based virtual host 1 OK”>../html/nv1/index.html
[root@localhost conf]# mkdir ../html/nv2
[root@localhost conf]# touch ../html/nv2/index.html
[root@localhost conf]# echo “Name based virtual host 2 OK”>../html/nv2/index.html
[root@localhost conf]# mkdir ../html/nv3
[root@localhost conf]# touch ../html/nv3/index.html
[root@localhost conf]# echo “Name based virtual host 3 OK”>../html/nv3/index.html

在nginx配置文件中添加基于主机名的虚拟机主机配置
server {
listen       80;
server_name  nv1.linuxcache.net;
access_log   logs/nv1_access.log;

location / {
root   html/nv1;
index  index.html index.htm;
}
}

server {
listen       80;
server_name  nv2.linuxcache.net nv3.linuxcache.net;
access_log   logs/nv2_access.log;

location / {
root   html/nv2;
index  index.html index.htm;
}
}

server {
listen       80;
server_name  *.linuxcache.cn;
access_log   logs/nv3_access.log;

location / {
root   html/nv3;
index  index.html index.htm;
}
}

修改Windows客户机主机文件将测试域名指向虚拟机IP地址
C:\Windows\System32\drivers\etc\hosts
192.168.244.134 nv1.linuxcache.net
192.168.244.134 nv2.linuxcache.net
192.168.244.134 nv3.linuxcache.net
192.168.244.134 www.linuxcache.cn
192.168.244.134 mail.linuxcache.cn

nginx-vhost-0507-03 nginx-vhost-0507-04 nginx-vhost-0507-05 nginx-vhost-0507-06 nginx-vhost-0507-07

5 月 072013
 

Tar文件打包工具

查看当前系统下tar版本信息

[root@localhost ~]# tar --version
tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.

[root@localhost ~]#

Tar命令示例

tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
tar -tvf archive.tar         # List all files in archive.tar verbosely.
tar -xf archive.tar          # Extract all files from archive.tar.

文件操作参数
-c, --create               create a new archive
-t, --list                 list the contents of an archive
-f, --file=ARCHIVE         use archive file or device ARCHIVE
-x, --extract, --get       extract files from an archive
追加打包
-r, --append
增量打包               append files to the end of an archive
-u, --update               only append files newer than copy in archive

压缩选项
-j, --bzip2                filter the archive through bzip2
-z, --gzip, --gunzip, --ungzip   filter the archive through gzip
-v, --verbose              verbosely list files processed
-J, --xz                   filter the archive through xz

CentOS6.3最小化环境默认未包含xz压缩工具

[root@localhost ~]# yum install xz
[root@localhost ~]# tar -Jxvf zlib-1.2.8.tar.xz

Gzip压缩工具常用命令参数

-d, --decompress  decompress
-l, --list        list compressed file contents

-n, --no-name     do not save or restore the original name and time stamp
-N, --name        save or restore the original name and time stamp

-t, --test        test compressed file integrity
-v, --verbose     verbose mode

-1, --fast        compress faster
-9, --best        compress better

测试压缩包完整性

[root@localhost ~]# gzip -tv nginx-1.4.0.tar.gz
nginx-1.4.0.tar.gz:      OK
[root@localhost ~]#

查看压缩包文件列表

[root@localhost ~]# gzip -l nginx-1.4.0.tar.gz
compressed        uncompressed  ratio uncompressed_name
2847187            14213120  80.0% nginx-1.4.0.tar
[root@localhost ~]#

Bzip2压缩工具常用命令参数

-d --decompress     force decompression
-z --compress       force compression
-f --force          overwrite existing output files
-t --test           test compressed file integrity
-v --verbose        be verbose (a 2nd -v gives more)
-1 .. -9            set block size to 100k .. 900k
--fast              alias for -1
--best              alias for -9

[root@localhost ~]# bzip2 -d nginx-1.4.0.tar.bz2

[root@localhost ~]# bzip2 -tv nginx-1.4.0.tar.bz2
nginx-1.4.0.tar.bz2: ok
[root@localhost ~]#

XZ压缩工具完整命令参数

-z, --compress      force compression
-d, --decompress    force decompression
-t, --test          test compressed file integrity
-l, --list          list information about files
-k, --keep          keep (don't delete) input files
-f, --force         force overwrite of output file and (de)compress links
-c, --stdout        write to standard output and don't delete input files
-0 .. -9            compression preset; 0-2 fast compression, 3-5 good
compression, 6-9 excellent compression; default is 6
-e, --extreme       use more CPU time when encoding to increase compression
ratio without increasing memory usage of the decoder
-q, --quiet         suppress warnings; specify twice to suppress errors too
-v, --verbose       be verbose; specify twice for even more verbose
-h, --help          display this short help
-H, --long-help     display the long help (lists also the advanced options)
-V, --version       display the version number

Linux下RAR压缩格式的压缩及解压缩命令与参数

[root@localhost ~]# tar xzvf rarlinux-4.2.0.tar.gz
[root@localhost ~]# mv rar /usr/local/
[root@localhost ~]# export PATH=/usr/local/rar/:$PATH

常用命令参数
a             Add files to archive
c             Add archive comment
e             Extract files to current directory
t             Test archive files
x             Extract files with full path

-dw            Wipe files after archiving
-k             Lock archive
-m<0..5>       Set compression level (0-store...3-default...5-maximal)
-p[password]   Set password

压缩指定文件夹

[root@localhost ~]# rar a zlib.rar zlib-1.2.8

压缩指定文件或目录后进行完整性测试

[root@localhost ~]# rar a -t zlib.rar zlib-1.2.8

使用压缩级别参数提高压缩比率

[root@localhost ~]# ll zlib.rar
-rw-r--r-- 1 root root 692321 May  8 11:33 zlib.rar
[root@localhost ~]# rm -rf zlib.rar
[root@localhost ~]# rar a -m5 zlib.rar zlib-1.2.8
[root@localhost ~]# ll zlib.rar
-rw-r--r-- 1 root root 691643 May  8 11:34 zlib.rar
[root@localhost ~]#

生成压缩文件后删除原始文件

[root@localhost ~]# rar a -dw zlib.rar zlib-1.2.8

解压缩

[root@localhost ~]# rm -rf zlib-1.2.8
[root@localhost ~]# rar x zlib.rar

设置压缩包密码

[root@localhost ~]# rar a -p12345 zlib.rar zlib-1.2.8

解压缩含有密码的压缩包

[root@localhost ~]# rar x zlib.rar

RAR 4.20   Copyright (c) 1993-2012 Alexander Roshal   9 Jun 2012
 Trial version             Type RAR -? for help

Extracting from zlib.rar

Enter password (will not be echoed) for Makefile.sas:

相关下载:
(1) rarlinux 4.2.0  (2) rarlinux 4.2.0 x64