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

5 月 072013
 

1

#user  nobody;
worker_processes  1;

2

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

3

#pid        logs/nginx.pid;

4

events {
 worker_connections  1024;
}

5

http {
 include       mime.types;
 default_type  application/octet-stream;
#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 #                  '$status $body_bytes_sent "$http_referer" '
 #                  '"$http_user_agent" "$http_x_forwarded_for"';
#access_log  logs/access.log  main;
sendfile        on;
 #tcp_nopush     on;
#keepalive_timeout  0;
 keepalive_timeout  65;
#gzip  on;
server {
 listen       80;
 server_name  localhost;
#charset koi8-r;
#access_log  logs/host.access.log  main;
location / {
 root   html;
 index  index.html index.htm;
 }
#error_page  404              /404.html;
# redirect server error pages to the static page /50x.html
 #
 error_page   500 502 503 504  /50x.html;
 location = /50x.html {
 root   html;
 }
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
 #
 #location ~ \.php$ {
 #    proxy_pass   http://127.0.0.1;
 #}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 #
 #location ~ \.php$ {
 #    root           html;
 #    fastcgi_pass   127.0.0.1:9000;
 #    fastcgi_index  index.php;
 #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
 #    include        fastcgi_params;
 #}
# deny access to .htaccess files, if Apache's document root
 # concurs with nginx's one
 #
 #location ~ /\.ht {
 #    deny  all;
 #}
 }
# another virtual host using mix of IP-, name-, and port-based configuration
 #
 #server {
 #    listen       8000;
 #    listen       somename:8080;
 #    server_name  somename  alias  another.alias;
#    location / {
 #        root   html;
 #        index  index.html index.htm;
 #    }
 #}
# HTTPS server
 #
 #server {
 #    listen       443;
 #    server_name  localhost;
#    ssl                  on;
 #    ssl_certificate      cert.pem;
 #    ssl_certificate_key  cert.key;
#    ssl_session_timeout  5m;
#    ssl_protocols  SSLv2 SSLv3 TLSv1;
 #    ssl_ciphers  HIGH:!aNULL:!MD5;
 #    ssl_prefer_server_ciphers   on;
#    location / {
 #        root   html;
 #        index  index.html index.htm;
 #    }
 #}
}

获取nginx的性能状态信息

在编译nginx过程中需启用–with-http_stub_status_module参数

查看当前安装Nginx的版本与配置信息

[root@localhost conf]# export PATH=/usr/local/nginx/sbin/:$PATH
[root@localhost conf]# nginx -V
nginx version: nginx/1.4.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: –prefix=/usr/local/nginx –with-http_stub_status_module
–with-http_ssl_module –with-pcre=../pcre-8.32/
–with-zlib=../zlib-1.2.8 –with-openssl=../openssl-1.0.1e
[root@localhost conf]#

添加

location /status {
stub_status on;
access_log  off;
allow 192.168.244.0/24;
deny all;
}

nginx-140-config-01

服务器文件列表
[root@localhost conf]# pwd
/usr/local/nginx/conf
[root@localhost conf]# mkdir ../html/pub
[root@localhost conf]# touch ../html/pub/hello.txt

location /pub   {
autoindex on;
autoindex_exact_size on;
autoindex_localtime off;
}

nginx-140-config-02

检测配置文件正确性

[root@localhost conf]# nginx -t -c /usr/local/nginx/conf/nginx.conf
nginx: [emerg] unexpected end of file, expecting “}” in /usr/local/nginx/conf/nginx.conf:131
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
[root@localhost conf]#

nginx-140-config-03

[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]#

 

5 月 072013
 

About FastCGI

FastCGI is simple because it is actually CGI with only a few extensions.
Like CGI, FastCGI is also language-independent. For instance, FastCGI provides a way to improve the performance of the thousands of Perl applications that have been written for the Web.
Like CGI, FastCGI runs applications in processes isolated from the core Web server, which provides greater security than APIs. (APIs link application code into the core Web server, which means that a bug in one API-based application can corrupt another application or the core server; a malicious API-based application can, for example, steal key security secrets from another application or the core server.)
Although FastCGI cannot duplicate the universality of CGI overnight, the FastCGI developers are committed to propagating FastCGI as an open standard. To that end, free FastCGI application libraries (C/C++, Java, Perl, Tcl) and upgrade modules for popular free servers (Apache, ISS, Lighttpd) are available.
Like CGI, FastCGI is not tied to the internal architecture of any Web server and is therefore stable even when server technology changes. An API reflects the internal architecture of a Web server, so when that architecture changes, so does the API.

Not only does FastCGI restore the strengths of CGI, it also adds two new benefits:

Distributed computing: Companies can run their FastCGI application on a different machine from the one on which they run their Web server. Distributed computing is a proven technique for scaling, linking to existing corporate systems, improving system availability, and improving security via compartmentalization, such as firewalls.
Multiple and extensible roles: CGI applications compute the response to an HTTP request. FastCGI applications can do that and more, such as perform modular authentication and authorization checks and translate data from one type to another. FastCGI is designed so that more roles can be introduced in the future.

http://www.fastcgi.com/drupal/