2 月 232013
 

在CentOS6.3最小化安装环境中需要安装的软件包

[root@squid ~]# yum install wget gcc gcc-c++ make perl

编译安装Squid

 [root@squid ~]# cd squid-3.3.1
 [root@squid squid-3.3.1]# ./configure --prefix=/usr/local/squid
 [root@squid squid-3.3.1]# make all
 [root@squid squid-3.3.1]# make install

安装完成后查看安装文件目录及配置文件

 [root@squid squid-3.3.1]# cd /usr/local/squid/
 [root@squid squid]# ls
 bin etc include lib libexec sbin share var
 [root@squid squid]# ls etc/
 cachemgr.conf mime.conf squid.conf
 cachemgr.conf.default mime.conf.default squid.conf.default
 errorpage.css msntauth.conf squid.conf.documented
 errorpage.css.default msntauth.conf.default
 [root@squid squid]#

Continue reading »

2 月 212013
 

安装编译工具

[root@localhost ~]# yum install gcc make

添加用以执行nginx的用户

[root@localhost conf]# groupadd nginx
[root@localhost conf]# useradd -g nginx nginx -s /sbin/nologin

安装PHP依赖

[root@localhost php-5.2.17]# yum install libxml2-devel

CentOS 6.3最小化安装环境已包含libxml2未包含libxml2-devel

libxml2-devel的安装依赖包关系

Installing:
 libxml2-devel        i686        2.7.6-12.el6_4.1         updates        1.1 M
Installing for dependencies:
 pkgconfig            i686        1:0.23-9.1.el6           base            67 k
 zlib-devel           i686        1.2.3-29.el6             base            44 k
Updating for dependencies:
 libxml2              i686        2.7.6-12.el6_4.1         updates        800 k
 zlib                 i686        1.2.3-29.el6             base            73 k

编译安装PHP环境

[root@localhost php-5.2.17]# ./configure --prefix=/usr/local/php --enable-fastcgi
[root@localhost php-5.2.17]# make
[root@localhost php-5.2.17]# make install

将路径加入系统环境变量

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

启动php-cgi模式,监听端口9000,并使用指定的php.ini配置,后台运行

[root@localhost ~]# php-cgi -b 9000 -c /usr/local/php/lib/php.ini &

查看php-cgi监听端口

[root@localhost ~]# netstat -ltun |grep 9000
 tcp        0      0 0.0.0.0:9000                0.0.0.0:*                   LISTEN
 [root@localhost ~]#

安装nginx编译过程中所需要的依赖软件包

[root@localhost nginx-1.4.0]# yum install gcc-c++ perl

编译安装nginx 1.4.0版本

[root@localhost nginx-1.4.0]# ./configure --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 nginx-1.4.0]# make
[root@localhost nginx-1.4.0]# make install

将nginx加入系统环境变量

export PATH=/usr/local/nginx/sbin:$PATH

查看nginx版本

[root@localhost ~]# nginx -v
 nginx version: nginx/1.4.0
 [root@localhost ~]#

默认示例配置文件部分

# 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;
#}

启用FastCGI并修改配置

location ~ \.php$ {
 root           html;
 fastcgi_pass   127.0.0.1:9000;
 fastcgi_index  index.php;
 #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
 fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;
 include        fastcgi_params;
 }

建立PHP测试页面文件

[root@localhost ~]# cd /usr/local/nginx/html/
[root@localhost html]# vi hello.php
 <?php phpinfo(); ?>

启动nginx并查看端口监听状态

[root@localhost ~]# netstat -ltu |grep http
 tcp        0      0 *:http                      *:*                         LISTEN
[root@localhost ~]#

访问默认首页

nginx-php-01

 

访问PHP测试页面

…… nginx-php-02

相关下载:
(1) nginx 1.4.0 (2)(3)

2 月 202013
 

下载最新版本nginx,pcre,openssl,zlib并解压缩

nginx-01-01

编译安装

 [root@localhost nginx-1.2.7]# ./configure --prefix=/usr/local/nginx \
 --with-pcre=../pcre-8.32/ --with-zlib=../zlib-1.2.7 \
 --with-openssl=../openssl-1.0.1e --with-http_ssl_module
[root@localhost nginx-1.2.7]#make
[root@localhost nginx-1.2.7]#make install

查看安装完成nginx的版本

[root@localhost sbin]# ./nginx -v
 nginx version: nginx/1.2.7

查看nginx命令参数

[root@localhost sbin]# ./nginx -h
nginx version: nginx/1.2.7
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
 -?,-h : this help
 -v : show version and exit
 -V : show version and configure options then exit
 -t : test configuration and exit
 -q : suppress non-error messages during configuration testing
 -s signal : send signal to a master process: stop, quit, reopen, reload
 -p prefix : set prefix path (default: /usr/local/nginx/)
 -c filename : set configuration file (default: conf/nginx.conf)
 -g directives : set global directives out of configuration file
[root@localhost sbin]#

启动

[root@localhost sbin]# ./nginx
 [root@localhost sbin]# netstat -lut |grep http
 tcp 0 0 *:http *:* LISTEN
 [root@localhost sbin]#

通过浏览器访问nginx服务器
nginx-01-02

错误分析1

./configure: error: the HTTP rewrite module requires the PCRE library.
 You can either disable the module by using --without-http_rewrite_module
 option, or install the PCRE library into the system, or build the PCRE library
 statically from the source with nginx by using --with-pcre=<path> option.

错误分析2

./configure: error: the HTTP gzip module requires the zlib library.
 You can either disable the module by using --without-http_gzip_module
 option, or install the zlib library into the system, or build the zlib library
 statically from the source with nginx by using --with-zlib=<path> option.

错误分析3

./configure: error: SSL modules require the OpenSSL library.
 You can either do not enable the modules, or install the OpenSSL library
 into the system, or build the OpenSSL library statically from the source
 with nginx by using --with-openssl=<path> option.

Nginx官方文档配置参数

--prefix=path
 --sbin-path=path
 --conf-path=path
 --pid-path=path
 --error-log-path=path
 --http-log-path=path
 --user=name
 --with-select_module
 --without-select_module
 --with-poll_module
 --without-poll_module
 --without-http_gzip_module
 --without-http_proxy_module
 --with-http_ssl_module
 --with-pcre=path
 --with-pcre-jit
 --with-zlib=path
--with-cc-opt=parameters
 --with-ld-opt=parameters

Nginx官方文档配置示例

./configure
 --sbin-path=/usr/local/nginx/nginx
 --conf-path=/usr/local/nginx/nginx.conf
 --pid-path=/usr/local/nginx/nginx.pid
 --with-http_ssl_module
 --with-pcre=../pcre-4.4
 --with-zlib=../zlib-1.1.3

相关下载:
(1)nginx 1.2.7 (2)openssl 1.0.1e (3)pcre 8.32 (4)zlib 1.2.7
内容引用:
(1)

1 月 212013
 

登录并查看

login as: root
 root@192.168.11.160's password:
 [root@localhost ~]# ifconfig
 eth0 Link encap:Ethernet HWaddr 00:50:56:A8:6C:61
 inet addr:192.168.11.160 Bcast:192.168.11.255 Mask:255.255.255.0
 inet6 addr: fe80::250:56ff:fea8:6c61/64 Scope:Link
 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 RX packets:114 errors:0 dropped:0 overruns:0 frame:0
 TX packets:54 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:9166 (8.9 KiB) TX bytes:6535 (6.3 KiB)

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 ~]# cd /etc/sysconfig/network-scripts/
 [root@localhost network-scripts]# cat ifcfg-eth0
 DEVICE="eth0"
 BOOTPROTO=none
 NM_CONTROLLED="yes"
 ONBOOT=yes
 TYPE="Ethernet"
 UUID="f0bd6d3b-c8dc-4e8a-8d9d-91938a5f4be1"
 HWADDR=00:50:56:A8:6C:61
 IPADDR=192.168.11.160
 PREFIX=24
 GATEWAY=192.168.11.1
 DNS1=202.96.128.86
 DEFROUTE=yes
 IPV4_FAILURE_FATAL=yes
 IPV6INIT=no
 NAME="System eth0"
 [root@localhost network-scripts]#
[root@localhost network-scripts]# cat ifcfg-eth1
 DEVICE="eth1"
 BOOTPROTO="dhcp"
 HWADDR="00:50:56:A8:6C:62"
 NM_CONTROLLED="yes"
 ONBOOT="no"
 TYPE="Ethernet"
 UUID="fce1b80b-9e63-4468-aaaa-529e991a5cff"
 [root@localhost network-scripts]#

修改内核模块加载参数
[root@localhost ~]# cd /etc/modprobe.d/
[root@localhost modprobe.d]# vi bonding.conf

alias bond0 bonding
options bond0 miimon=80 mode=5

mode参数所支持的选项

modes:
mode=0 (Balance Round Robin)
mode=1 (Active backup)
mode=2 (Balance XOR)
mode=3 (Broadcast)
mode=4 (802.3ad)
mode=5 (Balance TLB)
mode=6 (Balance ALB)

创建绑定接口的配置文件

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
 [root@localhost network-scripts]# vi ifcfg-bond0
 DEVICE=bond0
 IPADDR=192.168.11.160
 NETMASK=255.255.255.0
 NETWORK=192.16.11.0
 BROADCAST=192.168.11.255
 GATEWAY=192.168.11.1
 ONBOOT=yes
 BOOTPROTO=none
 USERCTL=no

修改网卡配置文件

[root@localhost network-scripts]# vi ifcfg-eth0
 DEVICE=eth0
 ONBOOT=yes
 BOOTPROTO=none
 USERCTL=no
 MASTER=bond0
 SLAVE=yes
[root@localhost network-scripts]# vi ifcfg-eth1
 DEVICE=eth1
 ONBOOT=yes
 BOOTPROTO=none
 USERCTL=no
 MASTER=bond0
 SLAVE=yes

重启网络服务

[root@localhost network-scripts]# service network restart > 2012
/etc/sysconfig/network-scripts/ifdown-eth: line 116: /sys/class/net/bond0/bonding/slaves: No such file or directory
[root@localhost network-scripts]# cat 2012
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface bond0: [ OK ]
[root@localhost network-scripts]#

^

[root@localhost ~]# ifconfig
 bond0 Link encap:Ethernet HWaddr 00:50:56:A8:6C:61
 inet addr:192.168.11.160 Bcast:192.168.11.255 Mask:255.255.255.0
 inet6 addr: fe80::250:56ff:fea8:6c61/64 Scope:Link
 UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
 RX packets:892 errors:0 dropped:0 overruns:0 frame:0
 TX packets:983 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:68406 (66.8 KiB) TX bytes:87517 (85.4 KiB)

eth0 Link encap:Ethernet HWaddr 00:50:56:A8:6C:61
 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
 RX packets:518 errors:0 dropped:0 overruns:0 frame:0
 TX packets:650 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:45276 (44.2 KiB) TX bytes:66535 (64.9 KiB)

eth1 Link encap:Ethernet HWaddr 00:50:56:A8:6C:62
 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
 RX packets:374 errors:0 dropped:0 overruns:0 frame:0
 TX packets:334 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:23130 (22.5 KiB) TX bytes:21216 (20.7 KiB)

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)

 

sbonding-bond0 bonding-eth0 bonding-eth1 bonding-eth2 bonding-eth3

内容引用:
(1)CenOS Wiki (2)Linux Channel Bonding

修改内核模块加载参数

span style=”color: #008000;”

1 月 182013
 

查看当前OpenVPN虚拟网卡所获得的IP地址信息

route-static-01

查看系统路由表

route-static-02

指定使用与OpenVPN默认网关接口相同的IP添加去往192.168.21.0网段的静态路由

C:\Users\Harvey Mei>route add 192.168.21.0 mask 255.255.255.0 10.8.0.25
 操作完成!

成功添加静态路由后ping目的主机的IP地址

route-static-03

 

Sat Jan 18 14:38:51 2013 C:\WINDOWS\system32\route.exe ADD 192.168.11.0 MASK 255.255.255.0 10.8.0.25
操作完成!
Sat Jan 18 14:38:52 2013 C:\WINDOWS\system32\route.exe ADD 10.8.0.1 MASK 255.255.255.255 10.8.0.25
操作完成!
Sat Jan 18 14:38:52 2013 Initialization Sequence Completed