tips

  1. maven构建项目时指定jdk版本

 

<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<configuration>
				<source>1.6</source>
				<target>1.6</target>
			</configuration>
		</plugin>
	</plugins>
</build>

未分类 Comments(1) 2013年3月02日 20:33

Debian 安装nginx

1. 下载最新版本的nginx包,我下载的是1.0.1版本。

http://www.nginx.org/en/download.html

2. 解压

tar zxvf nginx-1.0.1.tar.gz 

3. 进入解压后的nginx目录中

# cd nginx-1.0.1 // 进入程序目录
# apt-get install build-essential  // 安装编译环境
# apt-get install libpcre3-dev  // 安装PCRE库
# apt-get install libssl-dev   // 安装Openssl库

4. 准备工作完成以后,就可以开始安装了

a) 编译:

# ./configure --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_flv_module

如果编译最后出现类似下面的信息,表示编译已经成功:

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + md5: using OpenSSL library
  + sha1 library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/etc/nginx"
  nginx configuration file: "/etc/nginx/nginx.conf"
  nginx pid file: "/var/run/nginx.pid"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

b) 安装

# make
# make install

5. 如果需要更新nginx版本,先按上述1~5的步骤安装好新的nginx,然后运行如下命令进行平滑升级

 

# kill -USR2 `/var/run/nginx.pid`
# kill -QUIT `/var/run/nginx.pid.oldbin`

6. 安全起见,需要隐藏nginx的版本号,方法如下:

1)修改nginx.conf配置:

# vi /etc/nginx/nginx.conf

在http {—}里加上server_tokens off;

2)重新加载配置:

# service nginx reload

 

linux Comments(2) 2011年5月10日 14:08

Debian 安装tomcat

系统环境:Debian 6.0

1. 首先需要安装jdk。有两个方法:一是从源里安装,另一个是从二进制版本安装。

从源里安装的方法比较简单:

apt-get install sun-java6-jdk

如果安装源中没有jdk,则可以从以下网站下载:

http://www.oracle.com/technetwork/indexes/downloads/index.html

下载最新版的jdk-6uxx-linux-i586.bin文件,通过如下命令增加可执行权限,然后执行安装:

chmod +x jdk-6u24-linux-i586.bin
./jdk-6u24-linux-i586.bin

2. 安装完成后,执行以下命令:

mv jdk-6u24-linux-i586 /usr/local/jdk
vi /etc/profile

在profile文件末尾添加如下代码:

JAVA_HOME="/usr/local/jdk"
# JAVA_HOME="/usr/lib/jvm/java-6-sun" # 如果是源安装
CLASS_PATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib"
PATH=".:$PATH:$JAVA_HOME/bin"
CATALINA_HOME="/usr/local/tomcat"
export JAVA_HOME CATALINA_HOME

 可以看到在上面的profile文件中我们事先配置好了CATALINA_HOME。CATALINA_HOME就是tomcat的安装目录,下面我们开始安装tomcat。

 

3. 去http://tomcat.apache.org/网站下载最新版的tomcat,使用如下命令解压,安装:

tar zxvf apache-tomcat-7.0.12.tar.gz
mv apache-tomcat-7.0.12 /usr/local/tomcat
vi /usr/local/tomcat/conf/server.xml

查找appBase="webapps",修改appBase的值为你的网页根目录。

4. 如此,tomcat就安装完毕了。但是需要为tomcat分配专门的用户,因为如果以root身份运行tomcat,tomcat就有了系统权限。所以添加一个独立运行此服务的用户tomcat,登陆设置为nologin,防止他拥用root权限给系统带来安全隐患

useradd -d /usr/local/tomcat -s /usr/sbin/nologin tomcat
chown -R tomcat:tomcat /usr/local/tomcat

5. 安装jsvc使tomcat随系统开机启动

参考http://tomcat.apache.org/tomcat-7.0-doc/setup.html的介绍,tomcat自带了jsvc工具,在tomcat的bin目录下:

cd $CATALINA_HOME/bin
tar xvfz commons-deamon-native.tar.gz
cd commons-daemon-1.0.x-native-src/unix
./configure
make
cp jsvc ../..
cd ../..

需要先安装编译工具才能执行编译命令,安装命令为:

apt-get install gcc make

如果执行没有出错,jsvc就安装成功了!

6. 设置启动脚本

在$CATALINA_HOME/bin/commons-daemon-1.0.x-native-src/unix/samples目录下有一个Tomcat7.sh文件,将其复制到/etc/init.d/m目录下并命名为tomcat:

cp /usr/local/tomcat/bin/commons-daemon-1.0.5-native-src/unix/samples/Tomcat7.sh /etc/init.d/tomcat

根据实际情况修改该文件,使其适合你的环境。

7. 修改运行级别

update-rc.d tomcat defaults

8. OK!

linux Comments(1) 2011年4月14日 15:25

设置mysql自增字段的初始值

ALTER TABLE pay_records AUTO_INCREMENT 10000001;

未分类 Comments(1) 2011年3月17日 19:06

Debian下设置Mysql字符集消除中文乱码

1. 配置/etc/mysql/my.cnf文件

因为客户端使用的是gbk编码,所以在[client]和[mysqld]下都添加如下设置:

default-character-set=gbk

2. 建表时使用如下设置:


CREATE TABLE IF NOT EXISTS `signon` (
  `id` int(11) NOT NULL auto_increment COMMENT '系统自动生成的自动递增用户ID',
  `username` varchar(16) character set gb2312 NOT NULL COMMENT '用户帐号',
  `passwd` varchar(32) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `qq` (`username`)
) ENGINE=MyISAM  DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;

 

未分类 Comments(2) 2011年3月10日 22:02

ubuntu pdf无法显示中文

sudo apt-get install xpdf-common cmap-adobe-gb1 cmap-adobe-cns1 poppler-data

未分类 Comments(1) 2011年2月01日 01:41

svn错误解决方案

 

Error1: Can’t open ‘/home/svn/db/txn-current-lock’: Permission denied

这种错误比较常见,而且一开始我一直以为是自己没有配置好认证权限的问题,我反复的配置10,11两步,结果还是没解决,我在windows下用tortoiseSVN客户端一直无法commit和添加文件,老是弹出这个错误。可我在linux下可以用#svn import …. 这个命令,我一直很纳闷,后来经过琢磨和上网搜索,终于解决。问题在于我的/home/svn目录下的一切子目录和文件都是属于root用户的,而我每次在linux下也是以root 用户import的,所以一直没有问题。可在windows从客户端访问就有问题了。

解决办法: 把/home/svn目录下的所有文件和子目录添加读写权限

#chmod  –R  o+rw  /home/svn

Okay, 问题解决。现在可以方便从windows下面checkout和commit了。

未分类 Comments(1) 2011年1月28日 07:25

ssh远程连接服务器失败

在Ubuntu下远程连接Linux服务器时失败,出现如下错误:


thuram@thuram-H55M-S2:~$ ssh root@192.168.18.104
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
f4:96:da:0e:e4:57:1a:be:75:78:69:6a:9b:2d:4a:a6.
Please contact your system administrator.
Add correct host key in /home/thuram/.ssh/known_hosts to get rid of this message.
Offending key in /home/thuram/.ssh/known_hosts:1
RSA host key for 192.168.18.104 has changed and you have requested strict checking.
Host key verification failed.
 

解决方法很简单,只需删除~/.ssh/known_hosts文件即可。

linux Comments(8) 2011年1月24日 07:46

Ubuntu下声卡不发声解决方案一例

刚装的ubuntu 10.10没有声音,google了一下,照如下步骤走了一遍,问题解决,现将方法粘贴如下:

 

去除系统自带声音模块
sudo apt-get –purge remove linux-sound-base alsa-base alsa-utils
重新安装,并安装最新模块:
sudo apt-get install linux-sound-base alsa-base alsa-utils
重启后可能不能进入gdm图型登录窗口。
ubuntu 的用户输入
sudo apt-get install gdm ubuntu-desktop
Xubuntu的用户输入:
sudo apt-get install gdm xubuntu-desktop
重启一下。
安装alsa模块:
sudo apt-get install build-essential linux-headers-$(uname -r) module-assistant alsa-source
配置一次
sudo dpkg-reconfigure alsa-source
将会有一个蓝色窗口询问你是否安装。
选择yes
接着会询问你安装的声卡型号。
如果你清楚你要安装的型号就选你要装的,但个人推荐全选。
如果没有出错的话就是成功了。
请再重启你的电脑就可以听到优美的声音了。 

未分类 Comments(1) 2011年1月23日 03:45

Debian下配置MySQL远程访问

1.修改/etc/mysql/my.conf文件,将bind-address绑定到MySQL服务器的实际IP地址:

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
language        = /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 192.168.18.104

2.使用root登录mysql执行如下命令:

 

grant all on test.* to user@'%' identified by 'password';
grant all on test.* to user@localhost identified by 'password';

其中test为你要远程访问的数据库,user是你使用的用户名,password为该用户的密码。

linux Comments(65) 2011年1月10日 06:02