您的位置:首页 > 运维架构 > Linux

Linux服务器的配置

2016-07-25 12:25 447 查看
麻蛋,之前的windows服务器到期了。所以上一篇的那个deeplink一直没实现。(其实也可以自己用电脑搭服务器)

去腾讯云买了个linux服务器(学生每月只需一元),然后环境都需要重新配置。坑啊!

就写一下那个linux服务器tomcat环境的配置。

登录之后显示如下:

[root@VM_29_87_centos ~]#


为root用户,版本为centos ~是当前目录/root。

然我们现在来分区:

当前没有分区和格式化,无法用 df -h 命令看到数据盘

[root@VM_29_87_centos ~]#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 1.1G 18G 6% /


然后输入fdisk -l 查看数据盘的信息:

[root@VM_29_87_centos ~]#fdisk -l

Disk /dev/vda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0007ee22

Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20970496 83 Linux


上面显示有一个21.5G的数据盘需要挂载分区

执行分区的操作如下:

fdisk /dev/vda


[root@VM_29_87_centos ~]#fdisk /dev/vdb

Unable to open /dev/vdb
[root@VM_29_87_centos ~]#fdisk /dev/vda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)


根据帮助命令可知,先输入n新建分区,再输入p新建扩展分区。之后按wq保存退出。

在输入fdisk -l 就可以看到新分区已经创建完成

[root@VM_29_87_centos ~]#fdisk -l

Disk /dev/vda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0007ee22

Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20970496 83 Linux


之后需要对分区进行格式化,文件系统可自行绝对(ext3,ext2)建议使用ext3

使用如下的命令进行格式化分区。

[root@VM_29_87_centos ~]#mkfs.ext3 /dev/vda1
mke2fs 1.41.12 (17-May-2010)
/dev/vda1 is mounted; will not make a filesystem here!


显示 已挂载 无法分区

所以要先卸载分区再重新格式化

[root@VM_29_87_centos ~]#umount /dev/vda1
umount: /: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))


显示有程序使用/挂在该目录上,我们刚分的区,哪里来的程序?如何释放该程序呢?

使用fuser - identify processes using files or sockets

[root@VM_29_87_centos ~]#fuser -m /dev/vda1
/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出来

[root@VM_29_87_centos ~]#fdisk /dev/vda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 1
Partition 1 is already defined. Delete it before re-adding it.

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
No free sectors available


分不出来~~气死了 只有vda 那个系统盘 而且只有一个分区vda1。先别分了 ,我还是先配tomcat环境吧。

先安装nginx

一句代码

yum install nginx


再启动nginx服务。

[root@VM_29_87_centos ~]#service nginx start


检验nginx服务

[root@VM_29_87_centos ~]#service nginx start
Starting nginx: [ OK ]
[root@VM_29_87_centos ~]#sudo wget http://127.0.0.1 --2016-07-25 12:05:32-- http://127.0.0.1/ Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3698 (3.6K) [text/html]
Saving to: `index.html'

100%[==============================================>] 3,698 --.-K/s in 0s

2016-07-25 12:05:32 (315 MB/s) - `index.html' saved [3698/3698]


毕竟是搞android的nginx用到的不多,所以php

php环境还是配置了。。。毕竟世界上最好的语言

安装: yum install php php-fpm

启动:service php-fpm start 一句strat php的service

现在写如何配jdk和tomcat(我后来才发现,里面有自带的tomcat和jdk。。。。)

输入 java -version

看是否有自带的openjdk版本

[root@VM_29_87_centos ~]#java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (rhel-2.6.4.0.el6_7-x86_64 u95-b00)
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/

[root@VM_29_87_centos tomcat]# mv apache-tomcat-6.0.30/ /usr/local/


再在tomcat目录下执行如下操作:打开tomcat

[root@VM_29_87_centos tomcat]#  /usr/local/tomcat/bin/catalina.sh start


即可在外部的浏览器中输入ip地址和端口号看到tomcat猫了:

http://115.159.107.159:8080/


然后问题继续–都是一大堆坑

把index.html移动到webapps里面之后。还是无法访问。而且在分区的时候,不小心动了分区表然后出现grup错误。一直未能修复

参考 http://www.2cto.com/os/201110/109140.html

反正也是新系统,然后就重装系统了~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: