分类目录归档:环境搭建

在64位的环境下编译32位的应用程序

在64位的环境下编译32位的应用程序
背景知识: http://www.divms.uiowa.edu/local/linux_help/rh_ws3_amd64_faq.html

我们的 64bit Debain 需要安装以下软件包

apt-get install ia32-libs libc6-dev-i386 linux32

1) 最关键的东西是需要告知gcc编译器编译的平台是 i386,CFLAGS 必须添加 -m32 参数. [关于gcc编译参数的官方文档]

2) 用 linux32 命令在configure改一下CHOST,设置一下编译环境

linux32 命令使用前后区别

staff-1:~/src/lame-3.96.1# ./configure
checking build system type… x86_64-unknown-linux-gnu
checking host system type… x86_64-unknown-linux-gnu

staff-1:~/src/lame-3.96.1# linux32 ./configure
checking build system type… i686-pc-linux-gnu
checking host system type… i686-pc-linux-gnu

3) 如果编译的程序是32位的,所需要的动态链接库也需重新编译,例如mplayer需要用到 mp3lame,jpeg-6b,libpng等,均需要重新编译.

4) 如何知道应用程序是64位还是32位的?可使用file命令查看.

staff-1:~# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared libs), for GNU/Linux 2.6.0, stripped

staff-1:~# file /usr/bin/mplayer
/usr/bin/mplayer: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared libs), for GNU/Linux 2.6.0, stripped

5) 一些编译前准备的实例,mplayer

linux32 ./configure –prefix=/usr –cc=”gcc -m32″ –target=”i386-linux”
make
make install

注意:-cc,–target 参数不一定每个 configure 程序都提供,需灵活变通,其本质是设置了一些环境变量,可用手动配置.

export CFLAGS=”-m32 -04 -march=i386 -mtune=i386″

6) 注意和原来的共享库冲突,尽量不要编译到 /usr 目录下,否则影响其它64位的程序正常运作就得不尝失了.

7) 能不能100%编译成功? 不一定,如果 makefile 使用了64位的linker例如ld等,去link你编译出来32位的so的话,那就会报告不兼容. Good luck!!

相关参考:
•How to build 32-bit Wine on a 64-bit (x86-64) system

以下是其它人的讨论

1) 最关键的东西是需要告知gcc编译器编译的平台是 i386,CFLAGS 必须添加 -m32 参数. [关于gcc编译参数的官方文档]

2) 用 linux32 命令在configure改一下CHOST,设置一下编译环境

linux32 命令使用前后区别

staff-1:~/src/lame-3.96.1# ./configure
checking build system type… x86_64-unknown-linux-gnu
checking host system type… x86_64-unknown-linux-gnu

staff-1:~/src/lame-3.96.1# linux32 ./configure
checking build system type… i686-pc-linux-gnu
checking host system type… i686-pc-linux-gnu

这段没看懂,
第2点怎么设置的能说具体点吗??谢谢。

答复:
linux32 是一个设置环境变量 CHOST 的命令.可用 export CHOST=”i686-pc-linux-gnu” 代替

我自己尝试编译libmm在64位服务器上通过,参数如下
./configure CC=”gcc -m32″

ntpd

  默认情况下,我们配置的NTP服务器不会去时间源那里同步时间,所以必须修改/etc/ntp/step-tickers文件,加入我们的时间源,这样每次通过/etc/init.d/ntpd 来启动服务的时候就会自动更新时间了

extmail的后期维护的一点问题

在安装了Extmail以后,进入Extman对邮件系统进行管理的时候,访问http://url/(extman)的时候却提示:
Can’t open /tmp/extman//sid_26da75f9aec35f2cbc6b4fa425ab525e, No such file or directory
此时只需要将/temp/extman的权限设置为777即可。
如果没有该目录,可手功创建该目录mkdir /tmp/extman,并将其权限设置为777
出现这个问题的原因好像是linux会定期清除/tmp/目录,导致extman丢失,
通过修改,/var/www/extsuite/extman/webmail.cf文件里面的配置

# sys_sess_dir, the session dir
SYS_SESS_DIR = /tmp/extman/
将SYS_SESS_DIR指定到了/data/extman下面。

  Extmail进后台不能正常显示系统的信息的解决办法

进入后台不显示目录信息提示”No such file or directory”
进入extman/daemon/cmdserver –daemon  运行启来就能显示了

配置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