分类目录归档:环境搭建

配置apache虚拟主机的下载—-手记

apache已经配置了两个虚拟主机,现在要求使用ip来访问呢,把根目录下的文件列表出来

apache虚拟主机配置完毕后,当通过ip访问时,因为不能匹配任何一个基于域名的虚拟主机,apache会把第一个虚拟主机会提供给访问者,所以通过ip访问只用配置第一个虚拟主机就可以了。

当访问apache的DocumentRoot目录外面的文件时,需要Alias关键字,例如“Alias / /home/zhaozheng/software/”
同时定义web根的权限,使用Directory关键字来定义,如果需要目录浏览,则在Options关键字中需要使用indexes属性
访问顺序是allow,deny,最后是Allow from all
如下:
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /
    Alias / /home/zhaozheng/software/
    ServerName software.kejet.com
    ServerAlias www.dummy-host.example.com
<Directory />
            Options indexes FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
</Directory>

php5+apache2.0官方安装说明

这是php源码中自带的INSTALL文件,里面的说明摘录,重要的标识为红色了

1.  gzip -d httpd-2_0_NN.tar.gz
2.  tar xvf httpd-2_0_NN.tar
3.  gunzip php-NN.tar.gz
4.  tar -xvf php-NN.tar
5.  cd httpd-2_0_NN
6.  ./configure –enable-so
7.  make
8.  make install

    Now you have Apache 2.0.NN available under /usr/local/apache2,
    configured with loadable module support and the standard MPM prefork.
    To test the installation use your normal procedure for starting
    the Apache server, e.g.:
    /usr/local/apache2/bin/apachectl start
    and stop the server to go on with the configuration for PHP:
    /usr/local/apache2/bin/apachectl stop.

9.  cd ../php-NN

10. Now, configure your PHP.  This is where you customize your PHP
    with various options, like which extensions will be enabled.  Do a
    ./configure –help for a list of available options.  In our example
    we’ll do a simple configure with Apache 2 and MySQL support.  Your
    path to apxs may differ, in fact, the binary may even be named apxs2 on
    your system.

      ./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql

11. make
12. make install

    If you decide to change your configure options after installation,
    you only need to repeat the last three steps. You only need to
    restart apache for the new module to take effect. A recompile of
    Apache is not needed.

    Note that unless told otherwise, ‘make install’ will also install PEAR,
    various PHP tools such as phpize, install the PHP CLI, and more.

13. Setup your php.ini

    cp php.ini-dist /usr/local/lib/php.ini

    You may edit your .ini file to set PHP options.  If you prefer having
    php.ini in another location, use –with-config-file-path=/some/path in
    step 10.

    If you instead choose php.ini-recommended, be certain to read the list
    of changes within, as they affect how PHP behaves.

14. Edit your httpd.conf to load the PHP module.  The path on the right hand
    side of the LoadModule statement must point to the path of the PHP
    module on your system.  The make install from above may have already
    added this for you, but be sure to check.

    For PHP 4:

      LoadModule php4_module modules/libphp4.so

    For PHP 5:

      LoadModule php5_module modules/libphp5.so

15. Tell Apache to parse certain extensions as PHP.  For example,
    let’s have Apache parse the .php extension as PHP.  You could
    have any extension(s) parse as PHP by simply adding more, with
    each separated by a space.  We’ll add .phtml to demonstrate.

      AddType application/x-httpd-php .php .phtml

    It’s also common to setup the .phps extension to show highlighted PHP
    source, this can be done with:

      AddType application/x-httpd-php-source .phps

16. Use your normal procedure for starting the Apache server, e.g.:

      /usr/local/apache2/bin/apachectl start

   Following the steps above you will have a running Apache 2.0 with
   support for PHP as SAPI module. Of course there are many more
   configuration options available for both, Apache and PHP. For more
   information use ./configure –help in the corresponding source tree. In
   case you wish to build a multithreaded version of Apache 2.0 you must
   overwrite the standard MPM-Module prefork either with worker or
   perchild. To do so append to your configure line in step 6 above either
   the option –with-mpm=worker or –with-mpm=perchild. Take care about
   the consequences and understand what you are doing. For more
   information read the Apache documentation about the MPM-Modules.

     Note: If you want to use content negotiation, read the Apache
     MultiViews FAQ.

     Note: To build a multithreaded version of Apache your system must
     support threads. This also implies to build PHP with experimental
     Zend Thread Safety (ZTS). Therefore not all extensions might be
     available. The recommended setup is to build Apache with the
     standard prefork MPM-Module.
     __________________________________________________________________

rsync,windows下的gid和uid是什么

cwrsync中的rsyncd.conf需要uid和gid

没有会出错:
C:\Program Files\cwRsync\bin>rsync -r 192.168.60.132::test /cygdrive/c/test
@ERROR: invalid gid nobody
rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]

后来才知道,windows下,uid=0,gid=0即可,折腾好几个小时,真不值。

附:cwrsync的配置文件
rsyncd.conf

use chroot = false
strict modes = false
hosts allow = *
log file = rsyncd.log
uid = 0
gid = 0
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[test]
path = /cygdrive/c/work
read only = false
write only = false
transfer logging = yes

客户端:
rsync -r 192.168.60.132::test /cygdrive/c/test

服务器端安装有问题,无法吧cwrsync-server安装为服务,原因未知,手动起rsync的服务器端
e:\Program Files\ICW\Bin\rsync –config=”/cygdrive/e/program files/icw/rsyncd.conf” –daemon –no-detach

windows2003集群中的“群集操作模式”的单播和多播的问题说明

    Windows server 2003中提供了网络负载均衡(NLB)功能。NLB的操作模式有单播和多播两种,它们之间有什么区别呢?
    首先,给大家介绍一下NLB的工作原理:当客户向NLB群集(NLB的虚拟IP地址)发起请求时,其实客户的请求数据包是发送到所有的NLB节点,然后运行在NLB节点上的NLB服务根据同样的NLB算法来确定是否应该由自己进行处理,如果不是则丢弃客户的请求数据包,如果是则进行处理。 如何将请求数据包发送到所有的NLB节点是NLB运行的关键之处,单播和多播这两种操作模式就是用于实现这一需求。NLB不支持单个NLB群集中的单播/多播的混合环境;在每一个NLB群集中,该群集中的所有节点都必须配置为多播或单播,否则,此NLB群集将无法正常工作。 单播和多播的运行方式和不同之处分别为: 单播 在单播模式下,NLB重新对每个NLB节点中启用NLB的网络适配器分配MAC地址(此MAC地址称为群集MAC地址),并且所有的NLB节点均使用相同的MAC地址(均使用群集MAC地址),同时NLB修改所有发送的数据包中的源MAC地址,从而使交换机不能将此群集MAC地址绑定在某个端口上。 工作在单播模式下的NLB可以在所有网络环境下正常运行,但是由于它的工作特性,具有以下两个限制: 由于NLB所使用的群集MAC地址没有绑定在某个具体的交换机端口上,所以所有的NLB通讯均通过在交换机的所有端口上广播进行,而不管此端口是否连接了NLB节点,这造成了额外的网络流量负担; 由于所有的NLB节点具有相同的MAC地址,NLB节点之间不能通过自己原有的专用IP地址进行通讯。
   多播 在多播模式下,NLB不会修改NLB节点启用NLB的网络适配器的MAC地址,而是为它再分配一个二层多播MAC地址专用于NLB的通讯(此MAC地址称为群集MAC地址),这样NLB节点之间可以通过自己原有的专用IP地址进行通讯。但是在多播模式中,NLB节点发送的针对群集IP地址MAC地址ARP请求的ARP回复会将群集IP地址映射到多播MAC地址,而许多路由器或者交换机(包括CISCO的产品)会拒绝这一行为。当出现这种情况时,你必须在路由器和交换机上手动添加静态映射,将群集IP地址映射到群集的多播MAC地址。
    Windows Server 2003提供了一个新的特性,称为IGMP 多播,它可以通过使用IGMP协议支持来使交换机只将NLB通讯发送到连接NLB节点的端口,而不是所有交换机端口。但是此特性必须要求交换机支持IGMP侦听,并且要求群集工作在多播模式下。

nagios安装,网上太多了,这个是自己安装后的手记。

nagios安装

下载:wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz
安装:
tar -zxvf nagios-3.2.0.tar.gz
cd nagios-3.2.0
./configure –prefix=/usr/local/nagios –with-command-group=nagcmd
make all
make all完毕后有如下提示:
“If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type ‘make’
without any arguments for a list of all possible options):

  make install
     – This installs the main program, CGIs, and HTML files

  make install-init
     – This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     – This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     – This installs *SAMPLE* config files in /usr/local/nagios/etc
       You’ll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     – This installs the Apache config file for the Nagios
       web interface”
依次运行如下命令:
make install
make install-init
make install-commandmode
make install-config
make install-webconf
给nginx添加认证:
修改nginx的配置文件如下:
    location /nagios/ {
    alias /usr/local/nagios/share/;
    index index.html index.htm index.php;
    auth_basic “nagios”;
    auth_basic_user_file /usr/local/nagios/etc/htpasswd admin
    }
生成htpasswd文件:
/usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd admin
其中htpasswd是apache提供的工具
配置nagios
nagios web界面提示
It appears as though you do not have permission to view information for any of the services you requested…
打开cgi.cfg配置文件,里面有个参数:
use_authentication=1
为了保障系统的安全性,nagios设置了这个参数,默认为1,改为0即可

 

配置:
下载插件:
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
tar -zxvf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
./configure –prefix=/usr/local/nagios
make
make install
配置附件:
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
tar -zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure –prefix=/usr/local/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
返回:[root@localhost nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H localhost
      NRPE v2.12
完成。
配置perl,cgi,nginx

nginx的perl的fcgi环境搭建。


首先:有三种方式(三个不同的脚本)搭建cgi环境,第二种,在运行时,nginx的error里会报错。
FastCGI sent in stderr: “Bad file descriptor at /EBS/fcgi.pl line 125”,第二种脚本的好处是可以起多个进程(process)
 方法一
 测试页
 
 

记得一定要给nginx发送头信息 不然会报504错误的。

#!/usr/bin/perl -w
print “Content-type: text/plain\r\n\r\n”;#发送头信息
print “test”;

1、安装FCGI模块:
到http://search.cpan.org/网站上下载FCGI模块:

wget http://search.cpan.org/CPAN/authors/id/S/SK/SKIMO/FCGI-0.67.tar.gz
 
tar -zxvf FCGI-0.67.tar.gz. 
cd FCGI-0.67 
perl Makefile.PL
make 
make install

2、安装 IO 和 IO::ALL模块
下载:
wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/IO-1.25.tar.gz
http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.39.tar.gz
安装:
tar -xvzf IO-1.25.tar.gz
cd IO-1.25
perl Makefile.PL
make 
make install
 
tar -xvzf IO-All-0.39.tar.gz
cd IO-ALL-0.39
perl Makefile.PL
make
make install
  
3、如果需要,安装perl-Getopt和 perl-Socket
(转注:以上三项,使用cpan安装会跟简单一些,cpan怎么安装,请看其它日志) 
  
4、perl cgi脚本
或从下面的地址下载perl-fcgi脚本
http://www.nginx.eu/nginx-fcgi/nginx-fcgi.txt
(转注:拿到这个脚本后,可能需要修改一些脚本的路径,在我的操作过程中,我更改了一下sock那个文件的名字,这个文件我是放在/usr/local/nginx/perl-fcgi.pl,我没有取nginx-fcgi.pl这个名字)

5、启动cgi脚本 (nobody为nginx的运行用户)
vi start_perl_cgi.sh
  

#!/bin/bash

#set -x

dir=/usr/local/nginx

 

stop ()

{

#pkill  -f  $dir/perl-fcgi.pl

kill $(cat $dir/logs/perl-fcgi.pid)

rm $dir/logs/perl-fcgi.pid 2>/dev/null

rm $dir/logs/perl-fcgi.sock 2>/dev/null

echo “stop perl-fcgi done”

}

 

 

start ()

{

rm $dir/now_start_perl_fcgi.sh 2>/dev/null

 

chown nobody.root $dir/logs

echo “$dir/perl-fcgi.pl -l $dir/logs/perl-fcgi.log -pid $dir/logs/perl-fcgi.pid -S $dir/logs/perl-fcgi.sock” >>$dir/now_start_perl_f

cgi.sh

 

chown nobody.nobody $dir/now_start_perl_fcgi.sh

chmod u+x $dir/now_start_perl_fcgi.sh

 

sudo -u nobody $dir/now_start_perl_fcgi.sh

echo “start perl-fcgi done”

}

 

case $1 in

stop)

stop

;;

start)

start

;;

restart)

stop

start

;;

esac 

启动
./start_perl_cgi.sh start

6为Nginx添加FCGI支持(以安装nagios为例)
vi perl_fcgi.conf 

gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
fastcgi_pass unix:/usr/local/nginx/logs/nginx-fcgi.sock;
fastcgi_index index.cgi;

fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name;

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name

以上为perl_fcgi.conf文件内容(转注)

location ~* .*\.cgi$
                {
                      rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
                        include perl_fcgi.conf;
                }

以上为nginx.conf配置文件中的内容(转注)
将请求cgi的url由/nagios/cgi-bin/*.cgi 重写为/*.cgi,这样,即下面的fastcgi_param中的$fastcgi_script_name,这样,可以正确的拼出cgi文件的路径。

重启nginx后,应该就可以访问perl的cgi文件了 

配置nginx下的perl的fcgi的原因是我需要在我的机器上安装nagios。
以上为摘抄加自己的一些补充,原作地址为:http://blog.chinaunix.net/u/32831/showart_2011754.html