工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆
浏览模式: 标准 | 列表分类:linux

selinux介绍

nginx的一些记录

 

一直是用apache,也早早就听说过nginx的性能是如何如何的优越,却也一直没有亲自测试过.
最近有一台机的负载好大,CPU的资源,基本上是用完.

后用了nginx来试,而且,也把原来的PHP程序换成了CGI(因为这台机的功能,代码都很简单),这个nginx的编译,也是优化了CGI的编译的.速度确实快了好多.
主要原因,一是用nginx,且用了专门优化了CGI的,代码也换了,而且,对访问方式也作了一些调整


记录一些数据:
 所有连接 开始连接 正在连接 结束连接
apache 15万   2-4K   (2-5K) (120K)
nginx 10万   1K   60K    70K

有些值相差是比较大,我想这和我的设置时间有关
apache的连接时间都很短,而nginx的是apache的10倍差不多

不过从测试的结果来看,nginx的响应上,确实比apache快得多.
不过,流量或连接大到一定大的时候.nginx会直接丢掉,而apache等待的时间会长一点
所以,用nginx时,会丢掉一连接,从一些数据统计中,可以看到

硬件配置,双至强3.0,4G内存

 

configure: error: libjpeg.(a|so) not found

./configure --prefix=/www/servers/php --with-apxs2=/www/servers/httpd20/bin/apxs --with-mcrypt=/usr --with-gd=/usr --enable-gd-native-ttf --with-jpeg-dir=/usr --with-png-dir=/usr --with-ttf --with-zlib --with-freetype-dir=/usr --with-mysql=/www/servers/mysql --with-iconv --enable-mbstring --enable-ftp

configure: error: libjpeg.(a|so) not found
ln -sf libjpeg.so.62.0.0 libjpeg.so


configure: error: libpng.(a|so) not found.
yum install libpng-devel

centos 裁剪,定制

mkdir -p /storage/kickstart_build/isolinux/CentOS
mkdir -p /storage/kickstart_build/isolinux/ks
mkdir -p /storage/kickstart_build/isolinux/image
mkdir -p /storage/kickstart_build/isolinux/repodata
mkdir /storage/kickstart_build/all_rpms


cp -rp /media/isolinux/* /storage/kickstart_build/isolinux
cp /media/.discinfo /storage/kickstart_build/isolinux
cp -rp /media/repodata/comps.xml /storage/kickstart_build
cp -rp /media/CentOS/* /storage/kickstart_build/all_rpms


cd /storage/kickstart_build
chmod +x pare.pl
cd /storage/kickstart_build/isolinux/CentOS
/storage/kickstart_build/pare.pl /storage/kickstart_build/all_rpms i386


cd /storage/kickstart_build/isolinux/CentOS
mkdir /tmp/testdb
rpm --initdb --dbpath /tmp/testdb
rpm --test --dbpath /tmp/testdb -Uvh *.rpm

cd /storage/kickstart_build/isolinux
declare -x discinfo=`head -1 .discinfo`
createrepo -u "media://$discinfo" -g /storage/kickstart_build/comps.xml .

cd /storage/kickstart_build
mkisofs -o MYOS.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/
 

1 安装一个简洁的系统
2 安装 anaconda,anaconda-runtime
3 mount,mkdir /centos,cp光盘内所有到/centos
4 剪裁软件包,可根据install.log,放到 /centos/centos,也可直接替换CentOS
5 cd /centos,createrepo -g repodata/coms.xml .  执行两次
6 cp anaconda-ks.cfg ks.cfg
 vi isolinux.cfg
default linux > default linux ks=cdrom:/ks.cfg
7 make iso
mkisofs -o MYOS.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T centos/


 

运行perl程序出现: : bad interpreter: No such file or directory

运行perl程序时出现: bad interpreter: No such file or directory 这样的错误提示.

原因:这是在windows下通过写字板或其他编辑工具编写的perl程序,windows环境下每行的结束符是CRLF(Carriage-Return, Line-Feed). 在linux下结束符却是LF,所以每行多了一个CR串.
处理:通过以下脚本对每行结束符进行替换

#!/usr/bin/perl

die "Usage: $0 < files >\n" unless @ARGV;

for $file (@ARGV)
{
    open IN, $file or die "$0: Cannot open $file for input!\n";

    my @lines = <IN>;

    close IN;
    open OUT, "> $file" or die "$0: Cannot open $file for output!\n";

    s/\r$// for @lines;
    print OUT for @lines;
}

Privilege separation user sshd does not exist

启动sshd提示:

Privilege separation user sshd does not exist

google了一下,找到了解决方法。

方法一(推荐):
修改/etc/passwd文件,在其中加入
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
或者
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
我加入的是:
sshd:x:109:65534::/var/run/sshd:/usr/sbin/nologin
参考
http://www.unixguide.net/comments/sun/ssh_installation.shtml/37.shtml
http://www.gipsky.com/modules/newbb/viewtopic.php?topic_id=966

方法二(不推荐):
修改/etc/ssh/sshd_config文件
将其中
UsePrivilegeSeparation yes
修改为
UsePrivilegeSeparation no
虽然能解决问题,但是降低了ssh的安全级别。

解开RPM包

rpm2cpio a.rpm | cpio --extract --make-directories

 

2009.07.03

rpm -ivh kchmviewer-3.1-1.el5.5.x86_64.rpm --prefix=/home/chc/rpms/tmp

因为rpm实际上使用cpio格式打包的,因此可以先转成cpio然后解压,如下所示:
rpm2cpio kchmviewer-3.1-1.el5.5.x86_64.rpm | cpio -div

rhel5

Installing PEAR environment:      /www/servers/php/lib/php/
/home/r00t/php-5.2.6/sapi/cli/php: error while loading shared libraries: /usr/local/gd/lib/libgd.so.2: cannot rest
ore segment prot after reloc: Permission denied
make[1]: *** [install-pear-installer] Error 127
make: *** [install-pear] Error 2


Nov 14 16:54:45 localhost setroubleshoot:      SELinux is preventing /home/r00t/php-5.2.6/conftest from loading /u
sr/local/gd/lib/libgd.so.2.0.0 which requires text relocation.      For complete SELinux messages. run sealert -l7f26cea9-91e8-4b3a-93e0-6298e6c4e265


failed to connect to server


chcon -t textrel_shlib_t /usr/local/gd/lib/libgd.so.2

 

###
checking for MySQL UNIX socket location... /tmp/mysql.sock
checking for mysql_close in -lmysqlclient_r... no
checking for mysql_error in -lmysqlclient_r... no
configure: error: mysql configure failed. Please check config.log for more information.

没找到解决办法,把PHP换为4的就可以了