Linux伺服器的配置
登入之後顯示如下:
1 [[email protected]_29_87_centos ~]#
為root使用者,版本為centos ~是當前目錄/root。
然我們現在來分割槽:
當前沒有分割槽和格式化,無法用 df -h 命令看到資料盤
1 [[email protected]_29_87_centos ~]# df -h
2 Filesystem Size Used Avail Use% Mounted on
3 /dev/vda1 20G 1.1G 18G 6% /
然後輸入fdisk -l 檢視資料盤的資訊:
1 [
[email protected]_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 [[email protected]_29_87_centos ~]# fdisk /dev/vdb 2 3 Unable to open /dev/vdb 4 [[email protected]_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 [[email protected]_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 [email protected]_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 [[email protected]_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 [[email protected]_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 [[email protected]_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 [[email protected]_29_87_centos ~]# service nginx start
檢驗nginx服務
1 [[email protected]_29_87_centos ~]# service nginx start
2 Starting nginx: [ OK ]
3 [[email protected]_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 [[email protected]_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 [[email protected]_29_87_centos tomcat]# mv apache-tomcat-6.0.30/ /usr/local/
再在tomcat目錄下執行如下操作:開啟tomcat
1 [[email protected]_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