个人工具

“Vps”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
配置站点
安装 B-Check php 探针
第325行: 第325行:
 
  unzip b-check.zip
 
  unzip b-check.zip
  
执行完毕后,在浏览器的地址输入: http://184.82.9.30/b-check 查看,显示如下:
+
执行完毕后,在浏览器的地址输入: http://184.82.9.30/b-check/ 查看,显示如下:
  
 
[[Image:Vps_BCheck.png]]
 
[[Image:Vps_BCheck.png]]

2011年8月12日 (五) 22:49的版本

Ubuntu Linux VPS 入门指南

拿到的帐号

开通后,你将收到如下的帐号:

ACCOUNT INFORMATION
Order ID: 111111
Hosting Package: VPS #1 (Virtual Private Server) - vePortal - (SCRANTON, PA) - RESALE
Domain: XXX.XXX.XXX
Billing Cycle: Monthly
Next Due Date: 09/12/2011

SERVER INFORMATION
VPS ID: 111111
VPS IP Address: 184.82.9.30
SSH Root Password: pass001
VPS Control Panel URL (non-SSL): http://184.82.9.30:2407
VPS Control Panel URL (SSL): https://184.82.9.30:2408
VPS Control Panel Username: user001
VPS Control Panel Password: pass001

比较重要的事情是:

  • VPS地址:184.82.9.30 ,第二个IP是地址的最后一位+1,如果你的IP是 173.210.202.198 , 第二个IP则是 173.210.202.199
  • 面板的地址:打开 https://184.82.9.30:2408 地址后,会自动跳转到另外一个地址 https://64.120.201.42:2408/ ,请记录此地址,这个才是你真实的面板地址,当VPS无法启动时,使用原地址将无法自动跳转,需要直接使用真实的面板地址才可以登录面板。(不同的VPS,跳转后的地址是不一样的,请勿照搬)

如何远程访问

Linux VPS支持ssh远程访问,因此需要使用putty工具来访问。

1 下载putty

下载地址: http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe

2 运行putty

这个程序不需要安装,下载后直接运行,后在Host地址输入VPS的IP如下:

Vps putty1.png

3 登录vps

点击上图中的 Open 按钮,第一次登录会出现确认密钥的提示,如下图,请点击 “是” 按钮。

Vps putty2.png

4 如下图输入登录用户名 root 回车,继续输入密码,注意输入密码是不会显示 “*” 的,同时密码是区分大小写的。

有个技巧,直接去复制密码后,鼠标点击 putty 的输入密码窗口,直接按下鼠标右键,然后回车即可登录。 在putty的窗口按下鼠标右键表示粘贴。

Vps putty3.png

5 如果显示下图则表示登录成功了。

Vps putty4.png

6 设置 putty 支持 vps 的中文文件名或中文文件内容显示:

设置显示字体,左边窗口点击 Window -> Appearance ,右边点击 Font settings -> Change 如下图:

Vps putty5.png

字体选择 新宋体 字符集选择 CHINESE_GB2312 ,字体大小随你喜好设置。设置完毕后点确定

Vps putty6.png

设置终端字符,左边窗口点 Window -> Translation ,右边选择 Remote character set 的下拉框选择 UTF-8 ,如下图:

Vps putty7.png

7 设置 putty 支持 端口转发:

点击左面的 Connection -> SSH -> Tunnels , 右边在 Source port 输入 7070,同时选择 Dynamic 如下图,然后点击 Add 完成设置

Vps putty8.png

如何上传和下载文件

VPS 直接支持ssh协议,因此不需要采用 ftp 方式上传,可以直接使用支持 sftp 协议的客户端上传文件,这里使用 FileZilla。

1 下载FileZilla

官网下载地址: http://filezilla-project.org/download.php?type=client

或直接点击下载: http://sourceforge.net/projects/filezilla/files/FileZilla_Client/3.5.0/FileZilla_3.5.0_win32-setup.exe/download

2 下载完毕后安装 FileZilla

3 添加站点

运行FileZilla,点击菜单 文件 -> 站点管理器

Vps FileZilla1.png

点击后如下图:

Vps FileZilla2.png

再点击面板的 "新站点" 按钮,在右边的输入地方,输入:

主机:VPS的IP,本例输入 184.82.9.30
协议:选择 SFTP
登录类型:选一般
用户:输入root
密码:输入ssh的登录密码,注意密码区分大小写。

如下图:

Vps FileZilla3.png

输入完毕后,再切换到字符集,选择 "强制 UTF-8" ,如下图:

Vps FileZilla4.png

输入完毕后直接点击 “连接” 按钮即可,连接完毕后如下图所示,你就可以直接上传和下载文件了。

Vps FileZilla5.png

下一次打开 FileZilla 时,直接到站点管理器,点击连接即可。

更新软件源

以下命令均需要使用 putty 登录到服务器远程执行命令操作,你可以直接复制下面的命令,然后点击 putty 窗口按鼠标右键,粘贴命令。

本步骤不可跳过,需要先执行,后面才可以继续,建议每次安装新软件时,都执行一遍本步骤。

输入如下命令更新软件源:

apt-get update

下面的提示不同的Linux的版本存在不同的差异,但有如下类似的提示时,表示更新成功:

root@241541:~# apt-get update
Get:1 http://archive.ubuntu.com maverick Release.gpg [198B]
Ign http://archive.ubuntu.com/ubuntu/ maverick/main Translation-en
Ign http://archive.ubuntu.com/ubuntu/ maverick/restricted Translation-en
Ign http://archive.ubuntu.com/ubuntu/ maverick/universe Translation-en
Get:2 http://archive.ubuntu.com maverick-updates Release.gpg [198B]
Ign http://archive.ubuntu.com/ubuntu/ maverick-updates/main Translation-en
Ign http://archive.ubuntu.com/ubuntu/ maverick-updates/restricted Translation-en
Ign http://archive.ubuntu.com/ubuntu/ maverick-updates/universe Translation-en
Get:3 http://archive.ubuntu.com maverick-security Release.gpg [198B]
Ign http://archive.ubuntu.com/ubuntu/ maverick-security/main Translation-en
Ign http://archive.ubuntu.com/ubuntu/ maverick-security/restricted Translation-en
Ign http://archive.ubuntu.com/ubuntu/ maverick-security/universe Translation-en
Get:4 http://archive.ubuntu.com maverick Release [39.8kB]
Get:5 http://archive.ubuntu.com maverick-updates Release [31.4kB]
Get:6 http://archive.ubuntu.com maverick-security Release [31.4kB]
Get:7 http://archive.ubuntu.com maverick/main i386 Packages [1492kB]
Get:8 http://archive.ubuntu.com maverick/restricted i386 Packages [5992B]
Get:9 http://archive.ubuntu.com maverick/universe i386 Packages [5791kB]
Get:10 http://archive.ubuntu.com maverick-updates/main i386 Packages [380kB]
Get:11 http://archive.ubuntu.com maverick-updates/restricted i386 Packages [1797B]
Get:12 http://archive.ubuntu.com maverick-updates/universe i386 Packages [157kB]
Get:13 http://archive.ubuntu.com maverick-security/main i386 Packages [157kB]
Get:14 http://archive.ubuntu.com maverick-security/restricted i386 Packages [14B]
Get:15 http://archive.ubuntu.com maverick-security/universe i386 Packages [77.9kB]
Fetched 8166kB in 4s (1724kB/s)
Reading package lists... Done

安装常用软件

VPS里面缺乏一些常用工具软件,一次安装好:

输入如下命令安装解压缩、下载和数据同步软件:

apt-get install unzip wget rsync

如果提示如下命令,表示之前已经安装好:

root@241541:~# apt-get install unzip zip wget rsync
Reading package lists... Done
Building dependency tree
Reading state information... Done
unzip is already the newest version.
wget is already the newest version.
rsync is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 26 not upgraded.

如果之前没有安装会提示如下命令,表示已经安装好

root@241541:~# apt-get install unzip zip wget rsync
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  rsync unzip wget zip
0 upgraded, 4 newly installed, 0 to remove and 26 not upgraded.
Need to get 319kB/1125kB of archives.
After this operation, 2314kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ maverick/main zip i386 3.0-3 [319kB]
Fetched 319kB in 0s (417kB/s)
Selecting previously deselected package wget.
(Reading database ... 22549 files and directories currently installed.)
Unpacking wget (from .../wget_1.12-1.1ubuntu3_i386.deb) ...
Selecting previously deselected package rsync.
Unpacking rsync (from .../rsync_3.0.7-2ubuntu1.1_i386.deb) ...
Selecting previously deselected package unzip.
Unpacking unzip (from .../archives/unzip_6.0-4_i386.deb) ...
Selecting previously deselected package zip.
Unpacking zip (from .../archives/zip_3.0-3_i386.deb) ...
Setting up wget (1.12-1.1ubuntu3) ...
Setting up rsync (3.0.7-2ubuntu1.1) ...
Setting up unzip (6.0-4) ...
Setting up zip (3.0-3) ...

使用 Apache 搭建站点

安装 Apache2 Web 服务

VPS 默认有安装Apache2,但如果你删除了,就需要重新安装;如果没有删除,执行下面的命令会退出来,不会对系统产生任何影响。

输入如下命令安装

apt-get install apache2

正常情况下会给出如下提示,说明Apache2默认已经安装好了:

root@241541:~# apt-get install apache2
Reading package lists... Done
Building dependency tree... Done
apache2 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

安装 mysql 数据库服务

安装mysql前,#1的vps需要先关闭apache2,因为mysql的安装会初始化数据,占了很大内存,如果apache2不关闭,有可能导致安装mysql失败。

1 输入如下命令关闭 apache2

/etc/init.d/apache2 stop

如果输入正确,会提示如下信息,表示apache2已经停止

root@241541:~# /etc/init.d/apache2 stop
 * Stopping web server apache2                                                  apache2: Could not reliably determine the server's fully qualified domain name, using 0.3.175.133 for ServerName
 ... waiting                                                             [ OK ]

2 输入如下命令安装mysql

apt-get install mysql-server

如果输入正确,会提示如下信息,

root@241541:~# apt-get install mysql-server
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16
  libnet-daemon-perl libplrpc-perl mysql-client-5.1 mysql-client-core-5.1
  mysql-common mysql-server-5.1 mysql-server-core-5.1
Suggested packages:
  libipc-sharedcache-perl libterm-readkey-perl tinyca
The following NEW packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16
  libnet-daemon-perl libplrpc-perl mysql-client-5.1 mysql-client-core-5.1
  mysql-common mysql-server mysql-server-5.1 mysql-server-core-5.1
0 upgraded, 12 newly installed, 0 to remove and 26 not upgraded.
Need to get 22.9MB of archives.
After this operation, 54.4MB of additional disk space will be used.
Do you want to continue [Y/n]? 

输入 Y 回车,继续安装 会提示输入 mysql 的 root 用户密码,你可以输入密码后回车,也可以不输入任何密码直接回车。 (不输入密码不会影响到Mysql的安全性,因为Mysql仅仅用于本地监听,但不输入密码会导致后续phpmyadmin无法运行)

Vps Mysql1.png

需要重新输入一遍密码,如下图所示:

Vps Mysql2.png

最后提示如下界面,表示mysql安装成功。

Vps Mysql3.png

安装php环境

执行如下命令安装apache2的php5扩展和php的mysql扩展

apt-get install libapache2-mod-php5 php5-gd php5-mysql

如下提示:

root@241541:~# apt-get install libapache2-mod-php5 php5-gd php5-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libgd2-xpm libjpeg62 libt1-5 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6
  libxpm4 php5-cli php5-common
Suggested packages:
  php-pear libgd-tools php5-suhosin
The following NEW packages will be installed:
  libapache2-mod-php5 libgd2-xpm libjpeg62 libt1-5 libx11-6 libx11-data
  libxau6 libxcb1 libxdmcp6 libxpm4 php5-cli php5-common php5-gd php5-mysql
0 upgraded, 14 newly installed, 0 to remove and 26 not upgraded.
Need to get 8128kB of archives.
After this operation, 22.7MB of additional disk space will be used.
Do you want to continue [Y/n]?

输入 Y,回车继续,以下表示安装完成。

Vps php1.png

重新启动apache2, 输入如下命令:

/etc/init.d/apache2 start

提示如下,表示启动成功:

root@241541:~# /etc/init.d/apache2 start
 * Starting web server apache2                                                  apache2: Could not reliably determine the server's fully qualified domain name, using 0.3.175.133 for ServerName
                                                                         [ OK ]

测试站点

以上命令已经完整安装好一台Web服务器所具有的环境,以下来搭建一个最简单的站点。

web 的根目录位于 /var/www 你可以将自己的程序直接放到此目录。

安装phpsysindo

使用putty登录到服务器,依次执行如下命令安装phpsysindo:

cd /var/www
wget http://sourceforge.net/projects/phpsysinfo/files/phpsysinfo/3.0.13/phpsysinfo-3.0.13.tar.gz/download -O phpsysinfo-3.0.13.tar.gz
tar xzvf phpsysinfo-3.0.13.tar.gz 
cd phpsysinfo
mv config.php.new config.php

执行完毕后,在浏览器的地址输入: http://184.82.9.30/phpsysinfo/ 查看,显示如下:

Vps phpsysinfo.png

安装 B-Check php 探针

使用putty登录到服务器,依次执行如下命令安装b-check:

cd /var/www
wget "http://down.zzbaike.com/d/download.php?n=1&server=1&id=4409::1283742285" -O b-check.zip --referer=http://down.zzbaike.com/
unzip b-check.zip

执行完毕后,在浏览器的地址输入: http://184.82.9.30/b-check/ 查看,显示如下:

Vps BCheck.png

使用 Nginx 搭建站点

邮件服务

安全相关事项

vps的root密码不要设置的太简单,这样很容易被攻破,你可以安装如下软件来降低vps被攻破的机会。

输入如下命令:

apt-get install denyhosts

提示如下表示安装完成:

root@241541:/# apt-get install denyhosts
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  denyhosts
0 upgraded, 1 newly installed, 0 to remove and 26 not upgraded.
Need to get 73.8kB of archives.
After this operation, 451kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ maverick/universe denyhosts all 2.6-7 [73.8kB]
Fetched 73.8kB in 0s (131kB/s)
Selecting previously deselected package denyhosts.
(Reading database ... 22621 files and directories currently installed.)
Unpacking denyhosts (from .../denyhosts_2.6-7_all.deb) ...
Setting up denyhosts (2.6-7) ...
 * Starting DenyHosts denyhosts                                          [ OK ]

这样如果用户5次密码输入错误,将会自动将其IP加到黑名单,不允许再登录。

日常维护

查看硬盘剩余空间大小

df

显示

root@241541:/# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/simfs            20971520    583508  20388012   3% /

查看硬盘可用文件数

df -i

显示

root@241541:/# df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/simfs            400000   26568  373432    7% /

查看内存剩余大小

free

显示

root@241541:/# free
             total       used       free     shared    buffers     cached
Mem:        524800     245240     279560          0          0          0
-/+ buffers/cache:     245240     279560
Swap:            0          0          0

动态显示系统程序情况

top

显示 Vps top.png

更多命令参考

Ubuntu 技巧