Skip to content


用php控制word的打印边距

将生成的word文件另存为htm,用文本比较工具(如svn的diff)差看差异,就可以找着关键点了。

<!– @page Section1  {size:595.3pt 841.9pt;  margin:33.0pt 33.15pt 33.0pt 33.15pt; } div.Section1  {page:Section1;} ……

…….
…….

Posted in Others, 技术.

Tagged with , , , .


nginx+php(FCGI)+xcache+mysql on as4

一、系统环境 linux为redhat as4 全新安装,不带默认万维网服务,带开发工具和系统工具,加上mrtg、net-snmp-utils、sysstat

二、下载安装文件

mkdir src cd src vi lemp_down_list

输入以下内容

http://www.zlib.net/zlib-1.2.3.tar.gz http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.31.tar.gz ftp://xmlsoft.org/libxml2/libxml2-2.6.32.tar.gz ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz http://fontconfig.org/release/fontconfig-2.6.0.tar.gz http://www.libgd.org/releases/gd-2.0.35.tar.bz2 http://ftp.gnu.org/pub/gnu/gettext/gettext-0.17.tar.gz http://mirror.optus.net/sourceforge/m/mc/mcrypt/libmcrypt-2.5.8.tar.gz http://mirror.x10.com/mirror/mysql/Downloads/MySQL-5.1/mysql-5.1.26-rc.tar.gz http://www.monkey.org/~provos/libevent-1.4.5-stable.tar.gz http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz http://www.php.net/get/php-5.2.6.tar.gz/from/this/mirror http://php-fpm.anight.org/downloads/head/php-5.2.6-fpm-0.5.8.diff.gz http://pecl.php.net/get/memcache-2.2.3.tgz http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz http://sysoev.ru/nginx/nginx-0.6.32.tar.gz

开始下载

wget -i lemp_down_list

三、安装基本包

A1、安装zlib

tar xzvf zlib-1.2.3.tar.gz cd zlib-1.2.3 ./configure –prefix=/usr/local/zlib make make install

A2、安装freetype

tar xzvf freetype-2.3.5.tar.gz cd freetype-2.3.5 ./configure –prefix=/usr/local/freetype make make install

A3、安装libpng

tar xzvf libpng-1.2.29.tar.gz tar xzvf libpng-1.2.31.tar.gz cd libpng-1.2.29 cd libpng-1.3.31 cp scripts/makefile.std makefile make test make install

A4、# tar -zxf libxml2-2.6.32.tar.gz

# cd libxml2-2.6.32 # ./configure –prefix=/usr/local/libxml # make; make install echo ‘/usr/local/libxml/lib’ >> /etc/ld.so.conf ldconfig -v

A5、安装 libxslt

# tar -zxf libxslt-1.1.24.tar.gz # cd libxslt-1.1.24 # ./configure –prefix=/usr/local/libxslt –with-libxml-prefix=/usr/local/libxml # make; make install

A6、安装jpeg

# mkdir -p /usr/local/jpeg6/{,bin,lib,include,man/man1,man1} # tar xzvf jpegsrc.v6b.tar.gz # cd jpeg-6b # ./configure –prefix=/usr/local/jpeg6 –enable-shared –enable-static # make

如果安装提示没有libtool,先安装libtool 然后进入jpeg-6b的源码目录,然后执行以下步骤,

# make install

在64位系统安装时使用以下命令

# CFLAGS=”-O3 -fPIC” ./configure –prefix=/usr/local/jpeg6 –enable-shared –enable-static # make # make install # make install-lib

如果安装PHP5,必需安装libxml2

A7、安装iconv

tar zxvf libiconv-1.12.tar.gc cd libiconv-1.12 ./configure –prefix=/usr/local/libiconv make make install ln -s /usr/local/libiconv/lib/* /usr/lib ldconfig -v

A8、安装fontconfig

tar xzvf fontconfig-2.5.0.tar.gz tar xzvf fontconfig-2.6.0.tar.gz cd fontconfig-2.5.0 cd fontconfig-2.6.0 ./configure –prefix=/usr/local/fontconfig –disable-docs –sysconfdir=/etc –mandir=/usr/share/man –with-freetype-config=/usr/local/freetype/bin/freetype-config

错误: /usr/local/fontconfig/bin/fc-cache: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory 解决:

ln -s /usr/local/lib/libionv.so.2 /usr/lib/libiconv.so.2

错误: checking for LIBXML2… configure: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. 解决:

wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz tar zxvf pkg-config-0.23.tar.gz cd pkg-config-0.23 ./configure make make install

错误: fcxml.c: In function FcConfigMessage': fcxml.c:484: error:va_start’ used in function with fixed args 解决:

export LIBXML2_CFLAGS=-I/usr/local/libxml/include/libxml2 export LIBXML2_LIBS=/usr/local/libxml/lib/libxml2.so

编译参数最后加 –enable-libxml2 再次config make make install

A9、安装GD

tar xzvf gd-2.0.35.tar.gz cd gd-2.0.35 ./configure –prefix=/usr/local/gd2 –with-jpeg=/usr/local/jpeg6/ –with-png –with-zlib –with-freetype=/usr/local/freetype/ –with-fontconfig=/usr/local/fontconfig make make install

错误: configure.ac:64: error: possibly undefined macro: AM_ICONV If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. 解决:

cd .. tar zxvf gettext-0.17.tar.gz cd gettext-0.17 ./configure –prefix=/usr/local/gettext –disable-java –disable-native-java make make install

/bin/sed: can’t read /lib/libattr.la: No such file or directory

ln -s /usr/lib/* /lib/

再安装gettext 再安装gd

X86 64位LINUX下安装GD的注意事项
错误提示: /usr/bin/ld: /usr/local/lib/libjpeg.a(jcapimin.o): relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC 进入Jpeg目录 CFLAGS=”-O3 -fPIC” ./configure make make install-lib 编译前需指定为64位编译模式,否则会出现以下错误: /usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32against `a local symbol’ can not be used when making a shared object;recompile with -fPIC /usr/local/lib/libz.a: could not read symbols: Bad value 解决办法 : 重新安装 zlib-1.2.3.tar.gz tar -zxvf zlib-1.2.3.tar.gz cd zlib-1.2.3 ./configure vi Makefile 找到 CFLAGS=-O3 -DUSE_MMAP 在后面加入-fPIC,即变成CFLAGS=-O3 -DUSE_MMAP -fPIC 接下面步骤 make make install nfig.so -L/usr/lib64 /usr/local/freetype/lib/libfreetype.so -lpng -lz -lm -Wl,–rpath -Wl,/usr/local/freetype/lib -Wl,-soname -Wl,libgd.so.2 -o .libs/libgd.so.2.0.0 /usr/bin/ld: /usr/local/lib/libpng.a(png.o): relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libpng.a: could not read symbols: Bad value collect2: ld returned 1 exit status 重新安装libpng;删除解压文件,重新解压 cp scripts/makefile.linux makefile vi Makefile 找到 CFLAGS=后加上-fPIC make test make install 再重新安接gd; vi Makefile 找到 CFLAGS=后加上-fPIC A10、安装 libmcrypt tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure –prefix=/usr/local/libmcrypt make make install 四、安装mysql 1.mysql安装 http://dev.mysql.com/doc/refman/5.1/en/index.html http://dev.mysql.com/doc/refman/5.1/en/installing-source.html /usr/sbin/groupadd website # 管理组 /usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql -d /dev/null -s /sbin/nologin tar zxvf mysql-5.1.26-rc.tar.gz cd mysql-5.1.26-rc/ CFLAGS=”-O3″ CXX=gcc CXXFLAGS=”-O3 -felide-constructors -fno-exceptions -fno-rtti” ./configure –prefix=/opt/mysql –localstatedir=/opt/mysql/var –sysconfdir=/opt/mysql –without-debug –with-unix-socket-path=/opt/mysql/mysql.sock –with-big-tables –with-charset=gbk –with-collation=gbk_chinese_ci –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –with-extra-charsets=gbk,gb2312,utf8 –with-pthread –enable-thread-safe-client –with-innodb #–with-innodb时,mysql的data存放于/opt/mysql/var 下,无些参数时为/opt/mysql/data下 默认为/var/lib/mysql (在/etc/my.cnf中) 错误: /usr/bin/ld: cannot find -lncurses collect2: ld returned 1 exit status 解决: # yum -y install ncurses-devel make make install #512M内存和web共用 cp support-files/my-medium.cnf /opt/mysql/my.cnf #2G内存和web共用 #cp support-files/my-large.cnf /opt/mysql/my.cnf #删除默认的my.cnf rm /etc/my.cnf /opt/mysql/bin/mysql_install_db –defaults-file=/opt/mysql/my.cnf –basedir=/opt/mysql –datadir=/opt/mysql/var –user=mysql –pid-file=/opt/mysql/var/mysql.pid –skip-locking –socket=/opt/mysql/mysql.sock chmod +w /opt/mysql chown -R mysql:mysql /opt/mysql cd .. chgrp website /opt/mysql/my.cnf chmod 0664 /opt/mysql/my.cnf 2.自动运行mysql http://dev.mysql.com/doc/refman/5.1/en/automatic-start.html cp support-files/mysql.server /opt/mysql/bin/ chmod 755 /opt/mysql/bin/mysql.server #自动启动 cp support-files/mysql.server /etc/init.d/mysql chmod 755 /etc/init.d/mysql chkconfig –add mysql #某些linux上 #chkconfig –level 345 mysql on #开启服务 /etc/init.d/mysql start #关闭服务 #/etc/init.d/mysql stop 3.手动开启/关闭服务 /bin/sh /opt/mysql/bin/mysqld_safe –user=mysql & /opt/mysql/bin/mysqladmin -uroot -p shutdown Enter password: 4.mysql修改密码 #123456为密码 /opt/mysql/bin/mysqladmin -uroot password 123456 #测试密码 /opt/mysql/bin/mysql -uroot -p Enter password: 5.编辑my.cnf vi /opt/mysql/my.cnf 关闭log_bin 将log-bin=mysql-bin注释掉,需要热备份或主从服务器的可以保留,开启后会占很多空间 开启innodb 将innodb开头的注释去掉,除了innodb_log_arch_dir参数,开启它将无法启动msyql 修改完成后重启mysql服务 五、安装memcached 官方网站 http://www.monkey.org/~provos/libevent/ http://www.danga.com/memcached/download.bml 1.下载 wget http://www.monkey.org/~provos/libevent-1.4.5-stable.tar.gz wget http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz 2.安装libevent # tar zxvf libevent-1.4.5-stable.tar.gz # cd libevent-1.4.5 # ./configure –prefix=/usr # make # make install 3.安装memcached tar zxvf memcached-1.2.5.tar.gz cd memcached-1.2.5 ./configure –prefix=/opt/memcached –with-libevent=/usr make make install 4.启动Memcache的服务器端 # /opt/memcached/bin/memcached -d -m 100 -u root -l 127.0.0.1-p 12000 -c 256 -P /tmp/memcached.pid /opt/memcached/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory ========================== error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory #cp /usr/lib/libevent* /usr/lib64/ -R ========================== echo /usr/local/libevent/lib >> /etc/ld.so.conf ldconfig -d选项是启动一个守护进程, -m是分配给Memcache使用的内存数量,单位是MB,我这里是100MB, -u是运行Memcache的用户,我这里是root, -l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.54.96, -p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口, -c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定, -P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid, 5.如果要结束Memcache进程,执行: # kill `cat /tmp/memcached.pid` 也可以启动多个守护进程,不过端口不能重复。 5.图形介面监控memcached http://www.ooso.net/index.php/archives/462 六。安装php 1.php 补丁安装 tar zxvf php-5.2.6.tar.gz gzip -cd php-5.2.6-fpm-0.5.8.diff.gz | patch -d php-5.2.6 -p1 2.php安装 cd php-5.2.6 ./configure –prefix=/opt/php –with-config-file-path=/opt/php/etc –with-mysql=/opt/mysql –with-mysqli=/opt/mysql/bin/mysql_config –with-iconv-dir=/usr/local/libiconv –with-freetype-dir=/usr/local/freetype/ –with-jpeg-dir=/usr/local/jpeg6/ –with-png-dir –with-zlib=/usr/local/zlib/ –with-libxml-dir=/usr/local/libxml/ –enable-xml –enable-zend-multibyte –disable-debug –disable-ipv6 –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt=/usr/local/libmcrypt/ –with-gd –enable-gd-native-ttf 错误: checking for xml2-config path… configure: error: xml2-config not found. 解决: 编译参数最后加上 –with-xml-config=/usr/local/libxml/bin/xml2-config 错误: configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/ 解决: yum install curl-devel sed -i ‘s#-lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt#& -liconv#’ Makefile make make install cp php.ini-dist /opt/php/etc/php.ini chgrp website /opt/php/etc/php.ini chmod 0664 /opt/php/etc/php.ini chgrp website /opt/php/etc/php-fpm.conf chmod 0664 /opt/php/etc/php-fpm.conf cd ../ 3.编译安装PHP5扩展模块 tar zxvf memcache-2.2.3.tgz cd memcache-2.2.3/ /opt/php/bin/phpize 错误: Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable is set correctly and then rerun this script. 解决: # wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz # tar -zvxf m4-1.4.9.tar.gz # cd m4-1.4.9/ # ./configure && make && make install # cd ../ # wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz # tar -zvxf autoconf-2.61.tar.gz # cd autoconf-2.61/ # ./configure # make # make install 记得要用2.61 的autoconf-2.62会有错误,郁闷死了 Zend Extension Api No: 220060519 configure.in:77: warning: AC_CACHE_VAL(lt_prog_compiler_static_works, …): suspicious cache-id, must contain _cv_ to be cached ../../lib/autoconf/general.m4:1973: AC_CACHE_VAL is expanded from… ../../lib/autoconf/general.m4:1993: AC_CACHE_CHECK is expanded from… ./configure –with-php-config=/opt/php/bin/php-config make make install cd ../ tar zxvf xcache-1.2.2.tar.gz cd xcache-1.2.2/ /opt/php/bin/phpize ./configure –with-php-config=/opt/php/bin/php-config –enable-xcache –enable-xcache-coverager –enable-inline-optimization –disable-debug make make install cd ../ 4.修改php.ini文件 A 查找/opt/php/etc/php.ini中的extension_dir = “./” 修改为extension_dir = “/opt/php/lib/php/extensions/no-debug-non-zts-20060613/” 并在此行后增加以下几行,然后保存: extension = “memcache.so” B php.ini中 cgi.fix_pathinfo=1; 这样php-cgi方能正常使用SCRIPT_FILENAME这个变量,默认就是1 C 在php.ini尾部增加 [xcache-common] zend_extension = /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so [xcache.admin] xcache.admin.user = “xcache” ; xcache.admin.pass = md5($yourpasswd) ;如何生成md5密码: echo -n “password”| md5sum xcache.admin.pass = “0563ff87afd961147cc3b89fec551a87” #password is c1gstudio [xcache] xcache.cacher = On xcache.shm_scheme = “mmap” xcache.size = 32M ; cpu number (cat /proc/cpuinfo |grep -c processor) xcache.count = 2 xcache.slots = 8k xcache.ttl = 0 xcache.gc_interval = 0 xcache.var_size = 2M ; cpu number (cat /proc/cpuinfo |grep -c processor) xcache.var_count = 2 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 xcache.readonly_protection = Off xcache.mmap_path = “/dev/zero” D 让session使用memcached session.save_handler = memcache session.save_path = “tcp://127.0.0.1:12000” 5.创建用户组 /usr/sbin/groupadd www -g 48 /usr/sbin/useradd -g website www -d /dev/null -s /sbin/nologin mkdir -p /opt/htdocs/www/nginx chmod -R 0775 /opt/htdocs/ chown -R www:website /opt/htdocs/ 6.创建php-fpm配置文件 (php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi): 在/opt/php/etc/目录中创建php-fpm.conf文件: rm -f /opt/php/etc/php-fpm.conf vi /opt/php/etc/php-fpm.conf All relative paths in this config are relative to php’s install prefix
Pid file /opt/php/logs/php-fpm.pid Error log file /opt/php/logs/php-fpm.log Log level notice When this amount of php processes exited with SIGSEGV or SIGBUS … 10 … in a less than this interval of time, a graceful restart will be initiated. Useful to work around accidental curruptions in accelerator’s shared memory. 1m Time limit on waiting child’s reaction on signals from master 5s Set to ‘no’ to debug fpm yes
Name of pool. Used in logs and stats. default Address to accept fastcgi requests on. Valid syntax is ‘ip.ad.re.ss:port’ or just ‘port’ or ‘/path/to/unix/socket’ 127.0.0.1:9000 Set listen(2) backlog -1 Set permissions for unix socket, if one used. In Linux read/write permissions must be set in order to allow connections from web server. Many BSD-derrived systems allow connections regardless of permissions. 0666 Additional php.ini defines, specific to this pool of workers. /usr/sbin/sendmail -t -i 0 Unix user of processes www Unix group of processes website Process manager settings Sets style of controling worker process count. Valid values are ‘static’ and ‘apache-like’ static Sets the limit on the number of simultaneous requests that will be served. Equivalent to Apache MaxClients directive. Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi Used with any pm_style. 20 Settings group for ‘apache-like’ pm style Sets the number of server processes created on startup. Used only when ‘apache-like’ pm_style is selected 20 Sets the desired minimum number of idle server processes. Used only when ‘apache-like’ pm_style is selected 5 Sets the desired maximum number of idle server processes. Used only when ‘apache-like’ pm_style is selected 250 Time limit on waiting execution of single request Should be used when ‘max_execution_time’ ini option does not terminate execution for some reason 31s Set open file desc rlimit 51200 Set max core size rlimit 0 Chroot to this directory at the start Chdir to this directory at the start Redirect workers’ stdout and stderr into main error log. If not set, they will be redirected to /dev/null, according to FastCGI specs yes How much requests each process should execute before respawn. Useful to work around memory leaks in 3rd party libraries. For endless request processing please specify 0 Equivalent to PHP_FCGI_MAX_REQUESTS 51200 Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect. Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+) Makes sense only with AF_INET listening socket. 127.0.0.1 Pass environment variables like LD_LIBRARY_PATH All $VARIABLEs are taken from current environment $HOSTNAME /usr/local/bin:/usr/bin:/bin /tmp /tmp /tmp $OSTYPE $MACHTYPE 2
和原始配置文件的差别 用户组->www max_children=64 MaxApareServers=250 rlimit_files=51200 max_requests=51200 去掉注释 7.优化文件句柄并开启php ulimit -SHn 51200 /opt/php/sbin/php-fpm start #/opt/php/sbin/php-fpm还有其他参数,包括:start|stop|quit|restart|reload|logrotate,修改php.ini后不重启php-cgi,重新加载配置文件使用reload。

七、安装Nginx 1.安装Nginx所需的pcre库 tar zxvf pcre-7.7.tar.gz cd pcre-7.7/ ./configure –enable-utf8 –enable-unicode-properties make && make install cd ../ 2.安装Nginx tar zxvf nginx-0.6.32.tar.gz cd nginx-0.6.32/ A 关闭debug模式来减少nginx大小 http://bianbian.org/technology/271.html du /opt/nginx/sbin/nginx #未做优化时的大小 1712 /opt/nginx/sbin/nginx #优化后的大小 404 /opt/nginx/sbin/nginx vi auto/cc/gcc # 最后几行sheft+g #注释这行 #CFLAGS=”$CFLAGS -g” B 伪装header vi src/core/nginx.h #define NGINX_VERSION “1.0” #define NGINX_VER “C1GWS/” NGINX_VERSION C 编译 ./configure –user=www –group=website –prefix=/opt/nginx –with-http_stub_status_module –with-http_ssl_module make make install cd ../ 3.修改权限 chown -R www:website /opt/nginx/logs/ chmod -R 0775 /opt/nginx/logs/ chown -R www:website /opt/nginx/conf/ chmod -R 0775 /opt/nginx/conf/ 4.创建Nginx配置文件 rm -f /opt/nginx/conf/nginx.conf vi /opt/nginx/conf/nginx.conf user www website; worker_processes 4; #cpu*2 error_log /opt/nginx/logs/nginx_error.log crit; pid /dev/shm/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ‘ ‘$status $body_bytes_sent “$http_referer” ‘ ‘”$http_user_agent” $http_x_forwarded_for’; charset utf-8; server_names_hash_bucket_size 128; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_intercept_errors on; # 解决 no input file specified fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 128k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; fastcgi_temp_path /dev/shm; gzip on; gzip_min_length 1k; gzip_buffers 4 8k; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/html application/xml; server { listen 80; server_name devwww.c1gstudio.com; index index.html index.htm index.php; root /opt/htdocs/www; location ~ .*\.php?$ { include fcgi.conf; #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } access_log /opt/nginx/logs/access.log access; } server { listen 80; server_name devstatus.c1gstudio.com; index index.html index.htm index.php; root /opt/htdocs/status; error_page 404 /404.html; #error_page 500 502 503 504 /50x.html; location ~ .*\.php?$ { include fcgi.conf; #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } location /nginx { stub_status on; access_log off; auth_basic “NginxStatus”; auth_basic_user_file htpasswd; #用apache的htpasswd生成访问密码 #/opt/apache2/bin/htpasswd -c /opt/nginx/conf/htpasswd c1gstduio admin } # alias #localtion /alias/ { #alias /spool/w3/images/; #} #防盗链 location ~* ^.+\.(jpg|jpeg|gif|png|swf|rar|zip)$ { valid_referers none blocked *.yingjiesheng.com *.yingjiesheng.net localhost; if ($invalid_referer) { rewrite ^/ http://www.c1gstudio.com/logo.gif; return 403; } } # add expires header for static content location ~* ^.+\.(jpg|jpeg|gif|png|css|js|ico|html)$ { access_log off; root /opt/htdocs/www; expires 2h; break; } #禁止访问 location ~/\.ht { deny all; } location /(themes|templates_c)/ { deny all; } access_log /opt/nginx/logs/status.log access; } } 5.nginx的日志滚动 mkdir 0775 /opt/shell chgrp website /opt/shell vi /opt/shell/nginx_log.sh #!/bin/sh log_dir=/opt/nginx/logs yesterday=`date +%Y%m%d` lastday=`date +%Y%m%d -d ‘-1 month’` /bin/rm ${log_dir}/access.${lastday}.log /bin/rm ${log_dir}/nginx_error.${lastday}.log /bin/mv ${log_dir}/access.log ${log_dir}/access.${yesterday}.log /bin/mv ${log_dir}/nginx_error.log ${log_dir}/nginx_error.${yesterday}.log kill -USR1 `cat /opt/nginx/nginx.pid` /bin/gzip ${log_dir}/access.${yesterday}.log & /bin/gzip ${log_dir}/nginx_error.${yesterday}.log & 在crontab里每日23:59时 59 23 * * * /bin/sh /opt/shell/nginx_log.sh > /dev/null 2>&;1 http://www.bullog.cn/blogs/shunz/archives/157311.aspx 6.让nginx支持FastCGI http://wiki.codemongers.com/NginxSimpleCGI http://wiki.codemongers.com/NginxSimpleCGI?action=recall&rev=10 7.cpan安装 A #perl -MCPAN -e ‘install FCGI’ 一路回车 或使用原码安装 B #wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz #tar zxvf FCGI-0.67.tar.gz #cd FCGI-0.67 #perl Makefile.PL #make #make install #mkdir -p /var/run/nginx/ 如果makefile时遇到错误 perl Makefile.PL INSTALL_BASE=~ Can’t locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3. BEGIN failed–compilation aborted at Makefile.PL line 3. 安装perl-ExtUtils-MakeMaker yum install perl-ExtUtils-MakeMaker 将链接网页中的perl代码保存成perl-fcgi.pl并运行 chmod o+x /opt/shell/perl-fcgi.pl perl /opt/shell/perl-fcgi.pl 修改nginx配置文件 检查nginx配置文件/重新载入/关闭nginx /opt/nginx/sbin/nginx -t kill -HUP 进程号 # 重载配置文件 kill -15 进程号 # 关闭 8.pear升级 使用新装的pear代替系统的pear #which pear /usr/bin/pear #pear config-show Configuration (channel pear.php.net): ===================================== Auto-discover new Channels auto_discover Default Channel default_channel pear.php.net HTTP Proxy Server Address http_proxy PEAR server [DEPRECATED] master_server pear.php.net Default Channel Mirror preferred_mirror pear.php.net Remote Configuration File remote_config PEAR executables directory bin_dir /usr/bin PEAR documentation directory doc_dir /usr/share/pear/doc PHP extension directory ext_dir /usr/lib/php4 PEAR directory php_dir /usr/share/pear PEAR Installer cache directory cache_dir /tmp/pear/cache PEAR data directory data_dir /usr/share/pear/data PHP CLI/CGI binary php_bin /usr/bin/php PEAR test directory test_dir /usr/share/pear/test Cache TimeToLive cache_ttl 3600 Preferred Package State preferred_state stable Unix file mask umask 22 Debug Log Level verbose 1 PEAR password (for password maintainers) Signature Handling Program sig_bin /usr/bin/gpg Signature Key Directory sig_keydir /etc/pearkeys Signature Key Id sig_keyid Package Signature Type sig_type gpg PEAR username (for username maintainers) User Configuration File Filename /root/.pearrc System Configuration File Filename /etc/pear.conf #/opt/php/bin/pear config-show Configuration (channel pear.php.net): ===================================== Auto-discover new Channels auto_discover Default Channel default_channel pear.php.net HTTP Proxy Server Address http_proxy PEAR server [DEPRECATED] master_server pear.php.net Default Channel Mirror preferred_mirror pear.php.net Remote Configuration File remote_config PEAR executables directory bin_dir /opt/php/bin PEAR documentation directory doc_dir /opt/php/lib/php/doc PHP extension directory ext_dir /opt/php/lib/php/extensions/no-debug-non-zts-20060613 PEAR directory php_dir /opt/php/lib/php PEAR Installer cache directory cache_dir /tmp/pear/cache PEAR data directory data_dir /opt/php/lib/php/data PHP CLI/CGI binary php_bin /opt/php/bin/php PEAR test directory test_dir /opt/php/lib/php/test Cache TimeToLive cache_ttl 3600 Preferred Package State preferred_state stable Unix file mask umask 22 Debug Log Level verbose 1 cfg_dir download_dir php_ini temp_dir www_dir PEAR password (for password maintainers) Signature Handling Program sig_bin /usr/bin/gpg Signature Key Directory sig_keydir /opt/php/etc/pearkeys Signature Key Id sig_keyid Package Signature Type sig_type gpg PEAR username (for username maintainers) User Configuration File Filename /root/.pearrc System Configuration File Filename /opt/php/etc/pear.conf #mv /usr/bin/pear /usr/bin/pear.del #ln -s /opt/php/bin/pear /usr/bin/pear #pear list Installed packages, channel pear.php.net: ========================================= Package Version State Archive_Tar 1.3.2 stable Console_Getopt 1.2.3 stable PEAR 1.7.1 stable Structures_Graph 1.0.2 stable #pear upgrade pear #pear install Benchmark Cache_Lite DB HTTP Mail Mail_Mime Net_SMTP Net_Socket Pager XML_Parser XML_RPC #pear list Installed packages, channel pear.php.net: ========================================= Package Version State Archive_Tar 1.3.2 stable Benchmark 1.2.7 stable Cache_Lite 1.7.4 stable Console_Getopt 1.2.3 stable DB 1.7.13 stable Mail 1.1.14 stable Mail_Mime 1.5.2 stable Mail_mimeDecode 1.5.0 stable Net_SMTP 1.3.1 stable Net_Socket 1.0.9 stable PEAR 1.7.2 stable Pager 2.4.7 stable Structures_Graph 1.0.2 stable XML_Parser 1.3.0 stable XML_RPC 1.5.1 stable 八、awstats安装 linux awstats 安装 清除日志记录可以删除conf中DirData=”/var/lib/awstats” 下的文件 分析 perl /opt/awstats/wwwroot/cgi-bin/awstats.pl -config=sina -update 查看,在ie中输入 http://localhost/awstats/awstats.pl?config=sina 自动运行,在crontab中加入 10 8 * * * (cd /opt/awstats/wwwroot/cgi-bin/; ./awstats.pl -update -config=sina ) 九、apache与nginx+php cgi性能比较 http://www.guogoul.com/2008/07/08/nginx_2/ 十、快捷控制脚本 点此下载lemp脚本 /opt/lemp Usage: /opt/lemp start Start LEMP (nginx, MySQL, phpfpm, tomcat) startnginx Start only nginx startmysql Start only MySQL starttomcat Start only tomcat startphpfpm Start only phpfpm startmemcached Start only memcached stop Stop LEMP (nginx, MySQL, phpfpm, tomcat) stopnginx Stop only nginx stopmysql Stop only MySQL stoptomcat Stop only tomcat stopphpfpm Stop only phpfpm stopmemcached Stop only memcached reload Reload LEMP (nginx, MySQL, phpfpm ) reloadnginx Reload only nginx reloadmysql Reload only MySQL reloadphpfpm Reload only phpfpm restart Stop and start LEMP 十一、防arp http://bbs.linuxtone.org/thread-41-1-1.html 参考 http://blog.s135.com/read.php/351.htm http://31543.blog.51cto.com/21543/83964 =============================================================== update 2008/08/14 A 解决php 404错误为 no input file specified 在nginx.conf中增加 fastcgi_intercept_errors on; B 优化 #ulimit -SHn 51200 #vi /etc/rc.local 尾部增加 ulimit -SHn 51200 #vi /etc/sysctl.conf 尾部增加 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 #/sbin/sysctl -p C PHP FastCGI进程数多少合适? netstat -anpo | grep “php-cgi” | wc -l 如果实际使用的“FastCGI进程数”接近预设的“FastCGI进程数”,那么,说明“FastCGI进程数”不够用,需要增大。 ======================================================== update 2009-8-19 万恶的wp编辑器把文章搞乱了

Posted in Nginx, 技术.

Tagged with , , , , , , , , , , , , .


如果flash将层挡住了怎么办?

加上一句

Posted in HTML/XHTML/CSS, 技术.


sysstat 安装

This package provides the sar and iostat commands for Linux. Sar and iostat enable system monitoring of disk, network, and other IO activity

http://rpmfind.net/ 下打systat 或 http://pagesperso-orange.fr/sebastien.godard/download.html

含src的rpm安装方式

1.执行rpm -i sysstat-5.0.5-1.src.rpm

  1. cd /usr/src/redhat/SPECS
  2. rpmbuild -bp sysstat-5.0.5-1.specs 一个和你的软件包同名的specs文件
  3. cd /usr/src/redhat/BUILD/sysstat-5.0.5-1/ 一个和你的软件包同名的目录
  4. ./configure 这一步和编译普通的源码软件一样,可以加上参数
  5. make
  6. make install

wget http://perso.orange.fr/sebastien.godard/sysstat-8.0.4.1.tar.gz

tar zxvf sysstat-8.0.4.1.tar.gz

cd sysstat-8.0.4.1

./configure

make

make install

    这个包一但安装下去,一般包括如下的几个命令可以使用。

    sar     iostat     sa1     sa2     sadf     mpstat     sadc     sysstat

crontab -e

/10 /usr/lib/sa/sa1 1 1 53 23 /usr/lib/sa/sa2 -A

 # /etc/init.d/crond restart

http://www.ixpub.net/thread-749930-1-17.html

让普通用户能够使用sar命令,至少有两种办法: 1、将普通用户加到adm组中; 2、这个例子中,就是这个命令:chmod o+x /usr/lib/sa/sadc

查看软件版本


[root@localhost sysstat-8.1.6]# sar -V
sysstat version 8.1.6

查看系统使用的文件描述符

[root@localhost sysstat-8.1.6]# sar -v 2 3 Linux 2.6.9-5.ELsmp (localhost.localdomain)     10/20/2008      i686  (4 CPU)   03:14:44 PM dentunusd   file-nr  inode-nr    pty-nr 03:14:46 PM     57966       810     66883         2 03:14:48 PM     57966       810     66883         2 03:14:50 PM     57966       810     66883         2 Average:        57966       810     66883         2

  1. 查看CPU使用情况
    <!–

    Code highlighting produced by Actipro CodeHighlighter (freeware)
    http://www.CodeHighlighter.com/

    –>sar  2   5 // 每隔2秒,显示5次,CPU使用的情况
     
  2. 查看内存使用情况
    <!–

    Code highlighting produced by Actipro CodeHighlighter (freeware)
    http://www.CodeHighlighter.com/

    –>sar  2   5 // 每隔2秒,显示5次,内存使用的情况
     
    1. 查看网络吞吐量
    <!–

    Code highlighting produced by Actipro CodeHighlighter (freeware)
    http://www.CodeHighlighter.com/

    –>
    1. sar  n DEV  2   5 // 每隔2秒,显示5次,网络吞吐量情况
  • Posted in LINUX, 技术.


    linux 下 lynx 安装

    Lynx是一个基于文本的浏览器 下载地址 http://ftp.iasi.roedu.net/mirrors/lynx.isc.org/current/

    lynx 依赖于openssl

    安装lynx

    运行下面的命令安装lynx:

    ./configure --prefix=/usr --libdir=/etc --with-ssl --with-zlib && make && make install && make DOCDIR=/usr/share/doc/lynx-2.8.4/lynx_doc \    HELPDIR=/usr/share/doc/lynx-2.8.4/lynx_help install-doc && make DOCDIR=/usr/share/doc/lynx-2.8.4/lynx_doc \    HELPDIR=/usr/share/doc/lynx-2.8.4/lynx_help install-help && sed s/"t\/etc"/"t\/usr\/share\/doc\/lynx\-2\.8\.4"/ \    /etc/lynx.cfg > /etc/lynx.bak && mv /etc/lynx.bak /etc/lynx.cfg

    Posted in LINUX, 技术.


    自动mount分区

    fdisk -l 得到需挂载的硬盘/dev/sda1

    先mount一下

    mkdir /opt && chmod 0777 /opt

    mount /dev/sda1 /opt

    成功后改/etc/fstab里的LABEL名字的步骤如下:

    e2label /dev/sda1 /opt

    修改并写入/etc/fstab 例如: LABEL=/opt          /opt                   ext3    defaults        1 2

    重启

    Posted in LINUX, 技术.


    linux下安装lucene

    apache+tomcat整合  http://www.ibm.com/developerworks/cn/opensource/os-lo-apache-tomcat/index.html

     了解 KinoSearch A Perl search engine library. http://www.rectangular.com/kinosearch/  

    Plucene基于java lucene项目创建 安装方法: perl -MCPAN -e “install Plucene” perl -MCPAN -e “install Plucene::Simple”

    Zend Framework http://framework.zend.com/download

    CLucene CLucene是C++版的全文检索引擎,完全移植于Lucene,采用 STL 编写。有php扩展,对中文支持不是很好。 http://sourceforge.net/projects/clucene/

    Lucene4c The Lucene4c project is an implementation of the Lucene search engine in C, built on top of the Apache Portable Runtime.   http://incubator.apache.org/lucene4c/

    Nutch Nutch 是一个开源Java 实现的搜索引擎。它提供了我们运行自己的搜索引擎所需的全部工具。包括全文搜索和Web爬虫。 http://lucene.apache.org/nutch http://nutch.sourceforge.net/docs/en/about.html

    jdk6 http://www.java.net/download/jdk6/6u10/promoted/b24/binaries/jdk-6u10-beta-bin-b24-linux-i586-14_may_2008-rpm.bin ant http://apache.mirror.phpchina.com/ant/binaries/apache-ant-1.7.0-bin.tar.gz lucene http://apache.mirror.phpchina.com/lucene/java/lucene-2.3.2.tar.gz javac https://javacc.dev.java.net/files/documents/17/26776/javacc-4.0.tar.gz php-java bridge http://nchc.dl.sourceforge.net/sourceforge/php-java-bridge/php-java-bridge_5.2.2.tar.gz tomcat http://apache.mirror.phpchina.com/tomcat/tomcat-6/v6.0.16/bin/apache-tomcat-6.0.16.tar.gz

    使用tomcat可以跳过第六步

    一 安装java环境 [root@dev ~]# java -version java version “1.4.2” gcj (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

    [root@dev ~]# rpm -qa |grep java java-1.4.2-gcj-compat-1.4.2.0-26jpp 注:通常,您不必使用 RPM 卸载 JRE,因为 RPM 可以在您安装新版本时自动卸载旧版本的 JRE!除非您准备永久删除 JRE,否则请跳过本节内容。

    [root@dev ~]# rpm   -e   java-1.4.2-gcj-compat-1.4.2.0-26jpp

    http://download.java.net/jdk6/ 下载jdk包 [root@dev ~]#wget –limit-rate=20000 http://www.java.net/download/jdk6/6u10/promoted/b24/binaries/jdk-6u10-beta-bin-b24-linux-i586-14_may_2008-rpm.bin 限制20k

    [root@dev ~]# chmod 755 jdk-6u10-beta-bin-b24-linux-i586-14_may_2008-rpm.bin\?e\=1212404509\&h\=a151b74ce54cda9cba81a7444944c0ba

    [root@dev ~]#./jdk-6u10-beta-bin-b24-linux-i586-14_may_2008-rpm.bin\?e\=1212404509\&h\=a151b74ce54cda9cba81a7444944c0ba 一路空格后健入yes

    [root@dev ~]# vi /etc/profile set JAVA_HOME=/usr/java/jdk1.6.0_10 export JAVA_HOME set PATH=$PATH:$JAVA_HOME/bin export PATH set CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export CLASSPATH

    bourne shell家族中赋值不用set,这个郁闷了我好久没找到变量无效的原因。 [root@dev ~]# source /etc/profile 

    用文本编辑器新建一个Test.java文件,在其中输入以下代码并保存:

        public class Test {       public static void main(String args[]) {         System.out.println(“A new jdk test !”);       }     }

    编译:在shell终端执行命令 javac Test.java 如果出错可能是javac还没装,先接着下面安装javac后,再返回到这里测试。

    运行:在shell终端执行命令 java Test

    当shell下出现“A new jdk test !”字样则jdk运行正常。

    二 安装ant http://ant.apache.org/bindownload.cgi ant是一个基于JAVA的自动化脚本引擎,脚本格式为XML。除了做JAVA编译相关任务外,ANT还可以通过插件实现很多应用的调用,比make脚本来说还要好维护一些。

    [root@dev ~]# wget http://apache.mirror.phpchina.com/ant/binaries/apache-ant-1.7.0-bin.tar.gz

    [root@dev ~]# tar zxvf apache-ant-1.7.0-bin.tar.gz

    [root@dev ~]# mv apache-ant-1.7.0 /usr/local/

    [root@dev ~]# vi /etc/profile

    在JAVA_HOME前加上 ANT_HOME=/usr/local/apache-ant-1.7.0 export ANT_HOME 编辑 set PATH=$PATH:$JAVA_HOME/bin:$ANT_HOME/bin

    [root@dev ~]# source /etc/profile 

    三 安装lucene wget http://apache.mirror.phpchina.com/lucene/java/lucene-2.3.2.tar.gz 不是lucene-2.3.2-src.tar.gz哦,这个无lucene-demos-2.3.2.jar [root@dev ~]# tar zxvf lucene-2.3.2.tar.gz

    [root@dev ~]# mv lucene-2.3.2 /usr/local

    四 安装javac https://javacc.dev.java.net/files/documents/17/26776/javacc-4.0.tar.gz [root@dev ~]# wget https://javacc.dev.java.net/files/documents/17/26776/javacc-4.0.tar.gz

    [root@dev ~]# gunzip javacc-4.0.tar.gz

    [root@dev ~]# tar -xvf javacc-4.0.tar

    [root@dev ~]# mv javacc-4.0 /usr/local/

    [root@dev ~]# cd  /usr/local/lucene-2.3.2

    [root@dev ~]# echo javacc.home=/usr/local/javacc-4.0 > ~/build.properties

    [root@dev ~]# ant

    五 测试lucene 再修改/etc/profile,在CLASSPATH前加上 LUCENE_HOME=/usr/local/lucene-2.3.2 修改变量 CLASSPATH=.:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar:${LUCENE_HOME}/lucene-core-2.3.2.jar:${LUCENE_HOME}/lucene-demos-2.3.2.jar

    #source /etc/profile

    生成索引

    [root@dev ~]# cd ./src/demo

    [root@dev demo]# java org.apache.lucene.demo.IndexFiles /usr/local/lucene-2.3.2/docs Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/lucene/demo/IndexFiles Caused by: java.lang.ClassNotFoundException: org.apache.lucene.demo.IndexFiles at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) Could not find the main class: org.apache.lucene.demo.IndexFiles. Program will exit.

    出现以上错误估计是CLASSPATH没写对。

    搜索…,输入以下命令就会出现搜索提示符。 [root@dev demo]# java org.apache.lucene.demo.SearchFiles

    六 安装php-java bridge php/Java bridge What is php/Java bridge? The php/Java bridge is an optimized, XML-based network protocol, which can be used to connect a native script engine, PHP, with a Java or ECMA 335 virtual machine. It is more than 50 times faster than local RPC via SOAP, requires less resources on the web-server side, and it is faster and more reliable than direct communication via the Java Native Interface. read more… http://php-java-bridge.sourceforge.net

    [root@dev ~]# wget –limit-rate=15000 http://nchc.dl.sourceforge.net/sourceforge/php-java-bridge/php-java-bridge_5.2.2.tar.gz

    [root@dev php-java-bridge-5.2.2]# /opt/lampp/bin/phpize && ./configure –disable-servlet –with-java=/usr/java/jdk1.6.0_10 && make CFLAGS=”-m32″ && make install ./configure: line 2969: php-config: command not found ./configure: line 2970: php-config: command not found configure: error: Cannot find php-config. Please use –with-php-config=PATH

    缺少xampp开发包和php-config 路径设置 http://sourceforge.net/project/showfiles.php?group_id=61776&package_id=60248

    [root@dev ~]# tar -zxvf xampp-linux-devel-xxx.tar.gz

    [root@dev ~]# mv lampp/* /opt/lampp/

    mv: cannot overwrite directory /opt/lampp/lib' mv: cannot overwrite directory/opt/lampp/modules’ mv: cannot overwrite directory `/opt/lampp/share’

    手动一个个移啦

    [root@dev php-java-bridge-5.2.2]# /opt/lampp/bin/phpize && ./configure –disable-servlet –with-php-config=/opt/lampp/bin/php-config –with-java=/usr/java/jdk1.6.0_10 && make CFLAGS=”-m32″ && make install

    make[1]: [php/java/bridge/JavaBridgeIllegalStateException.o] Error 1 make[1]: Leaving directory `/root/php-java-bridge-5.2.2/server’ make: [/root/php-java-bridge-5.2.2/modules/stamp] Error 2 报两个错,不去理它

    [root@dev php-java-bridge-5.2.2]# cp modules/java.so /opt/lampp/modules/

    vi /opt/lampp/etc/php.ini 加上 extension=”java.so”

    [root@dev php-java-bridge-5.2.2]# /opt/lampp/lampp start Starting XAMPP for Linux 1.6.1… PHP Warning: PHP Startup: Unable to load dynamic library ‘/opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/java.so’ – /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/java.so: cannot open shared object file: No such file or directory in Unknown on line 0

    [root@dev php-java-bridge-5.2.2]# cp modules/java.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/ [root@dev php-java-bridge-5.2.2]# /opt/lampp/lampp start Starting XAMPP for Linux 1.6.1… Exception in thread “main” java.lang.NoClassDefFoundError: php/java/bridge/Standalone Caused by: java.lang.ClassNotFoundException: php.java.bridge.Standalone at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) Could not find the main class: php.java.bridge.Standalone. Program will exit.

    不行咯,换成用tomcat 七 安装tomcat http://tomcat.apache.org/tomcat-6.0-doc/setup.html [root@dev ~]# wget –limit-rate=20000 http://apache.mirror.phpchina.com/tomcat/tomcat-6/v6.0.16/bin/apache-tomcat-6.0.16.tar.gz [root@dev ~]# tar -zxvf apache-tomcat-6.0.16.tar.gz [root@dev ~]# mv apache-tomcat-6.0.16 /usr/local/apache-tomcat

    [root@dev ~]# vi /etc/profile export JDK_HOME=${JAVA_HOME}

    export CATALINA_BASE=/usr/local/apache-tomcat export CATALINA_HOME=/usr/local/apache-tomcat [root@dev ~]# source /etc/profile [root@dev ~]# vi /etc/rc.d/rc.local /usr/local/apache-tomcat/bin/startup.sh

    测试 http://192.168.54.96:8080

     vi /usr/local/apache-tomcat/conf/server.xml

    port=”8080″ protocol=”HTTP/1.1″ connectionTimeout=”20000″ URIEncoding=”UTF-8″#增加此行 redirectPort=”8443″>

    < Host name =”localhost appBase =”webapps unpackWARs =”true autoDeploy =”true xmlValidation =”false xmlNamespaceAware =”false >

    中增加以下内容,将weblucene设为根目录

      < Context path =” docBase =”/usr/local/apache-tomcat/webapps/weblucene reloadable =”true debug =”0 crossContext =”true />

    server.xml默认有下面一行:

    这样允许任何人只要telnet到服务器的8005端口,输入”SHUTDOWN”,然后回车,服务器立即就被关掉了。 从安全的角度上考虑,我们需要把这个shutdown指令改成一个别人不容易猜测的字符串。 例如修改如下: ,这样就只有在telnet到8006,并且输入”lizongbo”才能够关闭Tomcat. 注意:这个修改不影响shutdown.bat的执行。运行shutdown.bat一样可以关闭服务器。

    参考Tomcat安全文档英文链接:http://jakarta.apache.org/tomcat/faq/security.html#8005 还有两个问题需要注意: 1、 对于tomcat3.1中,屏蔽目录文件自动列出的方法是什么? 缺省情况下,如果你访问tomcat下的一个web应用,那么如果你输入的是一个目录名,而且该目录下没有一个可用的welcome文件,那么tomcat会将该目录下的所有文件列出来,如果你想屏蔽这个缺省行为,那么可以修改conf/web.xml文件,将其中的:

    default org.apache.catalina.servlets.DefaultServlet

    debug

    0

    listings

    true 1修改为:

    default org.apache.catalina.servlets.DefaultServlet

    debug

    0

    listings

    false 1 默认的shutdown.sh一执行就死机,用网上的代替 http://noroot.info/node/16153

    cd /usr/local/apache-tomcat/bin

    mv shutdown.sh shutdown.sh.old

    vi /usr/local/apache-tomcat/bin/shutdown.sh //创建新的shutdown.sh关闭服务脚本

    #!/bin/sh TOMCAT_PID=/bin/netstat -anp|/bin/grep :8080 |/bin/gawk '{print $7}' |/bin/gawk -F [/] '{print $1}' /bin/kill -9 $TOMCAT_PID 2>/dev/null if [ $? -ne 0 ];then echo ‘Tomcat is not running.’ else echo “Succeed to shutdown tomcat.” fi

    chmod a+x shutdown.sh //为新建的脚本文件增加执行权限

    八 apache整合

    可以避免打8080 编辑apache http.conf servername devs.c1gstudio.com

    ProxyPass / balancer://cluster/ BalancerMember http://192.168.54.96:8080/

    Posted in Lucene, Tomcat, 技术.

    Tagged with , , .


    Linux的时间设置与同步 (NTP)

    http://x.86516.com/index.php/uid-69-action-viewspace-itemid-4537

    http://www.pool.ntp.org是NTP的官方网站,在这上面我们可以找到离我们城市最近的NTP Server. NTP建议我们为了保障时间的准确性,最少找两个个NTP Server asia的服务器地址 http://support.ntp.org/bin/view/Servers/NTPPoolServers

    ntp.api.bz ntp.api.bz 是一组NTP服务器集群,目前有6台服务器,位于上海电信。这项服务是 api.bz 继 http://sms.api.bz 移动飞信免费短信发送接口之后的第二项免费 API 服务。

    第二步要做的就是在打开NTP服务器之前先和这些服务器做一个同步,使得我们机器的时间尽量接近标准时间. 这里我们可以用ntpdate命令

    Posted in LINUX, 技术.

    Tagged with , .


    No space left on device

    设置crontab 时提示No space left on device 用df -k 检查还有空间

    用df -i  显示 /var 已占用100%,如果inode耗尽,则系统上将不能创建文件。

    在/var/spoo/clientmqueue/下有超多的文件 ls 半天没反应 用rm -rf * 会自动跳出root,用xargs来解决。

    # cd /var/spool/clientmqueue

    # ls | xargs rm -f

    原因分析:系统中cron执行的程序有输出内容,输出内容会以邮件形式发给cron的用户,而sendmail没有启动所以就产生了这些文件; 解决办法:  将crontab里面的命令后面加上> /dev/null 2>&1

    Posted in LINUX, 技术.


    textarea在ie7存在自适应宽度bug

    使用css width:99%控制宽度,当你从文本文件中粘贴一篇无换行的文章时,textarea的滚动条会自动跳至文本框顶部,影响输入。估计是ie7不能准确显示无换行内容的高度,在ie6,ff下无此问题。

    解决方法是去掉css,在textarea中用cols=90 写死宽度,IE7宽屏显示效果会差点,在FF下由于外部套了table仍然会自适应宽度。

    Posted in HTML/XHTML/CSS, 技术.