Posted by zuzhihui in 最新消息 on 2011/07/20 with No Comments
瑞豪开源的CentOS 6 VPS上线了!客户在购买VPS或者Rebuild的时候可以选择CentOS 6 VPS了。CentOS是Hosting圈内用的最广泛的操作系统,很受客户欢迎。
Posted by yar999 in Linux技术 on 2010/11/18 with No Comments
本文介绍怎样给CentOS的VPS或者独立主机增加新的IP地址。
增加新IP需要知道的是新的IP地址和子网掩码,其他信息(比如网关)都不再需要了。假如需要增加的ip是177.252.202.179,子网掩码是255.255.255.248
在目录/etc/sysconfig/network-scripts/ 下面是一些网卡的配置文件,新增加一个额外IP地址,需要在这个目录下新增加一个新网卡配置文件。额外IP的网卡配置文件的文件名是有要求的,必须是ifcfg-eth0:XXXX的形式,其中eth0代表物理网卡,eth0:XXXX 代表是附加在这个物理网卡上的虚拟网卡,XXXX可以是1到4位的字符串,字符串内容可以包含任意字母和数字。
ssh登录到centos之后
cd /etc/sysconfig/network-scripts/
vi ifcfg-eth0:1
然后输入下面的内容
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=177.252.202.179
NETMASK=255.255.255.248
ONBOOT=yes
然后保存退出,执行
ifup eth0:1
就可以启用177.252.202.179这个新增的ip
如果您需要增加第二个ip,您可以执行
vi ifcfg-eth0:2
然后输入,下面的内容
DEVICE=eth0:2
BOOTPROTO=static
IPADDR=177.252.202.179
NETMASK=255.255.255.248
ONBOOT=yes
然后执行下面的命令,启用177.252.202.179这个ip
ifup eth0:2
网卡配置文件中的变量名例如DEVICE等等,都需要大写。配置不同的网卡只需要修改
DEVICE(设备名字) IPADDR(ip地址) NETMASK(子网掩码)这3项就可以了
Posted by zuzhihui in Linux技术 on 2009/10/20 with No Comments
CentOS的时区配置文件是:/etc/sysconfig/clock 。 这个配置文件里面支持UTC,ARC,SRM,ZONE这几个配置选项,关于这几个配置选项详解如下:
这个配置文件里面的参数和 hwclock 命令关系很大,系统在启动的时候读取 /etc/sysconfig/clock 文件的内容,根据这些内容调用 hwclock 命令。
Posted by zuzhihui in vps技术 on 2009/05/08 with 1 Comment
此笔记,基于 “程序员小辉”的安装笔记修改 ——————————————————————————————————————–
Server 端的环境
Client 端的环境:
二. OpenVPN 服务端安装过程
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2. 03.tar.gz wget http://openvpn.net/release/openvpn-2.1_rc15.tar.gz
yum install -y openssl-devel
tar zxvf lzo-2.03.tar.gz
cd lzo-2.03
./configure
make
make install
cd ..
tar zxvf openvpn-2.1_rc15.tar.gz
cd openvpn-2.1_rc15
./configure
make
make install
cd ..
cp /root/openvpn-2.1_rc15/easy-rsa/ -r /etc/openvpn
初始化PKI
cd /etc/openvpn/2.0/#可以设置下OpenVPN参数(也可以修改vars文件来配置)
export D=`pwd`
export KEY_CONFIG=$D/openssl.cnf
export KEY_DIR=$D/keys
export KEY_SIZE=1024
export KEY_COUNTRY=CN
export KEY_PROVINCE=GD
export KEY_CITY=SZ
export KEY_ORG="dvdmaster"
export KEY_EMAIL="support@cooldvd.com"
#也可以不用设置直接执行下面的命令
. vars
创建证书颁发机构(CA)
./clean-all
./build-ca
Generating a 1024 bit RSA private key
................
........
writing new private key to 'ca.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [CN]:
State or Province Name (full name) [GD]:
Locality Name (eg, city) [SZ]:
Organization Name (eg, company) [dvdmaster]:
Organizational Unit Name (eg, section) []:dvdmaster
Common Name (eg, your name or your server's hostname) []:server
Email Address [support@cooldvd.com]:
建立server key
./build-key-server server
Generating a 1024 bit RSA private key
......
....................
writing new private key to 'server.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [CN]:
State or Province Name (full name) [GD]:
Locality Name (eg, city) [SZ]:
Organization Name (eg, company) [dvdmaster]:
Organizational Unit Name (eg, section) []:dvdmaster
Common Name (eg, your name or your server's hostname) []:server
Email Address [support@cooldvd.com]:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:abcd1234
An optional company name []:dvdmaster
Using configuration from /etc/openvpn/2.0/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName ::'CN'
stateOrProvinceName ::'GD'
localityName ::'SZ'
organizationName ::'dvdmaster'
organizationalUnitName::'dvdmaster'
commonName ::'server'
emailAddress ::'support@cooldvd.com'
Certificate is to be certified until Mar 19 08:15:31 2016 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
生成客户端 key
./build-key client1
Generating a 1024 bit RSA private key
.....
......
writing new private key to 'client1.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [CN]:
State or Province Name (full name) [GD]:
Locality Name (eg, city) [SZ]:
Organization Name (eg, company) [dvdmaster]:
Organizational Unit Name (eg, section) []:dvdmaster
Common Name (eg, your name or your server's hostname) []:client1 #重要: 每个不同的client 生成的证书, 名字必须不同.
Email Address [support@cooldvd.com]:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:abcd1234
An optional company name []:dvdmaster
Using configuration from /etc/openvpn/2.0/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName ::'CN'
stateOrProvinceName ::'GD'
localityName ::'SZ'
organizationName ::'dvdmaster'
organizationalUnitName::'dvdmaster'
commonName ::'client1'
emailAddress ::'support@cooldvd.com'
Certificate is to be certified until Mar 19 08:22:00 2016 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
以此类推建立其他客户端 key
./build-key client2
./build-key client3
注意在进入 Common Name (eg, your name or your server’s hostname) []: 的输入时, 每个证书输入的名字必须不同.
./build-dh
tar zcvf yskeys.tar.gz keys/
mkdir /etc/openvpn/2.0/conf
cp /root/openvpn-2.1_rc15/sample-config-files/server.conf /etc/openvpn/2.0/conf/server.conf
服务端配置文件(server.conf)样例
port 1194
proto udp
dev tun
ca /etc/openvpn/2.0/keys/ca.crt
cert /etc/openvpn/2.0/keys/ovpnser.crt
key /etc/openvpn/2.0/keys/ovpnser.key # This file should be kept secret
dh /etc/openvpn/2.0/keys/dh1024.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 10.8.0.1"
push "dhcp-option DNS 202.103.44.150" #客户端获得的DNS地址
push "dhcp-option DNS 202.103.24.68" #客户端获得的DNS地址
client-to-client
keepalive 10 120
comp-lzo
user nobody
group nobody
persist-key
persist-tun
status openvpn-status.log
verb 3
/usr/local/sbin/openvpn --config /etc/openvpn/2.0/conf/server.conf &
三. OpenVPN GUI For Windows 客户端安装过程
官方下载地址:http://openvpn.net/release/openvpn-2.1_rc15-install.exe
将上面第6步打包的yskeys.tar.gz中的下列证书文件解压到 你的OpenVPN GUI安装路径\OpenVPN\config文件夹下
ca.crt
ca.key
client1.crt
client1.csr
client1.key
把你的OpenVPN GUI安装路径\OpenVPN\sample-config下的client.ovpn文件复制到你的OpenVPN GUI安装路径\OpenVPN\config文件夹下,用记事本打开client.ovpn
#找到remote my-server-1 1194,把my-server-1改成你的ip地址
remote 221.233.59.16 1194
三. OpenVPN 访问外网的设置
echo 1 > /proc/sys/net/ipv4/ip_forward
#为了使CentOS重启后仍然开启路由转发功能我们需要再执行下列命令
sysctl -w net.ipv4.ip_forward=1
#因为我那天CentOS是ADSL拨号上网,所以把出口设置成ppp0,请根据实际情况设置
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o ppp0 -j MASQUERADE
push "dhcp-option DNS 10.8.0.1"
push "dhcp-option DNS 202.103.44.150" #客户端获得的DNS地址
push "dhcp-option DNS 202.103.24.68" #客户端获得的DNS地址
当 client 连接成功后, 在 cmd 下执行 ipconfig /all, 应该有这类似这样的输出:
Ethernet adapter 本地连接 2:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : TAP-Win32 Adapter V9
Physical Address. . . . . . . . . : 00-FF-F2-1A-44-BD
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 10.8.0.6
Subnet Mask . . . . . . . . . . . : 255.255.255.252
Default Gateway . . . . . . . . . : 10.8.0.5
DHCP Server . . . . . . . . . . . : 10.8.0.5
DNS Servers . . . . . . . . . . . : 10.8.0.1
202.103.44.150
202.103.24.68
Lease Obtained. . . . . . . . . . : 2009年5月8日 23:55:06
Lease Expires . . . . . . . . . . : 2010年5月8日 23:55:06
执行
vi /etc/rc.local
然后在最后面加入此行:
/usr/local/sbin/openvpn --config /etc/openvpn/2.0/conf/server.conf &
连接成功之后,去ip138.com上看看外网ip是多少,如果是CentOS系统的外网ip那说明测试成功了~
Posted by zuzhihui in Linux技术 on 2009/04/11 with 5 Comments
socks5代理的功能和作用这里我就不罗嗦了,下面是在CentOS5 VPS下的安装配置的一些笔记
---------------------------------------
1.配置编译环境
yum -y install gcc automake make
2.安装socks5必要的包
yum -y install pam-devel openldap-devel cyrus-sasl-devel openssl-devel
3.下载,编译安装ss5(socks5)
wget http://jaist.dl.sourceforge.net/sourceforge/ss5/ss5-3.6.1-1.tar.gz tar zxvf ss5-3.6.1-1.tar.gz cd ss5-3.6.1 ./configure make make install #启动ss5服务 /etc/init.d/ss5 start
ss5 默认使用1080端口,并允许任何人使用。
我们可以修改 /etc/opt/ss5/ss5.conf 中的
# SHost SPort Authentication # auth 0.0.0.0/0 - - 为 # SHost SPort Authentication # auth 0.0.0.0/0 - u
在 /etc/opt/ss5/ss5.passwd 中添加 用户名和密码 如:
test test
使用用户验证,重启ss5服务
/etc/init.d/ss5 restart
Posted by zuzhihui in vps技术 on 2009/01/02 with No Comments
CentOS中的yum能很方便的更新安装软件包,它能够自动解决rpm包之间的依赖关系,就像Debian中的apt-get一样。 使用yum必须要配置yum源地址,在国内的网络情况下,配置一个速度快的yum源还真不容易。不像Debian的apt源,国内有很多。本文介绍一些我们配置yum源的经验。
以前也以为国内的yum源速度快,但不知实际情况却恰恰相反。国内的一些yum源速度非常慢,yum更新慢的印象都是国内的源造成的。我分析慢原因还是国内的带宽少,这种没有回报的公益事业在国内没有多少人愿意投入,带宽都用来卖给客户赚钱了。
另外国内的yum源非常不稳定,以前常使用的be10的国内yum源,现在经常不能访问。
如果CentOS VPS的位置在国外,配置有一个国外的IP地址,那么使用缺省的yum源设置应该就很好。就像我们的美国VPS,使用的都是缺省的yum源,速度相当快
国内的CentOS VPS使用缺省的yum源速度往往很慢,因为缺省的yum源是这样设置的:
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
http://mirrorlist.centos.org这个URL能够自动返回VPS所在地附近的一些yum源,而这些yum源都是位于中国大陆或者台湾等地区,这些地区的源访问起来非常慢。为了解决这个问题,我们只需在mirrorlist这一行的尾部添加如下字符串即可:
&cc=us
解释一下上面的字符串:&是用来连接URL中的参数的;cc是http://mirrorlist.centos.org这个URL能接受的一个参数,代表地区的意思;us代表美国。这样,一个完整的mirrorlist配置应该如下:
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&cc=us
这样就能够直接访问美国地区的那些yum源,这些yum源从中国访问也是很快的。
附上整个的/etc/yum.repos.d/CentOS-Base.repo文件供参考:
[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&cc=us gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&cc=us gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #packages used/produced in the build but not released [addons] name=CentOS-$releasever - Addons mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons&cc=us gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&cc=us gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&cc=us gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
更简单的,可以用root在CentOS 5 VPS下执行如下命令更新yum源:
wget http://rashost.com/download/yum.sh sh yum.sh
Posted by zuzhihui in Linux技术 on 2008/09/12 with No Comments
在Debian VPS下用apt-get来管理软件包,非常方便。CentOS VPS下用yum来管理软件包,同样也很方便,yum是redhat RHEL和fedora采用的包管理方式。本文列举一些常用的yum用法。
比如:yum install httpd
命令:yum remove
命令:yum list updates
命令:yum check-update
命令:yum update
命令:yum update httpd
命令:yum list
命令:yum list installed
命令:yum info httpd
命令:yum search mysql
命令:yum clean packages
命令:yum clean headers
命令:yum clean oldheaders
命令:yum clean all
Posted by zuzhihui in Linux技术 on 2008/07/26 with No Comments
在CentOS VPS下运行tzselect可以修改时区,但不是永久的解决方案。最好的办法是:
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
这个方法在Debian VPS和Ubuntu VPS下是否可以,本人还没有去验证。
Posted by zuzhihui in Linux技术 on 2008/07/08 with No Comments
AWStats是在一个很流行的基于Perl的WEB日志分析工具。本文讲述CentOS5下nginx怎么安装配置awstats。
由于CentOS5没有自带awstats,所以我们必须手工下载awstats的RPM包,从awstats的主页上,找到下载地址http://dfn.dl.sourceforge.net/sourceforge/awstats/awstats-6.7-1.noarch.rpm 并下载到CentOS5的任意一个目录下。执行如下命令安装:
rpm -ivh awstats-6.7-1.noarch.rpm
awstats被安装在了 /usr/local/awstats/ 目录下
待续
Posted by zuzhihui in Linux技术 on 2008/06/01 with 2 Comments
(后注:CentOS VPS下最新的nginx解决方案,请参考 http://rashost.com/blog/centos5-vps-nginx-solution2 )
这篇文章已经介绍了怎样编译Nginx的RPM包 下载RPM包:
wget http://rashost.com/local/nginx-0.6.35-2.i386.rpm rpm -ivh nginx-0.6.35-2.i386.rpm chkconfig nginx on /etc/init.d/nginx start
然后访问本机的80端口,就可以看到页面了,这表示安装一切正常。 修改/etc/nginx/nginx.conf文件中的server_name部分,修改IP地址为本机IP地址:
server_name 192.168.0.104;
修改/etc/nginx/nginx.conf文件的index部分,加入index.php
index index.php index.html index.htm;
安装php和fastcgi
wget ftp://rpmfind.net/linux/dag/redhat/el5/en/i386/dag/RPMS/lighttpd-fastcgi-1.4.18-1.el5.rf.i386.rpm
wget ftp://rpmfind.net/linux/dag/redhat/el5/en/i386/dag/RPMS/lighttpd-1.4.18-1.el5.rf.i386.rpm
rpm -ivh lighttpd*.rpm # CentOS不自带lighttpd, 我们只好从别处下载,安装
chkconfig --del lighttpd #我们只用到lighttpd中的一个文件,不需要lighttpd开机自启动
yum install -y php-cgi php-mysql
spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u nginx -f /usr/bin/php-cgi
cd /usr/share/nginx/html/
echo "< ? phpinfo(); ?>" >i.php
然后修改/etc/nginx/nginx.conf文件的如下部分:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
重启nginx:
/etc/init.d/nginx stop
/etc/init.d/nginx start
然后访问本机的i.php文件 http://192.168.1.104/i.php 应该能正确的到php的配置信息,这就成功了! 最后要注意的是,在CentOS下nginx的默认html目录是/usr/share/nginx/html,这个和ubuntu下不同 另外,为了让php cgi程序开机自启动,请在/etc/rc.local文件的最后加入下面这行:
spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u nginx -f /usr/bin/php-cgi
近期评论