4 2010

如何在Linux上安装Squid代理服务器软件

1、获取Squid源代码

wget ftp://ftp.cuhk.edu.hk/pub/packages/info-systems/www/squid/squid-3.1.1.tar.gz

2、编译及安装

tar -zxvf squid-3.1.1.tar.gz
cd squid-3.1.1
./configure --prefix=/usr/local/squid --enable-arp-acl --enable-linux-netfilter --enable-pthreads --enable-err-language="Simplify_Chinese" --enable-default-err-language="Simplify_Chinese" --enable-auth="basic" --enable-baisc-auth-helpers="NCSA" --enable-underscore
make
make install

3、编译生成Squid认证程序ncsa_auth

cd helpers/basic_auth/NCSA/
make
cp ncsa_auth /usr/sbin/
cd ../../../

4、使用htpasswd来生成用户名/密码对应的文件

htpasswd -c /usr/local/squid/password hijava

在输入两边密码后,一个hijava用户就生成了。如果以后需要添加用户,把上面的命令去掉-c参数再运行即可。

5、修改Squid配置文件

cd /usr/local/squid/
mv -f etc/squid.conf etc/squid.conf.bak
vi etc/squid.conf

插入如下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
acl SSL_ports port 443
acl Safe_ports port 80		# http
acl Safe_ports port 21		# ftp
acl Safe_ports port 443		# https
acl Safe_ports port 70		# gopher
acl Safe_ports port 210		# wais
acl Safe_ports port 1025-65535	# unregistered ports
acl Safe_ports port 280		# http-mgmt
acl Safe_ports port 488		# gss-http
acl Safe_ports port 591		# filemaker
acl Safe_ports port 777		# multiling http
acl CONNECT method CONNECT
 
auth_param basic program /usr/sbin/ncsa_auth /usr/local/squid/password
acl normal proxy_auth REQUIRED
http_access allow normal
 
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
 
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
 
# And finally deny all other access to this proxy
http_access deny all
 
# Squid normally listens to port 3128
http_port 3128
 
# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?
 
# Uncomment and adjust the following to add a disk cache directory.
#cache_dir null /tmp
 
# Leave coredumps in the first cache dir
coredump_dir /usr/local/squid/var/cache
 
# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
refresh_pattern .		0	20%	4320

6、启动Squid

 ./sbin/squid

参考:http://wiki.ubuntu.org.cn/Squid%E9%85%8D%E7%BD%AE%E8%AF%A6%E8%A7%A3

十一 2 2008

[转]ubuntu下安装JDK

1、安装jdk1.5 java开源,对于桌面程序的性能提高的很显著。
(1)从sun下载jdk-1_5_0_10-linux-i586.bin

(2)默认的安装目录是/opt/jdk1.6.0
mv ./jdk-1_5_0_10-linux-i586.bin /opt/

(3)
chmod u+x jdk-1_5_0_10-linux-i586.bin

sudo ./jdk-1_5_0_10-linux-i586.bin

或者直接执行:

sh ./jdk-1_5_0_10-linux-i586.bin

选择yes安装

(4)配置classpath,修改所有用户的环境变量

sudo gedit /etc/profile

在文件最后添加
#set java environment
JAVA_HOME=/opt/jdk1.5.0_10
export JRE_HOME=/opt/jdk1.5.0_10/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

(5)重新启动,用命令测试jdk的版本
java -version

如果出现
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing)
则表示安装成功