httpd.conf中增加:
Listen 81
Listen 82
Listen 83
并同时开启:
Include conf/extra/httpd-vhosts.conf

httpd-vhosts.conf配置三个站点,分别对应81 82 83 三个端口,配置如下:

#-------------------- default root open with http://ip -------------------------
<VirtualHost *:81>
    ServerAdmin root@localhost
    DocumentRoot "/home/wwwroot/htdocs"
    ServerName 192.168.0.2
#    ServerAlias locahost 127.0.0.1
#    DirectoryIndex index.html index.html.var index.php
#   ErrorLog "logs/error.log"
#   CustomLog "logs/access.log" common
</VirtualHost>

#------------------------- virtual web www.aaa.com -----------------------------
<Directory /home/wwwroot/htdocs>
    AllowOverride ALL
    Allow from all
</Directory>

<VirtualHost *:82>
    ServerAdmin admin@gsywx.com
    DocumentRoot /home/wwwroot/htdocs/www.aaa.com
    ServerName www.aaa.com
#    ServerAlias *.aaa.com
#    ErrorLog "logs/www.aaa.com-error.log"
#    CustomLog "logs/www.aaa.com-access.log" common
</VirtualHost>

#------------------------- virtual web www.bbb.com -----------------------------
<Directory /home/wwwroot/htdocs>
    AllowOverride ALL
    Allow from all
</Directory>

<VirtualHost *:83>
    ServerAdmin admin@gsywx.com
    DocumentRoot /home/wwwroot/htdocs/www.bbb.com
    ServerName www.bbb.com
#    ServerAlias *.bbb.com
#    ErrorLog "logs/www.bbb.com-error.log"
#    CustomLog "logs/www.bbb.com-access.log" common
</VirtualHost>



nginx中的vhost.conf中配置对应的三个虚拟主机,配置如下:

  upstream  phppool1 {
  server 127.0.0.1:81;
   }

  upstream  phppool2 {
  server 127.0.0.1:82;
   }

  upstream  phppool3 {
  server 127.0.0.1:83;
   }

#------------------------------- default web dir -------------------------------
server
             {
                        listen 80;
                        server_name 192.168.0.2;
                        root /home/wwwroot/htdocs;
                        location / {
                              proxy_pass http://phppool1;
                              proxy_set_header Host $host;
}
}

#-------------------------------- www.aaa.com --------------------------------
server
             {
                        listen 80;
                        server_name www.aaa.com;
                        root /home/wwwroot/htdocs/www.aaa.com;
                        location / {
                              proxy_pass http://phppool2;
                              proxy_set_header Host $host;
}
}

#-------------------------------- www.bbb.com --------------------------------
server
             {
                        listen 80;
                        server_name www.bbb.com;
                        root /home/wwwroot/htdocs/www.bbb.com;
                        location / {
                              proxy_pass http://phppool3;
                              proxy_set_header Host $host;
}
}
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com


在用centos建立网站环境时,出现了这样的问题:
网站上的图片无法在IE中正确打开,发现都变形了,或色彩变得模糊或一块块的,使用图片另存为,发现图片只有上面一部份,下面部份丢失,或索性整个都不完整。检查网站上的图片完全正确,是用ssh二进制上传的。
重新安装nginx后问题依旧,于是,再安装apache,测试还一样,再用yum安装centos自带的apache,还是如此,后来经朋友查找发现说apache下的sendfile会有某些系统或CPU情况下存在bug,具体不深究它,解决问题即可。
解决方法:
在apache情况下:在httpd.conf中增加语句:EnableSendfile Off
在nginx情况下:修改nginx.conf中的 sendfile on;为 sendfile off;

为了更深地了解此问题,以下内容为搜索来的:

apache 配置中的两个指令EnableMMAP与EnableSendfile详解
访问大文件时>100k,只能送出前30k左右的内容,
在 ie中如何刷新都不能显示完整, 在 firefox中刷新几次后可显示完整,用 wget时,可看出明显的续传的过程.

需要关闭以下两项, 具体还是不知为何,但行之有效:

EnableMMAP 指令
说明 在递送中使用内存映射(memory-mapping)来读取文件
语法 EnableMMAP On|Off
默认值 EnableMMAP On
作用域 server config, virtual host, directory, .htaccess
覆盖项 FileInfo
状态 核心(C)
模块 core

此指令指示httpd在递送中如果需要读取一个文件的内容,它是否可以使用内存映射。当处理一个需要访问文件中的数据的请求时,比如说当递送一个使用mod_include进行服务器端分析的文件时,如果操作系统支持,Apache将默认使用内存映射。

这种内存映射有时会带来性能的提高,但在某些情况下,您可能会需要禁用内存映射以避免一些操作系统的问题:

在一些多处理器的系统上,内存映射会减低一些httpd的性能。
在挂载了NFS的DocumentRoot上,若已经将一个文件进行了内存映射,则删除或截断这个文件会造成httpd因为分段故障而崩溃。
在可能遇到这些问题的服务器配置过程中,您应当使用下面的命令来禁用内存映射:

EnableMMAP Off

对于挂载了NFS的文件夹,可以单独指定禁用内存映射:

EnableMMAP Off

EnableSendfile 指令
说明 使用操作系统内核的sendfile支持来将文件发送到客户端
语法 EnableSendfile On|Off
默认值 EnableSendfile On
作用域 server config, virtual host, directory, .htaccess
覆盖项 FileInfo
状态 核心(C)
模块 core
兼容性 仅在 Apache 2.0.44 及以后的版本中可用

这个指令控制httpd是否可以使用操作系统内核的sendfile支持来将文件发送到客户端。默认情况下,当处理一个请求并不需要访问文件内部的数据时(比如发送一个静态的文件内容),如果操作系统支持,Apache将使用sendfile将文件内容直接发送到客户端而并不读取文件。译者注:Linux2.4/2.6内核都支持。

这个sendfile机制避免了分开的读和写操作以及缓冲区分配,但是在一些平台或者一些文件系统上,最好禁止这个特性来避免一些问题:

一些平台可能会有编译系统检测不到的有缺陷的sendfile支持,特别是将在其他平台上使用交叉编译得到的二进制文件运行于当前对sendfile支持有缺陷的平台时。
在Linux上启用IPv6时,使用sendfile将会触发某些网卡上的TCP校验和卸载bug。
当Linux运行在Itanium处理器上的时候,sendfile可能无法处理大于2GB的文件。
对于一个通过网络挂载了NFS文件系统的DocumentRoot (比如:NFS或SMB),内核可能无法可靠的通过自己的缓冲区服务于网络文件。
如果出现以上情况,你应当禁用sendfile :

EnableSendfile Off

针对NFS或SMB,这个指令可以被针对目录的设置覆盖:

EnableSendfile Off


Tags:

linux系统时间的设置

[不指定 2010/11/13 20:44 | by xiaoyuwxz ]
linux系统时间的设置

一、设置时区
命令 tzselect
选择 5) Asia
选择 9) China
选择1) east China - Beijing, Guangdong, Shanghai, etc.
选择1) Yes

以上如果不通过tzselect,也可以直接修改
/etc/sysconfig/clock
内容为
ZONE="Asia/Shanghai"
UTC=true
ARC=false
保存即可

二、设置时间自动更新
安装ntpdate,ntpdate使用UDP协议
yum install netdate
加入计划任务
crontab -e
00 */3 * * * ntpdate 210.72.145.44
每3小时更新一次,210.72.145.44 为中国国家时间检验中心IP

如果系统上层UDP协议被封,那么可以使用rdate命令来更新时间,格式如下:
00 */3 * * * rdate -s time-b.nist.gov

Centos下安装TWiki教程

[不指定 2010/11/09 19:17 | by xiaoyuwxz ]
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com

默认约定:服务器环境centos5.5 32位,为了省时间环境使用yum安装

1、首先配置服务器环境,使用yum -y install httpd rcs
2、打开/etc/httpd/conf/httpd.con
    查找 AddDefaultCharset UTF-8  改成AddDefaultCharset GB2312
    查找:AddHandler cgi-script .cgi 前面的#去掉
   Options Indexes FollowSymLinks 修改为Options ExecCGI
    AllowOverride None修改为AllowOverride All
    重启httpd,service httpd restart
3、下载Twiki
   下载地址为:http://twiki.org/ 或http://down.zzbaike.com/download/TWiki-476.html
4、上传解压出来的程序,给网站目录当前用户的可执行权限。
   /bin/LocalLib.cfg.txt 改名为/bin/LocalLib.cfg,修改$twikiLibPath = "/absolute/path/to/your/lib";为$twikiLibPath = "/var/www/html/lib";
    修改/bin/.htaccess.txt 为/bin/.htaccess
    修改root-htaccess.txt为.htaccess
    修改/bin/configure为/bin/configure.cgi
5、运行配置文件 http://192.168.0.2/bin/configure.cgi进行安装
    如果要支持中文,配置的时候做如下设置:在configure中的Localisation设置需要特别注意,需要选中 {UserInterfaceInternationalisation}、{Languages}{'zh-cn'}{Enabled}、{UseLocale}这几项设置的复选框,并设置{Site}{Locale}为zh_CN.UTF-8,设置{Site} {CharSet}为UTF-8,{Site}{Lang}和{Site}{FullLang}为zh-CN,这样保存设置之后,打开Wiki就会是中文,并且能够正常的使用和编辑中文了。
6、设置好之后,通过bin目录下的view打开Wiki,例如http://192.168.0.2/bin/view
Tags: ,
分页: 2/20 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]