http://pve.proxmox.com/wiki/OpenVZ_Console

官方给文档了,这里记录一下:

Centos 6

Login via SSH (or use the VNC "Shell") to your Proxmox VE host and 'vzctl enter CTID' the container:

List all running container:

proxmox-ve:~# vzlist
     CTID      NPROC STATUS    IP_ADDR         HOSTNAME
      108         23 running   192.168.9.20    ubuntu-1204.proxmox.com
      109         18 running   192.168.9.21    centos63-64.proxmox.com
      111         15 running   192.168.9.23    centos5-64.proxmox.com
      114         14 running   192.168.9.30    deb6-32.proxmox.com
      115         15 running   192.168.9.31    deb7-32.proxmox.com
      122         14 running   192.168.9.36    deb5.proxmox.com

Enter the container:

proxmox-ve:~# vzctl enter 109
root@centos63-64:/# nano /etc/init/tty.conf

Change/Create the file that it looks exactly like this:

# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]

stop on runlevel [!2345]

respawn
exec /sbin/agetty -8 tty1 38400

Save the changes and shutdown/start the container via Console.

参考文章:http://www.miui.com/thread-442048-1-1.html

 

环境:笔记本电脑,win7系统
设备:小米手机(强君的)
手机操作:打开usb绑定和wifi热点,设置wifi热点,配置ssid名和密码
PC操作:系统会自动安装usb驱动,生成网卡,本地连接2 设置IP为192.168.42.1 掩码255.255.255.0,然后在本地连接(也就是能上网的网卡)右键属性设置共享,允许本地连接2通过它上网。
如果无法识别驱动,装个豌豆荚就行了。
手机操作:安装quicksshd,豌豆荚有下载
PC操作:远程通过putty连接到手机,手机的IP在quciksshd上可以查到
PUTTY操作:
busybox sysctl -a | grep ip_forward
#查看是否存在net.ipv4.ip_forward = 1
#如果不存在
echo 1 >/proc/sys/net/ipv4/ip_forward
#将如下写成shell,比如share_aphot.sh
busybox route add default gw 192.168.42.1
iptables -F
iptables -t nat -A POSTROUTING -s 192.168.43.0/24 -o usb0 -j MASQUERADE
然后赋予执行权限
chmod 777 share_aphot.sh
运行,就能上网了。

将来如果需要手机上网的时候,在putty里执行share_aphot.sh就行了,如果为了方便可以在手机上安装超级终端,登录进去执行su获得root权限再执行share_aphot.sh。

转:http://apps.hi.baidu.com/share/detail/14819035

如果你打算使用Apache httpd Web服务器,请看这里。

一、系统约定

软件源代码包存放位置 /usr/local/data-original

源码包编译安装位置(prefix) /usr/local/software_name

脚本以及维护程序存放位置 /usr/local/sbin

MySQL 数据库位置 /var/lib/mysql(可按情况设置)

网站根目录 /home/www/wwwroot(可按情况设置)

虚拟主机日志根目录 /home/www/logs(可按情况设置)

运行账户 www:www

二、系统环境部署及调整

1、检查系统是否正常

# more /var/log/messages (检查有无系统级错误信息)

# dmesg (检查硬件设备是否有错误信息)

# ifconfig(检查网卡设置是否正确)

# ping www.163.com (检查网络是否正常)

# cat /proc/cpuinfo (检查CPU频率是否正常)

# top (按1检测CPU核数是否正常,内存大小是否正常)

2、关闭不需要的服务

# ntsysv

以下仅列出需要启动的服务,未列出的服务一律推荐关闭:

atd

crond

irqbalance

microcode_ctl

network

sendmail

sshd

syslog

关闭SElinux:修改/etc/selinux/config文件中的SELINUX= 为 disabled

3、更换yum国内源

# cd /etc/yum.repos.d

# mv CentOS-Base.repo CentOS-Base.repo.save

# wget http://centos.ustc.edu.cn/CentOS-Base.repo.5

# mv CentOS-Base.repo.5 CentOS-Base.repo

# yum clean all

4、服务器时间检查和设置

#data (检查时间是否正确,是否是中国时间CST)

#cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime (如果时区不对,则执行,时间正常的跳过)

#yum -y install ntp (安装ntp对时工具)

#chkconfig ntpd on (让对时服务开机启动)

5、使用 yum 对系统进行更新并且安装必要软件包

#yum update –y

  1. #yum -y install make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

复制代码

6. 重新启动系统

# init 6

三、编译安装L.A.M.P环境

1、下载软件(截止到09年10月的最新版本)

# cd /usr/local/data-original

#wget http://sysoev.ru/nginx/nginx-0.7.63.tar.gz

#wget http://download.scientificlinux.net/nginx

#wget http://download.scientificlinux.net/php-fpm.conf

#wget http://download.scientificlinux.net/nginx.conf

#wget http://download.scientificlinux.net/fcgi.conf

#wget http://download.scientificlinux.net/php-5.2.10.tar.gz

#wget http://download.scientificlinux.net/php-5.2.10-fpm-0.5.13.diff.gz

#wget http://download.scientificlinux. ... glibc23-i386.tar.gz (32位系统)

#wget http://download.scientificlinux. ... ibc23-x86_64.tar.gz (64位系统)

#wget http://download.scientificlinux. ... i686-glibc23.tar.gz (32位系统)

#wget http://download.scientificlinux. ... 6_64-glibc23.tar.gz (64位系统)

2、安装MySQL

cd /usr/local/data-original

tar zxvf mysql-5.1.39-linux-i686-glibc23.tar.gz

mv mysql-5.1.39-linux-i686-glibc23 /usr/local/

ln -s /usr/local/mysql-5.1.39-linux-i686-glibc23/ /usr/local/mysql

groupadd mysql

useradd -g mysql mysql

chown -R mysql:mysql /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql-5.1.39-linux-i686-glibc23/

cd /usr/local/mysql

./scripts/mysql_install_db --user=mysql

cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod 755 /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig --level 3 mysqld on

cp ./support-files/my-huge.cnf /etc/my.cnf

mv /usr/local/mysql/data /var/lib/mysql

chown -R mysql:mysql /var/lib/mysql

编辑/etc/my.cnf

在 [mysqld] 段增加

  1. datadir = /var/lib/mysql
  2. skip-innodb
  3. wait-timeout = 10
  4. max_connections = 512
  5. max_connect_errors = 10000000

复制代码

在 [mysqld] 段修改

  1. max_allowed_packet = 16M
  2. thread_cache_size = CPU个数*2

复制代码

将 log-bin 注释

service mysqld start

bin/mysqladmin -u root password 'password_for_root'

其中引号内的password_for_root是要设置的root密码

3、安装Nginx

cd /usr/local/data-original/

tar zxvf nginx-0.7.63.tar.gz

cd nginx-0.7.63

./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_realip_module --with-http_addition_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module

make

make install

cp /usr/local/data-original/nginx /etc/init.d/nginx

chmod 755 /etc/init.d/nginx

chkconfig --add nginx

chkconfig nginx on

4、安装PHP和Zend

cd /usr/local/data-original

tar zxvf php-5.2.10.tar.gz

gzip -cd php-5.2.10-fpm-0.5.13.diff.gz | patch -d php-5.2.10 -p1

cd php-5.2.10

./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/etc/cgi --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-magic-quotes --with-mysql=/usr/local/mysql --with-pear --enable-sockets --with-ttf --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --enable-sysvsem --enable-sysvshm --with-libxml-dir=/usr --enable-force-cgi-redirect --enable-fastcgi --with-xmlrpc --enable-zip --enable-fpm

make

make install

mkdir -p /usr/local/etc/cgi/

cp php.ini-dist /usr/local/etc/cgi/php.ini

mv -f /usr/local/data-original/php-fpm.conf /usr/local/php5/etc/php-fpm.conf

groupadd www

useradd -g www www

echo 'ulimit -SHn 65535' >> /etc/rc.local

echo '/usr/local/php5/sbin/php-fpm start' >> /etc/rc.local

cd /usr/local/data-original

tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz

cd ZendOptimizer-3.3.3-linux-glibc23-i386

./install

(注意第一个要填的路径是Zend安装路径,第二个是php.ini所在的路径,即/usr/local/etc/cgi)

(不要选重启apache)

5、启动Nginx和php

mv -f /usr/local/data-original/fcgi.conf /usr/local/nginx/conf/

cp -f /usr/local/data-original/nginx.conf /usr/local/nginx/conf/nginx.conf

mkdir -p /home/www/wwwroot

ulimit -SHn 65535

/usr/local/php5/sbin/php-fpm start

service nginx start

在/home/www/wwwroot放入一个index.php,内容为

打开浏览器访问,即可看到phpinfo页面

6、设置系统防火墙

编辑/usr/local/sbin/fw.sh

复制以下内容进去

  1. #!/bin/bash
  2. # Stop iptables service first
  3. service iptables stop
  4. # Load FTP Kernel modules
  5. /sbin/modprobe ip_conntrack_ftp
  6. /sbin/modprobe ip_nat_ftp
  7. # Inital chains default policy
  8. /sbin/iptables -F -t filter
  9. /sbin/iptables -P INPUT DROP
  10. /sbin/iptables -P OUTPUT ACCEPT
  11. # Enable Native Network Transfer
  12. /sbin/iptables -A INPUT -i lo -j ACCEPT
  13. # Accept Established Connections
  14. /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  15. # ICMP Control
  16. /sbin/iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
  17. # WWW Service
  18. /sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  19. # FTP Service
  20. /sbin/iptables -A INPUT -p tcp --dport 21 -j ACCEPT
  21. # SSH Service
  22. /sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT

复制代码

退出编辑,执行以下命令

# chmod 755 /usr/local/sbin/fw.sh
# echo '/usr/local/sbin/fw.sh' >> /etc/rc.local
# /usr/local/sbin/fw.sh

PS:这篇优化总结不错,适合于小内存的VPS服务器。

CentOS 是免费的,并且有着 RHEL 的稳定,因此深受各大 hosting 服务商支持,几乎所有 Linux VPS 都支持 CentOS。

一般来说如果 VPS 配置较高我会选 CentOS,配置低的话就选 Debian,当然这是个人偏好,大多数 Linux VPS 服务商也会提供 Gentoo,不过每次安装程序,升级都要编译会消耗很多资源,耗时,而且性能没有明显提高,不推荐给配置低的 VPS。

VPS 服务商一般给的操作系统版本都是最小安装版本,或者优化过的版本。每个VPS服务商提供的版本都可能不同,安装 CentOS 的系统最低要求至少 64MB 内存(纯文字界面),1GB 硬盘空间。

安装和升级系统

1、登录 VPS 安装 CentOS 5。

2、安装完毕后马上升级整个系统。

yum update

有了一个干净的系统以后,剩下来就是加强和优化 Linux。

删除不必要的软件包,服务,用户,文件等

3、删除不需要的软件包。

yum remove Deployment_Guide-en-US finger cups-libs cups
bluez-libs desktop-file-utils ppp rp-pppoe wireless-tools irda-utils
nfs-utils nfs-utils-lib rdate fetchmail eject ksh mkbootdisk mtools
syslinux tcsh startup-notification talk apmd rmt dump setserial portmap yp-tools
ypbind

rpm -qa (列出所有安装了的包)
rpm -e package (删除某个包)
rpm -qi package (查询某个包)
rpm -qf command (根据程序查询包的名字)
rpm -ql package (查询某个包所有的安装文件)

4、删除一些不安全的软件包,并且用相应安全的软件替代,如: ssh/sftp/scp 替代 telnet, rsh, ftp, rcp
注意系统需要一个默认的 MAT,删除 Sendmail MAT 之前必须先安装一个,如: Postfix。

yum remove telnet rsh ftp rcp
yum install postfix
yum remove sendmail
/sbin/chkconfig postfix off

5、停掉并且删除一些不需要的 xinetd 服务。

/sbin/service xinetd stop; /sbin/chkconfig xinetd off
rm -rf /etc/xinetd.d

6、禁止一些 /etc/init.d/ 下面不需要的服务,更多信息请参考 “Understanding your (Red Hat Enterprise Linux) daemons, by Len DiMaggio”。

/sbin/chkconfig --list

for a in acpid anacron apmd atd autofs bluetooth cpuspeed cups gpm
hidd ip6tables irqbalance messagebus microcode_ctl netfs nfs nfslock
pcscd portmap readahead_early readahead_later rpcgssd rpcidmapd
sendmail smartd xinetd yum-updatesd; do /sbin/chkconfig $a off; done

7、重启系统后,检查一下正在运行中的服务,看看是不是都是必须的。

netstat -an | grep LISTEN
netstat -atunp

8、为了安全起见,删除一些不需要的用户。

cp /etc/passwd /etc/passwd.sav
cp /etc/group /etc/group.sav
for a in adm lp sync news uucp operator games gopher mailnull nscd rpc;
do /usr/sbin/userdel $a -f; done
for a in lp news uucp games gopher users floopy nscd rpc rpcuser nfsnobody;
do /usr/sbin/groupdel $a -f; done

加固和优化系统

9、打开防火墙。

system-config-securitylevel-tui

10、检查和禁止全局可写的 SUID 文件。

find / -perm +4000 -user root -type f -print
find / -perm +2000 -group root -type f -print
chmod u-s /full/path/to/filename
chmod g-s /full/path/to/filename

11、只允许 root 在一个 terminal 上登录,如: tty1。

vi /etc/securetty

12、避免其他用户按 Ctrl+Alt+Del 重启。

vi /etc/inittab

注释掉
#ca::ctrlaltdel:/sbin/shutdown -t3 -r now

13、/etc/security/console.apps/ 下面有 root 用户登录 console 后可以运行的程序,全部删除。
rm -f /etc/security/console.apps/*

14、删除一些登录信息。

vi /etc/issue (warning at login prompt)
vi /etc/motd (warning after successful login)

15、只运行一个 virtual terminal,如果是 VPS 的话,自己不可能物理登录终端,可以全部禁止掉。

vi /etc/inittab
# Run gettys in standard runlevels
#1:2345:respawn:/sbin/mingetty tty1
#2:2345:respawn:/sbin/mingetty tty2
...

16、加固 SSH 安全。

vi /etc/ssh/sshd_config
Port 2222
Protocol 2
PermitRootLogin no
PermitEmptyPasswords no
X11Forwarding no
UsePAM no
UseDNS no
AllowUsers vpsee
Banner /etc/issue

17、安装 Bastille 软件包帮助加固。

rpm -Uvh perl-Curses-1.15-1.el5.rf.i386.rpm
rpm -ivh Bastille-3.0.9-1.0.noarch.rpm
/usr/sbin/bastille -c

18、优化 Linux 内核。

vi /etc/sysctl.conf
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0

定制 Linux 内核

19、定制,编译,安装 Linux 内核。

yum install rpm-build ncurses ncurses-devel
rpm -ivh kernel-2.6.18-8.1.1.el5.data-original.rpm
cd /usr/data-original/redhat/SPECS
rpmbuild -bp --target i686 kernel-2.6.spec
cd /usr/data-original/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i686
sed -i 's/EXTRAVERSION = -prep/EXTRAVERSION = -8.1.1.custom.el5/' Makefile
make menuconfig
make rpm
cd /usr/data-original/redhat/RPMS/i686
rpm -ivh kernel-2.6.18prep-1.rpm
/sbin/mkinitrd /boot/initrd-2.6.18-prep.img 2.6.18-prep (2.6.18-prep -> /lib/modules)
vi /boot/grub/menu.1st

20、修改 iptables,只允许 ssh,http 和 https 端口打开。

/sbin/iptables -F
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A OUTPUT -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 443 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
/sbin/iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
/sbin/iptables -A INPUT -j REJECT
/sbin/iptables -A FORWARD -j REJECT

然后查看一下 iptables:

iptables -L

更多信息

10 Realistic Steps to a Faster Web Site
Understanding your (Red Hat Enterprise Linux) daemons, by Len DiMaggio
Linux Server Security (2nd Edition), by Michael D. Bauer, O’Reilly
Hardening Linux, by James Turnbull, Apress
RHEL 5.0 Deployment Guide, by RedHat
RHEL 5.0 Installation Guide, by RedHat

转自:http://www.vpsee.com/2009/06/128mb-vps-optimize-centos5/

linux下有sync, windows下也有类似的软件,就是cwRsync,此软件分为服务器端/客户端。
目前能找到的最新的版本是4.0.1。下载地址:cwRsync下载

主服务器:A 192.168.0.10

从服务器:B 192.168.0.20

 

1、主服务器A安装

主服务器A安装cwRsyncServer_4.0.1_Installer.zip,server 包括了 client 的功能。

安装完后,会在 系统服务 中增加 RsyncServer 和 ssh 服务,进入服务管理,设置为自动启动。安装成功后,要备份的文件目录必须加上 SvcwRsync 这个用户可读权限。

2、主服务器A配置

进入cwRsync安装目录,配置 rsyncd.conf 如下。

程序代码:

port = 9999 #默认端口是873,做了端口限制的要开启cwRsync所使用的端口。

use chroot = false

strict modes = false

hosts allow = *

log file = rsyncd.log #LOG

pid file = rsyncd.pid

# Module definitions

# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work

#

[web]

path = /cygdrive/d/web/test #注意格式,这说明是D盘WEB目录下的test目录

read only = true #只读

list = no

auth users = username  #指定用户名, 如果没有这行,则表明是匿名

secrets file=/cygdrive/d/rsyncd.secrets  这里指定了认证文件目录,名字叫 rsyncd.secrets,其内容是txt编辑为 username:123456 前面是用户名,后面是密码

transfer logging = no #是否记录详细的传输情况

rsyncd.conf相关解释:

use chroot = no        # 不使用chroot

max connections = 4    # 最大连接数为4

pid file = /cygdrive/d/rsyncd.pid

lock file = /cygdrive/d/rsync.lock

log file = /cygdrive/d/log/rsyncd.log    # 日志记录文件

[web]            # 这里是认证的模块名 client端需要根据此名字进行同步

path = /cygdrive/d/web/test    # 需要做镜像的目录

comment = BACKUP CLIENT IS SOLARIS 8 E250

ignore errors           # 可以忽略一些无关的IO错误

read only = yes         # 只读

list = no               # 不允许列文件

hosts allow=192.168.0.20         #允许连接IP,不限制则填写 *

auth users = username      # 认证的用户名,如果没有这行,则表明是匿名

secrets file = /cygdrive/d/rsyncd.secrets    # 认证文件名

1. 到vmware官方网站获取:VMware-server-2.0.0-122956.i386.rpm

2. 到CentOS上面执行rpm -ivh VMware-server-2.0.0-122956.i386.rpm

3. 运行vmware-config.pl,根据提示回答使用网络的Bridge模式,可以不用NAT。

安装过程中需要的序列号:

VMware Server 2 for Windows A0025-FWR6J-V1MFH-4R63M
VMware Server 2 for Linux A2J05-FWWF0-UGH0J-4J2HN

4.修正SELinux
chcon -t texrel_shlib_t /usr/lib/vmware/vmacore/libvmacore.so.1.0

chcon -t texrel_shlib_t /usr/lib/vmware/hostd/diskLibWrapper.so

5. /sbin/service vmware restart

6. 如果要远程管理(我的CentOS是最小安装,没有X),使用putty连接到CentOS机器上面,设置下面的ssh tunnel:

L8222 到远程的127.0.0.1:8222
L8333 到远程的127.0.0.1:8333
L902 到远程的127.0.0.1:902

7. 在本机上面运行IE并访问: http://localhost:8222/
输入3中指定的管理账户,如root和root的密码就可以了。

8. 如果要使用WMWare Remote Console只要选择Console标签,并下载安装IE插件就可以了。

有些时候,我们在复制/移动文件到另一台机器时会用到scp,因为它比较安全。但如果每次

都要输入密码,就比较烦了,尤其是在script里。不过,ssh有另一种用密钥对来验证的方

式。下面写出我生成密匙对的过程,供大家参考。

第一步:生成密匙对,我用的是rsa的密钥。使用命令 "ssh-keygen -t rsa"

   [user1@rh user1]$ ssh-keygen -t rsa

   Generating public/private rsa key pair.

   Enter file in which to save the key (/home/user1/.ssh/id_rsa):

   Created directory '/home/user1/.ssh'.

   Enter passphrase (empty for no passphrase):

   Enter same passphrase again:

   Your identification has been saved in /home/user1/.ssh/id_rsa.

   Your public key has been saved in /home/user1/.ssh/id_rsa.pub.

   The key fingerprint is:

   e0:f0:3b:d3:0a:3d:da:42:01:6a:61:2f:6c:a0:c6:e7 user1@rh.test.com

   [user1@rh user1]$

生成的过程中提示输入密钥对保存位置,直接回车,接受默认值就行了。接着会提示输入一

个不同于你的password的密码,直接回车,让它空着。当然,也可以输入一个。(我比较懒

,不想每次都要输入密码。) 这样,密钥对就生成完了。

其中公共密钥保存在 ~/.ssh/id_rsa.pub
私有密钥保存在 ~/.ssh/id_rsa

ssh可以与局域网中其他Linux机器相连,用scp命令可以从远程拷贝文件过来,用法如下:

scp xxx 192.168.0.68:/      (将文件xxx拷贝到ip地址为192.168.0.68的这台机器的目录/下)

scp -r xxx