查看“Vps”的源代码
来自Ubuntu中文
←
Vps
跳到导航
跳到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
此页面已受到保护,以防止编辑或其他操作。
您可以查看和复制此页面的源代码。
Ubuntu Linux VPS 入门指南 == 拿到的帐号 == BurstNET 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,跳转后的地址是不一样的,请勿照搬) 以下的指南都是针对 ubuntu 的,请centos或其它Linux用户到面板reload到ubuntu 10.10 x86 然后继续。 == 如何远程访问 == Linux VPS支持ssh远程访问,因此需要使用putty工具来访问。 1 下载putty 下载地址: http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe 2 运行putty 这个程序不需要安装,下载后直接运行,后在Host地址输入VPS的IP如下: [[Image:Vps_putty1.png]] 3 登录vps 点击上图中的 Open 按钮,第一次登录会出现确认密钥的提示,如下图,请点击 “是” 按钮。 [[Image:Vps_putty2.png]] 4 如下图输入登录用户名 root 回车,继续输入密码,注意输入密码是不会显示 “*” 的,同时密码是区分大小写的。 有个技巧,直接去复制密码后,鼠标点击 putty 的输入密码窗口,直接按下鼠标右键,然后回车即可登录。 在putty的窗口按下鼠标右键表示粘贴。 [[Image:Vps_putty3.png]] 5 如果显示下图则表示登录成功了。 [[Image:Vps_putty4.png]] 6 设置 putty 支持 vps 的中文文件名或中文文件内容显示: 设置显示字体,左边窗口点击 Window -> Appearance ,右边点击 Font settings -> Change 如下图: [[Image:Vps_putty5.png]] 字体选择 新宋体 字符集选择 CHINESE_GB2312 ,字体大小随你喜好设置。设置完毕后点确定 [[Image:Vps_putty6.png]] 设置终端字符,左边窗口点 Window -> Translation ,右边选择 Remote character set 的下拉框选择 UTF-8 ,如下图: [[Image:Vps_putty7.png]] 7 设置 putty 支持 端口转发: 点击左面的 Connection -> SSH -> Tunnels , 右边在 Source port 输入 7070,同时选择 Dynamic 如下图,然后点击 Add 完成设置 [[Image: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,点击菜单 文件 -> 站点管理器 [[Image:Vps_FileZilla1.png]] 点击后如下图: [[Image:Vps_FileZilla2.png]] 再点击面板的 "新站点" 按钮,在右边的输入地方,输入: 主机:VPS的IP,本例输入 184.82.9.30 协议:选择 SFTP 登录类型:选一般 用户:输入root 密码:输入ssh的登录密码,注意密码区分大小写。 如下图: [[Image:Vps_FileZilla3.png]] 输入完毕后,再切换到字符集,选择 "强制 UTF-8" ,如下图: [[Image:Vps_FileZilla4.png]] 输入完毕后直接点击 “连接” 按钮即可,连接完毕后如下图所示,你就可以直接上传和下载文件了。 [[Image: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无法运行) [[Image:Vps_Mysql1.png]] 需要重新输入一遍密码,如下图所示: [[Image:Vps_Mysql2.png]] 最后提示如下界面,表示mysql安装成功。 [[Image: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,回车继续,以下表示安装完成。 [[Image: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/ 查看,显示如下: [[Image:Vps_phpsysinfo.png]] ==== 安装 php 探针 ==== 使用putty登录到服务器,依次执行如下命令安装: cd /var/www wget http://www.duyaofei.com/downloads/tz.zip unzip tz.zip 运行结果如下所示: root@241541:~# cd /var/www root@241541:/var/www# wget http://www.duyaofei.com/downloads/tz.zip --2011-08-13 09:18:40-- http://www.duyaofei.com/downloads/tz.zip Resolving www.duyaofei.com... 74.220.215.201 Connecting to www.duyaofei.com|74.220.215.201|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 10490 (10K) [application/zip] Saving to: `tz.zip' 100%[======================================>] 10,490 --.-K/s in 0.07s 2011-08-13 09:18:41 (152 KB/s) - `tz.zip' saved [10490/10490] root@241541:/var/www# unzip tz.zip Archive: tz.zip inflating: tz.php 执行完毕后,在浏览器的地址输入: http://184.82.9.30/tz.php 查看,显示如下: [[Image:Vps_tz1.png]] ==== 安装 phpmyadmin ==== 安装phpmyadmin,需要mysql事先配置好root的密码。 使用putty登录到服务器,执行下面安装 apt-get install phpmyadmin 提示如下: root@241541:~# apt-get install phpmyadmin Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: dbconfig-common javascript-common libjs-mootools libmcrypt4 php5-mcrypt wwwconfig-common Suggested packages: libmcrypt-dev mcrypt postgresql-client apache apache-ssl The following NEW packages will be installed: dbconfig-common javascript-common libjs-mootools libmcrypt4 php5-mcrypt phpmyadmin wwwconfig-common 0 upgraded, 7 newly installed, 0 to remove and 26 not upgraded. Need to get 5184kB of archives. After this operation, 21.3MB of additional disk space will be used. Do you want to continue [Y/n]? 输入 Y, 回车继续。 按 空格键 选择 Apche2 如下图: [[Image:Vps_phpmyadmin1.png]] 选择完毕后,回车继续,提示如下图,是否需要创建phpmyadmin数据库, [[Image:Vps_phpmyadmin2.png]] 直接回车继续,提示输入mysql的管理员密码,输入后如下所示: [[Image:Vps_phpmyadmin3.png]] 回车继续后,如下图,提示输入phpmyadmin连接数据的密码,直接回车由系统随机产生一个即可。 [[Image:Vps_phpmyadmin4.png]] 完成安装提示如下: [[Image:Vps_phpmyadmin5.png]] 现在访问如下地址测试: http://184.82.9.30/phpmyadmin/ [[Image:Vps_phpmyadmin6.png]] 输入mysql的root帐号和mysql的密码,点击 执行 进行登录,进行正常访问如下: [[Image:Vps_phpmyadmin7.png]] === 配置虚拟站点 === 假设前提: 你有一个域名 test.com ,你希望搭建两个站点,第一个站点是 www.test.com 和 test.com 为主页,同时希望提供 bbs.test.com 为论坛。 ==== 配置域名 ==== 去域名商提供的面板将 test.com 的 A 记录修改为 VPS 的 IP 由于这里只是测试站点,直接在windows下修改 Hosts 文件,让系统识别这个域名 修改 C:\WINDOWS\system32\drivers\etc\hosts 文件 [[Image:Vps_winhosts1.png]] 双击选择 记事本 打开,在文件最后另起一行输入如下 184.82.9.30 test.com 184.82.9.30 www.test.com 184.82.9.30 bbs.test.com [[Image:Vps_winhosts2.png]] 如图所示,保存退出。 ==== 上传程序 ==== 约定两个站点的目录如下,为了方便备份,站点的目录最好集中存放在 /var/www 目录。 www.test.com(test.com) 对应目录: /var/www/test bbs.test.com 对应目录: /var/www/bbs 假设主站点安装帝国的CMS程序,论坛采用DZ的论坛,程序需要下载UTF-8的版本。 [[Image:Vps_ApacheSite1.png]] 使用前面提到的上传方法,利用 FileZilla 连接服务器,创建这两个目录。 [[Image:Vps_ApacheSite2.png]] 分别上传程序 [[Image:Vps_ApacheSite3.png]] ==== 多域名配置 ==== 编辑www.test.com的站点配置文件 test.com.txt <VirtualHost *:80> ServerName www.test.com ServerAlias test.com DocumentRoot /var/www/test/ </VirtualHost> 编辑bbs.test.com的站点配置文件 bbs.test.com.txt <VirtualHost *:80> ServerName bbs.test.com DocumentRoot /var/www/bbs/ </VirtualHost> 如图所示: [[Image:Vps_ApacheSite4.png]] 将这两个文件上传到 /etc/apache2/sites-enabled/ 目录 如图所示: [[Image:Vps_ApacheSite5.png]] ==== 修改上传文件权限 ==== 由于上传的文件的所有者为 root ,Apache 无法正常写入,所以需要设置上传文件的宿主为 www-data。 使用putty登录vps执行如下命令,设置 /var/www下的所有文件的宿主都是 www-data,这样apache2就可以正常读写: chown -R www-data:www-data /var/www/* /etc/init.d/apache2 restart 执行结果如下所示: root@241541:~# chown -R www-data:www-data /var/www/* root@241541:~# /etc/init.d/apache2 restart * Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 0.3.175.133 for ServerName ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 0.3.175.133 for ServerName [ OK ] ==== 安装配置 ==== 主站点程序访问 http://www.test.com 如下图所示,进一步安装: [[Image:Vps_ApacheSite8.png]] 论坛程序访问 http://bbs.test.com 如下图所示,进一步安装: [[Image:Vps_ApacheSite7.png]] 以上就是完成多域名的配置。 ==== mysql 管理 ==== 对于mysql数据库维护可以使用前面安装的 phpmyadmin 进行维护,或直接在 putty 中输入 mysql -p 进行管理如图所示: [[Image:Vps_mysql1.png]] == 使用 Nginx 搭建站点 == 为什要使用nginx?因为apache太耗内存了,使用nginx可以节约内存。 采用 nginx + php-fpm + mysql 搭建。 === 删除 apache2 === 使用putty登录vps,执行如下命令: apt-get remove apache2 apache2.2-common 出现类似如下提示时,输入 Y 并回车。 0 upgraded, 1 newly installed, 7 to remove and 26 not upgraded. Need to get 5837kB of archives. After this operation, 14.5MB disk space will be freed. Do you want to continue [Y/n]? 最后会出现如下提示,表示已经删除 apache2 Removing libapache2-mod-php5 ... Module php5 disabled. Run '/etc/init.d/apache2 restart' to activate new configuration! Removing apache2-mpm-prefork ... * 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 ] Removing apache2.2-common ... Removing apache2-utils ... Removing apache2.2-bin ... === 安装 php5-fpm php5-cgi === 使用putty登录vps,执行如下命令: apt-get install php5-cgi php5-fpm 出现下面的提示表示安装成功 root@241541:~# apt-get install php5-cgi php5-fpm Reading package lists... Done Building dependency tree Reading state information... Done php5-cgi is already the newest version. php5-cgi set to manually installed. Suggested packages: php-pear The following NEW packages will be installed: libevent-1.4-2 php5-fpm 0 upgraded, 2 newly installed, 0 to remove and 26 not upgraded. Need to get 3002kB of archives. After this operation, 7967kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu/ maverick/main libevent-1.4-2 i386 1.4.13-stable-1 [56.2kB] Get:2 http://archive.ubuntu.com/ubuntu/ maverick-updates/universe php5-fpm i386 5.3.3-1ubuntu9.5 [2946kB] Fetched 3002kB in 1s (2181kB/s) Selecting previously deselected package libevent-1.4-2. (Reading database ... 21902 files and directories currently installed.) Unpacking libevent-1.4-2 (from .../libevent-1.4-2_1.4.13-stable-1_i386.deb) ... Selecting previously deselected package php5-fpm. Unpacking php5-fpm (from .../php5-fpm_5.3.3-1ubuntu9.5_i386.deb) ... Setting up libevent-1.4-2 (1.4.13-stable-1) ... Setting up php5-fpm (5.3.3-1ubuntu9.5) ... update-rc.d: warning: php5-fpm stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (none) * Starting PHP5 FPM... Aug 13 06:25:50.352643 [WARNING] [pool www] pm.start_servers is not set. It's been set to 20. [ OK ] Creating config file /etc/php5/fpm/php.ini with new version Processing triggers for libc-bin ... ldconfig deferred processing now taking place === 安装 mysql === 见前面的安装 mysql 的步骤。 === 安装 nginx === 使用putty登录vps,执行如下命令: apt-get install nginx 出现如下提示,表示已经安装完毕: root@241541:~# apt-get install nginx Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: ufw The following NEW packages will be installed: nginx 0 upgraded, 1 newly installed, 0 to remove and 26 not upgraded. Need to get 341kB of archives. After this operation, 827kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu/ maverick/universe nginx i386 0.7.67-3ubuntu1 [341kB] Fetched 341kB in 0s (437kB/s) Selecting previously deselected package nginx. (Reading database ... 21918 files and directories currently installed.) Unpacking nginx (from .../nginx_0.7.67-3ubuntu1_i386.deb) ... Setting up nginx (0.7.67-3ubuntu1) ... 再执行下面的命令启动nginx服务: /etc/init.d/nginx start 结果如下所示,表示nginx顺利启动: root@241541:~# /etc/init.d/nginx start Starting nginx: nginx. === 测试站点 === 由于nginx默认的站点不支持php,所以需要修改默认站点。 编辑文件名为 default.txt ,注意下面的 server_name 修改为你的vps的ip地址,可以写一个IP,也可以都写上,IP和IP之间有空格。 server { listen 80; server_name 184.82.9.30 184.82.9.31; index index.html index.htm index.php; root /var/www/; location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } } 将 default.txt 文件使用 filezilla 上传到 /etc/nginx/sites-enabled 目录下 使用 putty 登录vps,输入如下命令重启 nginx 服务 /etc/init.d/nginx restart 重启结果如下所示: root@241541:~# /etc/init.d/nginx restart Restarting nginx: nginx. ==== 安装phpsysindo ==== 按照前面apache2讲述的安装 ==== 安装 php 探针 ==== 按照前面apache2讲述的安装 ==== 安装 phpmyadmin ==== 照前面 Apache2 安装 phpmyadmin, 注意第二步不要再按空格选择 apache2 , 直接回车下一步。 如果已经之前已经安装过 phpmyadmin ,不需要删除,继续使用。 安装完毕 phpmyadmin 后, 继续在 putty 里面执行如下命令即可: cd /var/www ln -s /usr/share/phpmyadmin . 执行情况如下所示: root@241541:~# cd /var/www root@241541:/var/www# ln -s /usr/share/phpmyadmin . root@241541:/var/www# 然后就可以在浏览器里面访问 phpmyadmin 了。 访问地址: http://184.82.9.30/phpmyadmin/ === 配置虚拟站点 === 以上运行环境均已经安装完毕,下面讲如何配置 nginx 的多域名。 假设前提: 你有一个域名 test.com ,你希望搭建两个站点,第一个站点是 www.test.com 和 test.com 为主页,同时希望提供 bbs.test.com 为论坛。 ==== 配置域名 ==== 参考上面 apache2 的配置域名部分。 ==== 上传程序 ==== 参考上面 apache2 的上传程序部分。 ==== 多域名配置 ==== 编辑www.test.com的站点配置文件 test.com.txt server { listen 80; server_name www.test.com test.com; index index.html index.htm index.php; root /var/www/test/; location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } } 编辑bbs.test.com的站点配置文件 bbs.test.com.txt server { listen 80; server_name bbs.test.com; index index.html index.htm index.php; root /var/www/bbs/; location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } } 将这两个文件使用 filezilla 上传到 /etc/nginx/sites-enabled/ 目录 ==== 修改上传文件权限 ==== 由于上传的文件的所有者为 root ,Nginx 无法正常写入,所以需要设置上传文件的宿主为 www-data。 使用putty登录vps执行如下命令,设置 /var/www下的所有文件的宿主都是 www-data,这样nginx就可以正常读写: chown -R www-data:www-data /var/www/* /etc/init.d/nginx restart 执行结果如下所示: root@241541:~# chown -R www-data:www-data /var/www/* root@195669:~# /etc/init.d/nginx restart Restarting nginx: nginx. ==== 安装配置 ==== 见 apache2 的安装配置部分 == 安全相关事项 == 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加到黑名单,不允许再登录。 == 备份和恢复 == 将 vps 成功安装好软件后,面临的第二大的事情是如何备份现有的东西?已经如何恢复? 你需要备份 3 个方面的内容: 1 站点配置文件 2 站点文件 3 数据库, 分别讲解如下: === 备份站点配置文件 === 看前面的设置,一般情况,我们需要备份Apache或Nginx,如果你修改了Mysql的配置,则需要备份Mysql的配置。 ==== 备份Apache配置文件 ==== 执行如下命令备份Apache的配置到 /root 下 : cd ~ tar czvf apache2.tar.gz /etc/apache2 备份的文件名叫 apache2.tar.gz ,执行结果如下: root@241541:~# cd ~ root@241541:~# tar czvf apache2.tar.gz /etc/apache2 tar: Removing leading `/' from member names /etc/apache2/ /etc/apache2/sites-enabled/ /etc/apache2/sites-enabled/test.com.txt /etc/apache2/sites-enabled/bbs.test.com.txt /etc/apache2/sites-enabled/000-default /etc/apache2/apache2.conf /etc/apache2/magic /etc/apache2/httpd.conf /etc/apache2/mods-enabled/ /etc/apache2/mods-enabled/autoindex.conf ... 中间部分省略 ... /etc/apache2/conf.d/ /etc/apache2/conf.d/phpmyadmin.conf /etc/apache2/conf.d/security /etc/apache2/conf.d/charset /etc/apache2/conf.d/javascript-common.conf /etc/apache2/conf.d/apache2-doc /etc/apache2/conf.d/localized-error-pages /etc/apache2/conf.d/other-vhosts-access-log /etc/apache2/ports.conf ==== 备份Nginx配置文件 ==== 执行如下命令备份Nginx的配置到 /root 下 : cd ~ tar czvf nginx.tar.gz /etc/nginx 备份的文件名叫 nginx.tar.gz ,执行结果如下: root@241541:~# cd ~ root@241541:~# tar czvf nginx.tar.gz /etc/nginx tar: Removing leading `/' from member names /etc/nginx/ /etc/nginx/koi-utf /etc/nginx/win-utf /etc/nginx/sites-enabled/ /etc/nginx/sites-enabled/test.com.txt /etc/nginx/sites-enabled/bbs.test.com.txt /etc/nginx/sites-enabled/default.txt /etc/nginx/fastcgi_params /etc/nginx/nginx.conf /etc/nginx/mime.types /etc/nginx/sites-available/ /etc/nginx/sites-available/default /etc/nginx/conf.d/ /etc/nginx/koi-win ==== 备份Mysql配置文件 ==== 执行如下命令备份Mysql的配置到 /root 下 : cd ~ tar czvf mysql.tar.gz /etc/mysql 备份的文件名叫 mysql.tar.gz ,执行结果如下: root@241541:~# cd ~ root@241541:~# tar czvf mysql.tar.gz /etc/mysql tar: Removing leading `/' from member names /etc/mysql/ /etc/mysql/my.cnf /etc/mysql/debian.cnf /etc/mysql/conf.d/ /etc/mysql/conf.d/mysqld_safe_syslog.cnf /etc/mysql/debian-start === 备份站点文件 === === 备份数据库 === == 日常维护 == === 查看硬盘剩余空间大小 === 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 显示 [[Image:Vps_top.png]] === 更多命令参考 === [[UbuntuSkills|Ubuntu 技巧]]
该页面使用的模板:
模板:Qref Alarm
(
查看源代码
)
返回
Vps
。
导航菜单
页面操作
页面
讨论
阅读
查看源代码
历史
页面操作
页面
讨论
更多
工具
个人工具
登录
导航
首页
最近更改
随机页面
页面分类
帮助
搜索
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息