心随所致,梦想为开。Follow the Dreams & Heart.
Archive for October, 2009
试用基于Xen的VPS(2):配置squid服务器
Oct 31st
前面总结了 基于Xen的VPS的web服务器的配置:ubuntu+nginx+php,下面记录下squid服务器的配置。
安装很简单:apt-get install squid
配置中的重点是打开用户验证。
通过htpasswd建立用户名密码文件,然后在squid的配置文件中设置。
http_port 3128 auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid.password auth_param basic children 5 auth_param basic realm Hamo’s Private Proxy auth_param basic credentialsttl 4 hours
acl all src all acl manager proto cache_object acl localhost src 127.0.0.1/32 acl to_localhost dst 127.0.0.0/8 acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 # RFC1918 possible internal network acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl SSL_ports port 443 # https acl SSL_ports port 563 # snews acl SSL_ports port 873 # rsync 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 Safe_ports port 631 # cups acl Safe_ports port 873 # rsync acl Safe_ports port 901 # SWAT acl purge method PURGE acl CONNECT method CONNECT
acl normal proxy_auth REQUIRED
http_access allow manager localhost http_access deny manager http_access allow purge localhost More >
试用基于Xen的VPS(1):ubuntu+nginx+php
Oct 31st
跟踪vps已经很久了,但是因为需要特殊端口开服务,所以符合条件的多为Xen平台的vps。众多比较之后选择了vpslink在西雅图机房,速度还不错。 因为对系统性能要求很低,所以选择了Link-1,2.5G硬盘、64M内存、100GB流量、1个独立ip。 使用优惠码9DMM7R可以有10%的折扣,vpslink.com。当然也可以找更大折扣的优惠码,但是一般只限3个月内。 在vpslink后台安装os,选择ubuntu9.04,一分钟后系统装完了,ssh登录root。 工作1:配置web服务器 为了调试程序,支持php的web服务器还是需要的。内存太小所以抛弃了一直以来的apache,改用nginx,并且通过fast-cgi来支持php。vpslink提供了ubuntu的源镜像,速度没的说。
(1)一步到位,安装nginx和php
apt-get install nginx php5-cli php5-cgi php5-mysql
(2)因为需要spawn-fcgi来启动fast-cgi,所以安装lighttpd,并设置为开机不启动
apt-get install lighttpd
(3)配置fast-cgi
在/etc/init.d/下建立php-cgi的服务文件,简单起见,可以直接copy nginx的来修改
cp nginx php-cgi
vi php-cgi,修改对应参数
DAEMON=/usr/bin/spawn-fcgi DAEMON_OPTS=”-a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi”
修改stop时的动作为:pkill -9 php-cgi
保存,退出。
(4) 配置nginx,打开php支持
vi /etc/nginx/sites-available/default
index中增加index.php,并将相关php部分注释取消,注意需要修改fastcgi_param的路径
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name; include /etc/nginx/fastcgi_params; }
(5) 启动服务
/etc/init.d/php-cgi start
/etc/init.d/nginx start
web服务器就配置完了。
工作2:配置squid代理服务器
这才是主要目的,要不也不用特意选择Xen的vps了。下回再说。