登录之后显示如下:
1 [root@VM_29_87_centos ~]#
为root用户,版本为centos ~是当前目录/root。
然我们现在来分区:
当前没有分区和格式化,无法用 df -h 命令看到数据盘
1 [root@VM_29_87_centos ~]# df -h
2 Filesystem Size Used Avail Use% Mounted on
3 /dev/vda1 20G 1.1G 18G 6% /
然后输入fdisk -l 查看数据盘的信息:
1 [root@VM_29_87_centos ~]# fdisk -l
2
3 Disk /dev/vda: 21.5 GB, 21474836480 bytes
4 255 heads, 63 sectors/track, 2610 cylinders
5 Units = cylinders of 16065 * 512 = 8225280 bytes
6 Sector size (logical/physical): 512 bytes / 512 bytes
7 I/O size (minimum/optimal): 512 bytes / 512 bytes
8 Disk identifier: 0x0007ee22
9
10 Device Boot Start End Blocks Id System
11 /dev/vda1 * 1 2611 20970496 83 Linux
上面显示有一个21.5G的数据盘需要挂载分区
执行分区的操作如下:
1 fdisk /dev/vda
1 [root@VM_29_87_centos ~]# fdisk /dev/vdb
2
3 Unable to open /dev/vdb
4 [root@VM_29_87_centos ~]# fdisk /dev/vda
5
6 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
7 switch off the mode (command 'c') and change display units to
8 sectors (command 'u').
9
10 Command (m for help): m
11 Command action
12 a toggle a bootable flag
13 b edit bsd disklabel
14 c toggle the dos compatibility flag
15 d delete a partition
16 l list known partition types
17 m print this menu
18 n add a new partition
19 o create a new empty DOS partition table
20 p print the partition table
21 q quit without saving changes
22 s create a new empty Sun disklabel
23 t change a partition's system id
24 u change display/entry units
25 v verify the partition table
26 w write table to disk and exit
27 x extra functionality (experts only)
根据帮助命令可知,先输入n新建分区,再输入p新建扩展分区。之后按wq保存退出。
在输入fdisk -l 就可以看到新分区已经创建完成
1 [root@VM_29_87_centos ~]# fdisk -l
2
3 Disk /dev/vda: 21.5 GB, 21474836480 bytes
4 255 heads, 63 sectors/track, 2610 cylinders
5 Units = cylinders of 16065 * 512 = 8225280 bytes
6 Sector size (logical/physical): 512 bytes / 512 bytes
7 I/O size (minimum/optimal): 512 bytes / 512 bytes
8 Disk identifier: 0x0007ee22
9
10 Device Boot Start End Blocks Id System
11 /dev/vda1 * 1 2611 20970496 83 Linux
之后需要对分区进行格式化,文件系统可自行绝对(ext3,ext2)建议使用ext3
使用如下的命令进行格式化分区。
1 root@VM_29_87_centos ~]# mkfs.ext3 /dev/vda1
2 mke2fs 1.41.12 (17-May-2010)
3 /dev/vda1 is mounted; will not make a filesystem here!
显示 已挂载 无法分区
所以要先卸载分区再重新格式化
1 [root@VM_29_87_centos ~]# umount /dev/vda1
2 umount: /: device is busy.
3 (In some cases useful info about processes that use
4 the device is found by lsof(8) or fuser(1))
显示有程序使用/挂在该目录上,我们刚分的区,哪里来的程序?如何释放该程序呢?
使用fuser - identify processes using files or sockets
1 [root@VM_29_87_centos ~]# fuser -m /dev/vda1
2 /dev/vda1: 1rce 2rc 3rc 4rc 5rc 6rc 7rc 8rc 9rc 10rc 11rc 12rc 13rc 14rc 15rc 16rc 17rc 18rc 19rc 20rc 21rc 22rc 23rc 24rc 25rc 26rc 27rc 28rc 29rc 30rc 32rc 33rc 34rc 35rc 36rc 37rc 44rc 46rc 47rc 48rc 80rc 81rc 184rc 186rc 210rc 335rc 423rce 464rc 594rc 615rc 746rc 749re 950rce 972rce 994rce 1032rce 1075rce 1167rce 1183rce 1187rce 1204rce 1244rce 1246rce 1248rce 1250rce 1252rce 1253rce 1254rce 1256rce 3125rce 3129rce 3189rce
重复之前的动作,分个vda2出来
1 [root@VM_29_87_centos ~]# fdisk /dev/vda
2
3 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
4 switch off the mode (command 'c') and change display units to
5 sectors (command 'u').
6
7 Command (m for help): n
8 Command action
9 e extended
10 p primary partition (1-4)
11 e
12 Partition number (1-4): 1
13 Partition 1 is already defined. Delete it before re-adding it.
14
15 Command (m for help): n
16 Command action
17 e extended
18 p primary partition (1-4)
19 p
20 Partition number (1-4): 2
21 No free sectors available
配tomcat环境
先安装nginx
一句代码
1 yum install nginx
再启动nginx服务。
1 [root@VM_29_87_centos ~]# service nginx start
检验nginx服务
1 [root@VM_29_87_centos ~]# service nginx start
2 Starting nginx: [ OK ]
3 [root@VM_29_87_centos ~]# sudo wget http://127.0.0.1
4 --2016-07-25 12:05:32-- http://127.0.0.1/
5 Connecting to 127.0.0.1:80... connected.
6 HTTP request sent, awaiting response... 200 OK
7 Length: 3698 (3.6K) [text/html]
8 Saving to: `index.html'
9
10 100%[==============================================>] 3,698 --.-K/s in 0s
11
12 2016-07-25 12:05:32 (315 MB/s) - `index.html' saved [3698/3698]
毕竟是搞android的nginx用到的不多,所以php环境还是配置了。。。
安装: yum install php php-fpm
启动:service php-fpm start 一句strat php的service
现在写如何配jdk和tomcat
输入 java -version
看是否有自带的openjdk版本
1 [root@VM_29_87_centos ~]# java -version
2 java version "1.7.0_95"
3 OpenJDK Runtime Environment (rhel-2.6.4.0.el6_7-x86_64 u95-b00)
4 OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
有的话就不用管,有人说要换成oracle的jdk 我看了下其实这两个差别不大,只是一个支持java8 一个不支持罢了 作为服务器我们java用的很少 主要是用tomcat 我们现在来看如何配tomcat
在http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html 下载你要的tomcat的版本
然后用Filezila上传到linux服务器:
再讲tomcat移动到 /usr/local/
1
2 [root@VM_29_87_centos tomcat]# mv apache-tomcat-6.0.30/ /usr/local/
再在tomcat目录下执行如下操作:打开tomcat
1 [root@VM_29_87_centos tomcat]# /usr/local/tomcat/bin/catalina.sh start
即可在外部的浏览器中输入ip地址和端口号看到tomcat猫了:
1 http://115.159.107.159:8080/
把index.html移动到webapps里面之后。还是无法访问。而且在分区的时候,不小心动了分区表然后出现grup错误。一直未能修复
参考 http://www.2cto.com/os/201110/109140.html