SUSE Linux 11里Nginx+Resin+JSP+Memcached+MySQL安装配置整合

本文介绍如何在SUSE Linux Enterprise Server 11 SP2上整合Nginx和Resin,实现Nginx处理静态内容,Resin处理动态JSP内容。文中详细介绍了安装依赖软件、配置Nginx与Resin、以及安装MySQL和memcached的过程。

http://www.ha97.com/5100.html/comment-page-1

PS:因一客户的运营环境需求,需要nginxresin整合,nginx负责处理静态页面部份,resin负责处理动态JSP部份。Resin是CAUCHO公司的产品,是一个非常流行的application server,对servlet和JSP提供了良好的支持,性能也比较优良,resin自身采用JAVA语言开发,而且Resin速度比Tomcat快,稳定性也比Tomcat好。关于各软件版本,我使用了官方比较新的稳定版本。以下是该环境安装整合部署的详细总结:

系统环境:SUSE Linux Enterprise Server 11 x64 SP2(其他Linux发行版基本通用)

一、前提环境

1、安装常用依赖软件包:(zypper类似于Redhat的yum,在CentOS中可以yum安装下列软件包)

zypper install gcc gcc-c++ bison patch unzip mlocate flex wget automake autoconf gd cpp gettext readline-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel openldap openldap-devel openldap-clients openldap-servers nss_ldap expat-devel libtool libtool-ltdl-devel bison libevent

2、使用Tcmalloc 优化Nginx、MySQL

注:64位操作系统请先安装 libunwind库,32位操作系统不要安装。libunwind库为基于64位CPU和操作系统的程序提供了基本的堆栈辗转开解功能,其中包括用于输出堆栈跟踪的API、用于以编程方式辗转开解堆栈的API以及支持C++异常处理机制的API。

我的以下软件包都下载在/root目录里:

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.0.1.tar.gz
tar zxvf libunwind-1.0.1.tar.gz
cd libunwind-1.0.1/
./configure
make
make install

注:google-perftools 是一款针对 C/C++ 程序的性能分析工具,它是一个遵守BSD协议的开源项目。使用该工具可以对 CPU 时间片、内存等系统资源的分配和使用进行分析。google-perftools 对一个程序的CPU性能剖析包括以下几个步骤。
1. 编译目标程序,加入对 google-perftools 库的依赖。
2. 运行目标程序,并用某种方式启动 / 终止剖析函数并产生剖析结果。
3. 运行剖结果转换工具,将不可读的结果数据转化成某种格式的文档(例如 pdf,txt,gv 等)。

cd /root
wget http://gperftools.googlecode.com/files/gperftools-2.0.tar.gz
tar zxvf gperftools-2.0.tar.gz
cd gperftools-2.0/
./configure
make
make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig

二、安装Nginx

1、添加nginx用户和编译安装nginx相关源码包:

groupadd www
useradd -g www www -s /sbin/nologin
mkdir -p /data/www
chmod +w /data/www
chown -R www:www /data/www
mkdir -p /data/logs
chmod +w /data/logs
chown -R www:www /data/logs

cd /root
wget http://nchc.dl.sourceforge.net/project/pcre/pcre/8.31/pcre-8.31.tar.gz
tar zxvf pcre-8.31.tar.gz
cd pcre-8.31/
./configure
make
make install

cd /root
wget http://zlib.net/zlib-1.2.7.tar.gz
tar -vxf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure
make install

注:zlib这个包一般系统自带有,但SUSE居然没有这个包,所以要编译一个。CentOS可以直接用yum安装。

cd /root
wget http://www.nginx.org/download/nginx-1.2.3.tar.gz
tar zxvf nginx-1.2.3.tar.gz
cd nginx-1.2.3/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-google_perftools_module
make
make install

2、编辑修改nginx主配置文件:
vim /usr/local/nginx/conf/nginx.conf

配置如下:

user www www;
worker_processes 8;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/nginx.pid;
#使用Tcmalloc优化nginx性能
google_perftools_profiles /var/tmp/tcmalloc;
注:Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
#工作模式及连接数上限
events
{
use epoll;
worker_connections 65535;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
http
{
#设定mime类型
include mime.types;
default_type application/octet-stream;
#charset gb2312;
#设定请求缓冲
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
#设置客户端能够上传文件大小的限制
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
server_tokens off;
client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_send_timeout 60;
proxy_read_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
#fastcgi_connect_timeout 300;
#fastcgi_send_timeout 300;
#fastcgi_read_timeout 300;
#fastcgi_buffer_size 64k;
#fastcgi_buffers 4 64k;
#fastcgi_busy_buffers_size 128k;
#fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

#limit_zone crawler $binary_remote_addr 10m;

#定义访问日志的写入格式
log_format wwwlog '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /data/logs/www_nginx.log wwwlog;
#设定访问日志的存放路径

#禁止通过ip访问站点
server{
server_name _;
return 404;
}
server
{
listen 80;
server_name www.webnginx.com;
index index.html index.htm index.jsp index.do;
#设定访问的默认首页地址
root /data/www/webnginx/;
#设定网站的资源存放路径
#limit_conn crawler 20;
if (-d $request_filename)
{
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}

#所有jsp的页面均交由resin处理
location ~ .(jsp|jspx|do)?$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
#转向resin处理
}
location ~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$
#设定访问静态文件直接读取不经过resin
{
expires 30d;
}
location ~ .*.(js|css)?$
{
expires 1h;
}
}

server
{
listen 80;
server_name status.www.webnginx.com;
location / {
stub_status on;
access_log off;
}
}
}

3、添加nginx服务启动脚本:
vim /etc/init.d/nginx

#! /bin/bash
# Description: Startup script for webserver on CentOS. cp it in /etc/init.d and
# chkconfig --add nginx && chkconfig nginx on
# then you can use server command control nginx
#
# chkconfig: 2345 08 99
# description: Starts, stops nginx

set -e
PATH=$PATH:/usr/local/nginx/sbin/
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/nginx.conf
PIDFILE=/usr/local/nginx/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

d_start() {
$DAEMON -c $CONFIGFILE || echo -n " already running"
}

d_stop() {
kill -QUIT `cat $PIDFILE` || echo -n " not running"
}

d_reload() {
kill -HUP `cat $PIDFILE` || echo -n " can't reload"
}

case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
d_reload
echo "reloaded."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
exit 0

4、将nginx添加到自启动服务中并启动:

chmod 700 /etc/init.d/nginx
chkconfig --add nginx
chkconfig --level 2345 nginx on
/etc/init.d/nginx start

附:Nginx的configure脚本支持选项说明:

./configure --help
--prefix= - 安装路径,如果没有指定,默认为/usr/local/nginx。
--sbin-path= - nginx可执行命令的文件,如果没有指定,默认为/sbin/nginx。
--conf-path= - 在没有使用-c参数指定的情况下nginx.conf的默认位置,如果没有指定,默认为/conf/nginx.conf。
--pid-path= - nginx.pid的路径,如果没有在nginx.conf中通过“pid”指令指定,默认为/logs/nginx.pid。
--lock-path= - nginx.lock文件路径,如果没有指定,默认为/logs/nginx.lock。
--error-log-path= - 当没有在nginx.conf中使用“error_log”指令指定时的错误日志位置,如果没有指定,默认为/logs/error.log。
--http-log-path= - 当没有在nginx.conf中使用“access_log”指令指定时的访问日志位置,如果没有指定,默认为/logs/access.log。
--user= - 当没有在nginx.conf中使用“user”指令指定时nginx运行的用户,如果没有指定,默认为“nobody”。
--group= - 当没有在nginx.conf中使用“user”指令指定时nginx运行的组,如果没有指定,默认为“nobody”。
--builddir=DIR - 设置构建目录。
--with-rtsig_module - 启用rtsig模块。
--with-select_module --without-select_module - 如果在configure的时候没有发现kqueue, epoll, rtsig或/dev/poll其中之一,select模块始终为启用状态。
--with-poll_module --without-poll_module - 如果在configure的时候没有发现kqueue, epoll, rtsig或/dev/poll其中之一,poll模块始终为启用状态。
--with-http_ssl_module - 启用ngx_http_ssl_module,启用SSL支持并且能够处理HTTPS请求。需要OpenSSL,在Debian系统中,对应的包为libssl-dev。
--with-http_realip_module - 启用ngx_http_realip_module
--with-http_addition_module - 启用ngx_http_addition_module
--with-http_sub_module - 启用ngx_http_sub_module
--with-http_dav_module - 启用ngx_http_dav_module
--with-http_flv_module - 启用ngx_http_flv_module
--with-http_stub_status_module - 启用”server status”(服务状态)页
--without-http_charset_module - 禁用ngx_http_charset_module
--without-http_gzip_module - 禁用ngx_http_gzip_module,如果启用,需要zlib包。
--without-http_ssi_module - 禁用ngx_http_ssi_module
--without-http_userid_module - 禁用ngx_http_userid_module
--without-http_access_module - 禁用ngx_http_access_module
--without-http_auth_basic_module - 禁用ngx_http_auth_basic_module
--without-http_autoindex_module - 禁用ngx_http_autoindex_module
--without-http_geo_module - 禁用ngx_http_geo_module
--without-http_map_module - 禁用ngx_http_map_module
--without-http_referer_module - 禁用ngx_http_referer_module
--without-http_rewrite_module - 禁用ngx_http_rewrite_module。如果启用,需要PCRE包。
--without-http_proxy_module - 禁用ngx_http_proxy_module
--without-http_fastcgi_module - 禁用ngx_http_fastcgi_module
--without-http_memcached_module - 禁用ngx_http_memcached_module
--without-http_limit_zone_module - 禁用ngx_http_limit_zone_module
--without-http_empty_gif_module - 禁用ngx_http_empty_gif_module
--without-http_browser_module - 禁用ngx_http_browser_module
--without-http_upstream_ip_hash_module - 禁用ngx_http_upstream_ip_hash_module
--with-http_perl_module - 启用ngx_http_perl_module
--with-perl_modules_path=PATH - 为perl模块设置路径
--with-perl=PATH - 为perl库设置路径
--http-client-body-temp-path=PATH - 为http连接的请求实体临时文件设置路径,如果没有指定,默认为/client_body_temp
--http-proxy-temp-path=PATH - 为http代理临时文件设置路径,如果没有指定,默认为/proxy_temp
--http-fastcgi-temp-path=PATH - 为http fastcgi临时文件设置路径,如果没有指定,默认为/fastcgi_temp
--without-http - 禁用HTTP服务
--with-mail - 启用IMAP4/POP3/SMTP代理模块
--with-mail_ssl_module - 启用ngx_mail_ssl_module
--with-cc=PATH - 设置C编译器路径
--with-cpp=PATH - 设置C预处理器路径
--with-cc-opt=OPTIONS - 变量CFLAGS中附加的参数,用于FreeBSD中的PCRE库,同样需要指定--with-cc-opt=”-I /usr/local/include”,如果我们使用select()函数则需要同时增加文件描述符数量,可以通过--with-cc-opt=”-D FD_SETSIZE=2048”指定。
--with-ld-opt=OPTIONS - 通过连接器的附加参数,用于FreeBSD中的PCRE库,同样需要指定--with-ld-opt=”-L /usr/local/lib”。
--with-cpu-opt=CPU - 指定编译的CPU,可用的值为: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
--without-pcre - 禁用PCRE库文件,同时将禁用HTTP rewrite 模块,如果要在”location”指令中使用正则表达式,同样需要PCRE库。
--with-pcre=DIR - 设置PCRE库源文件路径。
--with-pcre-opt=OPTIONS - 在编译时为PCRE设置附加参数。
--with-md5=DIR - 设置md5库源文件路径。
--with-md5-opt=OPTIONS - 在编译时为md5设置附加参数。
--with-md5-asm - 使用md5汇编源。
--with-sha1=DIR - 设置sha1库源文件路径。
--with-sha1-opt=OPTIONS - 在编译时为sha1设置附加参数。
--with-sha1-asm - 使用sha1汇编源。
--with-zlib=DIR - 设置zlib库源文件路径。
--with-zlib-opt=OPTIONS - 在编译时为zlib设置附加参数。
--with-zlib-asm=CPU - 为指定的CPU使用zlib汇编源进行优化,可用值为: pentium, pentiumpro。
--with-openssl=DIR - 设置openssl库源文件路径。
--with-openssl-opt=OPTIONS - 在编译时为openssl设置附加参数。
--with-debug - 启用debug记录。
--add-module=PATH - 增加一个在PATH中的第三方模块。

三、安装JDK和Resin

1、安装并配置JDK 1.6:

JDK 1.6版本下载列表:http://www.oracle.com/technetwork/java/javase/downloads/jdk6-downloads-1637591.html
下载rpm的安装包:jdk-6u34-linux-x64-rpm.bin
chmod +x jdk-6u34-linux-x64-rpm.bin
./jdk-6u34-linux-x64-rpm.bin

设置环境变量
vim /etc/profile
加入如下环境变量:

export JAVA_HOME=/usr/java/jdk1.6.0_34
export CLASS_PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$PATH:$JAVA_HOME/bin

source /etc/profile

注:查看java版本
java -version

2、安装并配置Resin:

wget http://www.caucho.com/download/resin-4.0.30.tar.gz
tar zxvf resin-4.0.30.tar.gz
cd resin-4.0.30/
./configure --prefix=/usr/local/resin
make
make install

启动resin:
/usr/local/resin/bin/resin.sh start

设置resin开机自启动:

cp -r init.d/resin /etc/init.d/resin
chmod +x /etc/init.d/resin
chkconfig --add resin
chkconfig --level 2345 resin on

四、Nginx、Resin整合和测试

1、将resin的默认目录与nginx的目录相同:
vim /usr/local/resin/conf/resin.xml

把下面:

<host id="" root-directory=".">
<!--
- webapps can be overridden/extended in the resin.xml
-->
<web-app id="/" root-directory="webapps/ROOT"/>

修改成:

<host id="" root-directory=".">
<!--
- webapps can be overridden/extended in the resin.xml
-->
<web-app id="/" root-directory="/data/www/webnginx"/>

2、创建一个JSP测试文件
vim /data/www/webnginx/index.jsp

3 + 6 = <%= 3 + 6 %>
详细的JSP环境探针代码请看:

http://www.ha97.com/5076.html

http://www.ha97.com/5086.html

重启nginx、resin
/etc/init.d/nginx restart
/etc/init.d/resin restart

注:访问http://www.webnginx.com,如果看到3 + 6 = 9,就证明nginx、resin整合成功。

五、安装memcached


cd /root
wget https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
tar -zxvf libevent-2.0.20-stable.tar.gz
cd libevent-2.0.20-stable/
./configure
make
make install
ln -s /usr/local/lib/libevent-2.0.so.5 /lib64/libevent-2.0.so.5

注:Libevent是一个轻量级的开源高性能网络库,memcache使用libevent作为网络底层的函式库。SUSE自带有libevent包,可能版本问题,不能正常使用,所以要重现编译安装2.0版本才行。


cd /root
wget http://memcached.googlecode.com/files/memcached-1.4.14.tar.gz
tar -zxvf memcached-1.4.14.tar.gz
cd memcached-1.4.14/
./configure --prefix=/usr/local/memcached --with-libevent=/usr
make
make install

注:Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提供动态、数据库驱动网站的速度。Memcached基于一个存储键/值对的hashmap。其守护进程(daemon)是用C写的,但是客户端可以用任何语言来编写,并通过memcached协议与守护进程通信。

注:Memcached基本使用方法:
-l 监听的地址memcached 无身份验证功能,严禁在无防护
-p 监听的端口状态下,直接监听外网端口!默认端口为11211
-d 以daemon 形式运行,一般皆需增加此参数
-u 以何用户身份运行,一般选nobody 等低权用户
-m 最大可用内存,以兆为单位
-c 最大的同时并发数,默认1024
-f 增长因子
-P PID 文件
启动:
/usr/local/memcached/bin/memcached -d -m 1024 -p 11211 -u www -c 4096
关闭:
killall -9 memcached
开机启动:
echo “/usr/local/memcached/bin/memcached -d -m 1024 -p 11211 -u www -c 4096″ >> /etc/rc.local

六、使用cmake编译安装MySQL

1、安装cmake:

cd /root
wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
tar zxvf cmake-2.8.8.tar.gz
cd cmake-2.8.8/
./bootstrap
gmake
gmake install

2、新建mysql用户和组、mysql数据目录:

groupadd mysql
useradd -g mysql mysql -s /sbin/nologin
mkdir -p /data/mysql/{data,binlog,relaylog,mysql}
chown -R mysql.mysql /data/mysql

3、定制安装MySQL 5.5:

cd ../
wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz
tar zxvf mysql-5.5.27.tar.gz
cd mysql-5.5.27/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql/data -DMYSQL_TCP_PORT=3306
make
make install
chmod +w /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

4、编辑mysql配置文件:
vim /etc/my.cnf

[client]
port = 3306
socket = /data/mysql/mysql.sock

[mysqld]
character_set_server = utf8
collation-server = utf8_general_ci
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user = mysql
port = 3306
socket = /data/mysql/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql/data
log-error = /data/mysql/mysql_error.log
pid-file = /data/mysql/mysql.pid
open_files_limit = 10240
back_log = 800
max_connections = 5000
max_connect_errors = 5000
table_cache = 1024
external-locking = FALSE
max_allowed_packet = 64M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 300
thread_concurrency = 8
query_cache_size = 512M
query_cache_limit = 4M
query_cache_min_res_unit = 4k
default-storage-engine = MyISAM
thread_stack = 512K
transaction_isolation = READ-COMMITTED
tmp_table_size = 512M
max_heap_table_size = 512M
long_query_time = 3
log-slave-updates
log-bin = /data/mysql/binlog/binlog
binlog_cache_size = 6M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 128M
relay-log-index = /data/mysql/relaylog/relaylog
relay-log-info-file = /data/mysql/relaylog/relaylog
relay-log = /data/mysql/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 512M
read_buffer_size = 8M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 128M
myisam_sort_buffer_size = 256M
myisam_max_sort_file_size = 100G
myisam_repair_threads = 1
myisam_recover

interactive_timeout = 90
wait_timeout = 90

skip_external_locking
skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

#master-host = 192.168.1.100
#master-user = user
#master-password = passwd
#master-port = 3306

server-id = 1
skip-innodb
log-slow-queries = /data/mysql/slow.log
long_query_time = 2

[mysqldump]
quick
max_allowed_packet = 128M

5、初始化mysql数据库:

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql

6、开启TCMalloc提高mysql在高并发下的性能
vim /usr/local/mysql/bin/mysqld_safe
在# executing mysqld_safe的下一行,加入如下:
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
注:使用lsof命令查看tcmalloc是否起效,这个需要启动mysql服务后才看到。
lsof -n | grep tcmalloc

7、设置mysql服务启动脚本:
cp mysql-5.5.27/support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
修改如下:

basedir=/usr/local/mysql
datadir=/data/mysql/data

chmod 700 /etc/init.d/mysqld
/etc/init.d/mysqld restart
chkconfig –add mysqld
chkconfig –level 2345 mysqld on
ln -s /usr/local/mysql/bin/mysql /sbin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin

8、设置mysql root密码:
mysqladmin -u root password 123456
修改root已设置好的密码:
mysqladmin -u root -p password 456
添加mysql管理帐户:

mysql -h localhost -u root -p123456
msqyl> use mysql;
msqyl> grant all on *.* to 'ha97'@'192.168.1.100' identified by '666888';
msqyl> flush privileges;
msqyl> exit;

9、配置mysql库文件搜索路径:
echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
ldconfig
添加/usr/local/mysql/bin到环境变量中:
export PATH=$PATH:/usr/local/mysql/bin


关于日历的控/* * My97 DatePicker 4.8 Beta4 * License: http://www.my97.net/dp/license.asp */ var $dp,WdatePicker;(function(){var $={ $langList:[ {name:"en",charset:"UTF-8"}, {name:"zh-cn",charset:"gb2312"}, {name:"zh-tw",charset:"GBK"}], $skinList:[ {name:"default",charset:"gb2312"}, {name:"whyGreen",charset:"gb2312"}, {name:"blue",charset:"gb2312"}, {name:"green",charset:"gb2312"}, {name:"simple",charset:"gb2312"}, {name:"ext",charset:"gb2312"}, {name:"blueFresh",charset:"gb2312"}, {name:"twoer",charset:"gb2312"}, {name:"YcloudRed",charset:"gb2312"}], $wdate:true, $crossFrame:true, $preLoad:false, $dpPath:"", doubleCalendar:false, enableKeyboard:true, enableInputMask:true, autoUpdateOnChanged:null, weekMethod:"ISO8601", position:{}, lang:"auto", skin:"default", dateFmt:"yyyy-MM-dd", realDateFmt:"yyyy-MM-dd", realTimeFmt:"HH:mm:ss", realFullFmt:"%Date %Time", minDate:"1900-01-01 00:00:00", maxDate:"2099-12-31 23:59:59", startDate:"", alwaysUseStartDate:false, yearOffset:1911, firstDayOfWeek:0, isShowWeek:false, highLineWeekDay:true, isShowClear:true, isShowToday:true, isShowOK:true, isShowOthers:true, readOnly:false, errDealMode:0, autoPickDate:null, qsEnabled:true, autoShowQS:false, opposite:false, hmsMenuCfg:{H:[1,6],m:[5,6],s:[15,4]}, opposite:false, specialDates:null,specialDays:null,disabledDates:null,disabledDays:null,onpicking:null,onpicked:null,onclearing:null,oncleared:null,ychanging:null,ychanged:null,Mchanging:null,Mchanged:null,dchanging:null,dchanged:null,Hchanging:null,Hchanged:null,mchanging:null,mchanged:null,schanging:null,schanged:null,eCont:null,vel:null,elProp:"",errMsg:"",quickSel:[],has:{},getRealLang:function(){var _=$.$langList;for(var A=0;A<_.length;A++)if(_[A].name==this.lang)return _[A];return _[0]}};WdatePicker=U;var Y=window,T={innerHTML:""},N="document",H="documentElement",C="getElementsByTagName",V,A,S,G,c,X=navigator.appName;if(X=="Microsoft Internet Explorer")S=true;else if(X=="Opera")c=true;else G=true;A=$.$dpPath||J();if($.$wdate)K(A+"skin/WdatePicker.css");V=Y;if($.$crossFrame){try{while(V.parent!=V&&V.parent[N][C]("frameset").length==0)V=V.parent}catch(O){}}if(!V.$dp)V.$dp={ff:G,ie:S,opera:c,status:0,defMinDate:$.minDate,defMaxDate:$.maxDate};B();if($.$preLoad&&$dp.status==0)E(Y,"onload",function(){U(null,true)});if(!Y[N].docMD){E(Y[N],"onmousedown",D,true);Y[N].docMD=true}if(!V[N].docMD){E(V[N],"onmousedown",D,true);V[N].docMD=true}E(Y,"onunload",function(){if($dp.dd)P($dp.dd,"none")});function B(){try{V[N],V.$dp=V.$dp||{}}catch($){V=Y;$dp=$dp||{}}var A={win:Y,$:function($){return(typeof $=="string")?Y[N].getElementById($):$},$D:function($,_){return this.$DV(this.$($).value,_)},$DV:function(_,$){if(_!=""){this.dt=$dp.cal.splitDate(_,$dp.cal.dateFmt);if($)for(var B in $)if(this.dt[B]===undefined)this.errMsg="invalid property:"+B;else{this.dt[B]+=$[B];if(B=="M"){var C=$["M"]>0?1:0,A=new Date(this.dt["y"],this.dt["M"],0).getDate();this.dt["d"]=Math.min(A+C,this.dt["d"])}}if(this.dt.refresh())return this.dt}return""},show:function(){var A=V[N].getElementsByTagName("div"),$=100000;for(var B=0;B<A.length;B++){var _=parseInt(A[B].style.zIndex);if(_>$)$=_}this.dd.style.zIndex=$+2;P(this.dd,"block");P(this.dd.firstChild,"")},unbind:function($){$=this.$($);if($.initcfg){L($,"onclick",function(){U($.initcfg)});L($,"onfocus",function(){U($.initcfg)})}},hide:function(){P(this.dd,"none")},attachEvent:E};for(var _ in A)V.$dp[_]=A[_];$dp=V.$dp}function E(B,_,A,$){if(B.addEventListener){var C=_.replace(/on/,"");A._ieEmuEventHandler=function($){return A($)};B.addEventListener(C,A._ieEmuEventHandler,$)}else B.attachEvent(_,A)}function L(A,$,_){if(A.removeEventListener){var B=$.replace(/on/,"");_._ieEmuEventHandler=function($){return _($)};A.removeEventListener(B,_._ieEmuEventHandler,false)}else A.detachEvent($,_)}function a(_,$,A){if(typeof _!=typeof $)return false;if(typeof _=="object"){if(!A)for(var B in _){if(typeof $[B]=="undefined")return false;if(!a(_[B],$[B],true))return false}return true}else if(typeof _=="function"&&typeof $=="function")return _.toString()==$.toString();else return _==$}function J(){var _,A,$=Y[N][C]("script");for(var B=0;B<$.length;B++){_=$[B].getAttribute("src")||"";_=_.substr(0,_.toLowerCase().indexOf("wdatepicker.js"));A=_.lastIndexOf("/");if(A>0)_=_.substring(0,A+1);if(_)break}return _}function K(A,$,B){var D=Y[N][C]("HEAD").item(0),_=Y[N].createElement("link");if(D){_.href=A;_.rel="stylesheet";_.type="text/css";if($)_.title=$;if(B)_.charset=B;D.appendChild(_)}}function F($){$=$||V;var A=0,_=0;while($!=V){var D=$.parent[N][C]("iframe");for(var F=0;F<D.length;F++){try{if(D[F].contentWindow==$){var E=W(D[F]);A+=E.left;_+=E.top;break}}catch(B){}}$=$.parent}return{"leftM":A,"topM":_}}function W(G,F){if(G.getBoundingClientRect)return G.getBoundingClientRect();else{var A={ROOT_TAG:/^body|html$/i,OP_SCROLL:/^(?:inline|table-row)$/i},E=false,I=null,_=G.offsetTop,H=G.offsetLeft,D=G.offsetWidth,B=G.offsetHeight,C=G.offsetParent;if(C!=G)while(C){H+=C.offsetLeft;_+=C.offsetTop;if(R(C,"position").toLowerCase()=="fixed")E=true;else if(C.tagName.toLowerCase()=="body")I=C.ownerDocument.defaultView;C=C.offsetParent}C=G.parentNode;while(C.tagName&&!A.ROOT_TAG.test(C.tagName)){if(C.scrollTop||C.scrollLeft)if(!A.OP_SCROLL.test(P(C)))if(!c||C.style.overflow!=="visible"){H-=C.scrollLeft;_-=C.scrollTop}C=C.parentNode}if(!E){var $=b(I);H-=$.left;_-=$.top}D+=H;B+=_;return{"left":H,"top":_,"right":D,"bottom":B}}}function M($){$=$||V;var B=$[N],A=($.innerWidth)?$.innerWidth:(B[H]&&B[H].clientWidth)?B[H].clientWidth:B.body.offsetWidth,_=($.innerHeight)?$.innerHeight:(B[H]&&B[H].clientHeight)?B[H].clientHeight:B.body.offsetHeight;return{"width":A,"height":_}}function b($){$=$||V;var B=$[N],A=B[H],_=B.body;B=(A&&A.scrollTop!=null&&(A.scrollTop>_.scrollTop||A.scrollLeft>_.scrollLeft))?A:_;return{"top":B.scrollTop,"left":B.scrollLeft}}function D($){try{var _=$?($.srcElement||$.target):null;if($dp.cal&&!$dp.eCont&&$dp.dd&&_!=$dp.el&&$dp.dd.style.display=="block")$dp.cal.close()}catch($){}}function Z(){$dp.status=2}var Q,_;function U(K,C){if(!$dp)return;B();var L={};for(var H in K)L[H]=K[H];for(H in $)if(H.substring(0,1)!="$"&&L[H]===undefined)L[H]=$[H];if(C){if(!J()){_=_||setInterval(function(){if(V[N].readyState=="complete")clearInterval(_);U(null,true)},50);return}if($dp.status==0){$dp.status=1;L.el=T;I(L,true)}else return}else if(L.eCont){L.eCont=$dp.$(L.eCont);L.el=T;L.autoPickDate=true;L.qsEnabled=false;I(L)}else{if($.$preLoad&&$dp.status!=2)return;var F=D();if(Y.event===F||F){L.srcEl=F.srcElement||F.target;F.cancelBubble=true}L.el=L.el=$dp.$(L.el||L.srcEl);if(!L.el||L.el["My97Mark"]===true||L.el.disabled||($dp.dd&&P($dp.dd)!="none"&&$dp.dd.style.left!="-970px")){try{if(L.el["My97Mark"])L.el["My97Mark"]=false}catch(A){}return}if(F&&L.el.nodeType==1&&!a(L.el.initcfg,K)){$dp.unbind(L.el);E(L.el,F.type=="focus"?"onclick":"onfocus",function(){U(K)});L.el.initcfg=K}I(L)}function J(){if(S&&V!=Y&&V[N].readyState!="complete")return false;return true}function D(){if(G){func=D.caller;while(func!=null){var $=func.arguments[0];if($&&($+"").indexOf("Event")>=0)return $;func=func.caller}return null}return event}}function R(_,$){return _.currentStyle?_.currentStyle[$]:document.defaultView.getComputedStyle(_,false)[$]}function P(_,$){if(_)if($!=null)_.style.display=$;else return R(_,"display")}function I(G,_){var D=G.el?G.el.nodeName:"INPUT";if(_||G.eCont||new RegExp(/input|textarea|div|span|p|a/ig).test(D))G.elProp=D=="INPUT"?"value":"innerHTML";else return;if(G.lang=="auto")G.lang=S?navigator.browserLanguage.toLowerCase():navigator.language.toLowerCase();if(!G.eCont)for(var C in G)$dp[C]=G[C];if(!$dp.dd||G.eCont||($dp.dd&&(G.getRealLang().name!=$dp.dd.lang||G.skin!=$dp.dd.skin))){if(G.eCont)E(G.eCont,G);else{$dp.dd=V[N].createElement("DIV");$dp.dd.style.cssText="position:absolute";V[N].body.appendChild($dp.dd);E($dp.dd,G);if(_)$dp.dd.style.left=$dp.dd.style.top="-970px";else{$dp.show();B($dp)}}}else if($dp.cal){$dp.show();$dp.cal.init();if(!$dp.eCont)B($dp)}function E(K,J){var I=V[N].domain,F=false,G="<iframe hideFocus=true width=9 height=7 frameborder=0 border=0 scrolling=no src=\"about:blank\"></iframe>";K.innerHTML=G;var _=$.$langList,D=$.$skinList,H;try{H=K.lastChild.contentWindow[N]}catch(E){F=true;K.removeChild(K.lastChild);var L=V[N].createElement("iframe");L.hideFocus=true;L.frameBorder=0;L.scrolling="no";L.src="javascript:(function(){var d=document;d.open();d.domain='"+I+"';})()";K.appendChild(L);setTimeout(function(){H=K.lastChild.contentWindow[N];C()},97);return}C();function C(){var _=J.getRealLang();K.lang=_.name;K.skin=J.skin;var $=["<head><script>","","var doc=document, $d, $dp, $cfg=doc.cfg, $pdp = parent.$dp, $dt, $tdt, $sdt, $lastInput, $IE=$pdp.ie, $FF = $pdp.ff,$OPERA=$pdp.opera, $ny, $cMark = false;","if($cfg.eCont){$dp = {};for(var p in $pdp)$dp[p]=$pdp[p];}else{$dp=$pdp;};for(var p in $cfg){$dp[p]=$cfg[p];}","doc.oncontextmenu=function(){try{$c._fillQS(!$dp.has.d,1);showB($d.qsDivSel);}catch(e){};return false;};","</script><script src=",A,"lang/",_.name,".js charset=",_.charset,"></script>"];if(F)$[1]="document.domain=\""+I+"\";";for(var C=0;C<D.length;C++)if(D[C].name==J.skin)$.push("<link rel=\"stylesheet\" type=\"text/css\" href=\""+A+"skin/"+D[C].name+"/datepicker.css\" charset=\""+D[C].charset+"\"/>");$.push("<script src=\""+A+"calendar.js\"></script>");$.push("</head><body leftmargin=\"0\" topmargin=\"0\" tabindex=0></body></html>");$.push("<script>var t;t=t||setInterval(function(){if(doc.ready){new My97DP();$cfg.onload();$c.autoSize();$cfg.setPos($dp);clearInterval(t);}},20);</script>");J.setPos=B;J.onload=Z;H.write("<html>");H.cfg=J;H.write($.join(""));H.close()}}function B(J){var H=J.position.left,C=J.position.top,D=J.el;if(D==T)return;if(D!=J.srcEl&&(P(D)=="none"||D.type=="hidden"))D=J.srcEl;var I=W(D),$=F(Y),E=M(V),B=b(V),G=$dp.dd.offsetHeight,A=$dp.dd.offsetWidth;if(isNaN(C))C=0;if(($.topM+I.bottom+G>E.height)&&($.topM+I.top-G>0))C+=B.top+$.topM+I.top-G-2;else{C+=B.top+$.topM+I.bottom;var _=C-B.top+G-E.height;if(_>0)C-=_}if(isNaN(H))H=0;H+=B.left+Math.min($.leftM+I.left,E.width-A-5)-(S?2:0);J.dd.style.top=C+"px";J.dd.style.left=H+"px"}}})()件
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值