安裝 CentOS5.7 Base Server
1.使用光碟開機
在光碟安裝選單,選擇linux text 安裝
2.分割partition
/ 35G
/swap 4096
/var 100G
/tmp 5G
/home 355G
3.選擇安裝套件
admin-tools
base
core
development-libs
development-tools
editors
legacy-network-server
legacy-software-development
legacy-software-support
Server Configuration tools
system-tools
text-internet
4.修改IP
方式一:
#ifconfig eth0 192.168.1.18 netmask 255.255.255.0
方式二:
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0
GATEWAY=192.168.0.103
ONBOOT=yes
ONBOOT=yes 當執行 /etc/init.d/network 來啟動網路服務時,也同時啟動該網路介面。開機時預設一定會啟動網路服務,所以該行設定簡單的說,就是希望在開機時啟動網路介面的意思啦。
BOOTPROTO='static' 設定靜態 ip 位址。如果您是 DHCP 的 Client 端 (比如 Cable Modem),請設定成 BOOTPROTO='dhcp'。
IPADDR=192.168.0.1 設定靜態 IP Address。
NETMASK=255.255.255.0 設定網路遮罩。
NETWORK=192.168.0.0 設定網路位址。
BROADCAST=192.168.0.255 設定廣播位址。
PERSISTENT_NAME=eth0 指定該介面名稱為 eth0。當您存在兩片網卡時,就可以使用這個參數來個別指定介面名稱,這樣就不容易搞混,當然您要是區分得出來,不設定也無所謂啦。p
1.使用光碟開機
在光碟安裝選單,選擇linux text 安裝
2.分割partition
/ 35G
/swap 4096
/var 100G
/tmp 5G
/home 355G
3.選擇安裝套件
admin-tools
base
core
development-libs
development-tools
editors
legacy-network-server
legacy-software-development
legacy-software-support
Server Configuration tools
system-tools
text-internet
4.修改IP
方式一:
#ifconfig eth0 192.168.1.18 netmask 255.255.255.0
方式二:
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0
GATEWAY=192.168.0.103
ONBOOT=yes
ONBOOT=yes 當執行 /etc/init.d/network 來啟動網路服務時,也同時啟動該網路介面。開機時預設一定會啟動網路服務,所以該行設定簡單的說,就是希望在開機時啟動網路介面的意思啦。
BOOTPROTO='static' 設定靜態 ip 位址。如果您是 DHCP 的 Client 端 (比如 Cable Modem),請設定成 BOOTPROTO='dhcp'。
IPADDR=192.168.0.1 設定靜態 IP Address。
NETMASK=255.255.255.0 設定網路遮罩。
NETWORK=192.168.0.0 設定網路位址。
BROADCAST=192.168.0.255 設定廣播位址。
PERSISTENT_NAME=eth0 指定該介面名稱為 eth0。當您存在兩片網卡時,就可以使用這個參數來個別指定介面名稱,這樣就不容易搞混,當然您要是區分得出來,不設定也無所謂啦。p
$vi /etc/resolv.conf 設定DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
$route del default 設定預設路由
$vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=Gacentos-b
GATEWAY=192.168.0.1
Or $route add default gw 192.168.0.1
$/etc/init.d/network restart
設定同一張網卡多組IP
$ifconfig eth0:1 192.168.0.36 netmask 255.255.255.0 up
or
vim /etc/sysconfig/network-scripts/ifcfg-eth0:1
5.安裝VMware Tools
$mkdir /mnt/cdrom
$mkdir /root/vmware
$mount /dev/cdrom /mnt/cdrom
$cp /mnt/cdrom/ VMwareTools-8.3.2-257589.tar.gz /root/vmware/
$cd /root/vmware
$tar –zxf VMwareTools-8.3.2-257589.tar.gz
$cd vmware-tools-distrib
$./ vmware-install.pl
6.關閉SElinux
$cd /etc/sysconfig
$vi selinux
SELINUX=enforcing 改成 SELINUX=disabled
$setenforce 0 //如果沒有重開的話
7.關閉其他service
/sbin/chkconfig yum-updatesd off
/sbin/chkconfig xfs off
/sbin/chkconfig sendmail off
/sbin/chkconfig rpcidmapd off
/sbin/chkconfig rpcgssd off
/sbin/chkconfig portmap off
/sbin/chkconfig pcscd off
/sbin/chkconfig nfslock off
/sbin/chkconfig netfs off
/sbin/chkconfig kudzu off
/sbin/chkconfig ip6tables off
/sbin/chkconfig firstboot off
/sbin/chkconfig gpm off
/sbin/chkconfig bluetooth off
/sbin/chkconfig cups off
/sbin/chkconfig avahi-daemon off
/sbin/chkconfig autofs off
nameserver 8.8.8.8
nameserver 8.8.4.4
$route del default 設定預設路由
$vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=Gacentos-b
GATEWAY=192.168.0.1
Or $route add default gw 192.168.0.1
$/etc/init.d/network restart
設定同一張網卡多組IP
$ifconfig eth0:1 192.168.0.36 netmask 255.255.255.0 up
or
vim /etc/sysconfig/network-scripts/ifcfg-eth0:1
5.安裝VMware Tools
$mkdir /mnt/cdrom
$mkdir /root/vmware
$mount /dev/cdrom /mnt/cdrom
$cp /mnt/cdrom/ VMwareTools-8.3.2-257589.tar.gz /root/vmware/
$cd /root/vmware
$tar –zxf VMwareTools-8.3.2-257589.tar.gz
$cd vmware-tools-distrib
$./ vmware-install.pl
6.關閉SElinux
$cd /etc/sysconfig
$vi selinux
SELINUX=enforcing 改成 SELINUX=disabled
$setenforce 0 //如果沒有重開的話
7.關閉其他service
/sbin/chkconfig yum-updatesd off
/sbin/chkconfig xfs off
/sbin/chkconfig sendmail off
/sbin/chkconfig rpcidmapd off
/sbin/chkconfig rpcgssd off
/sbin/chkconfig portmap off
/sbin/chkconfig pcscd off
/sbin/chkconfig nfslock off
/sbin/chkconfig netfs off
/sbin/chkconfig kudzu off
/sbin/chkconfig ip6tables off
/sbin/chkconfig firstboot off
/sbin/chkconfig gpm off
/sbin/chkconfig bluetooth off
/sbin/chkconfig cups off
/sbin/chkconfig avahi-daemon off
/sbin/chkconfig autofs off
/sbin/chkconfig anacron off
/sbin/chkconfig autofs off
/sbin/chkconfig cpuspeed off
/sbin/chkconfig gpm off
/sbin/chkconfig netfs off
/sbin/chkconfig nfslock off
/sbin/chkconfig portmap off
/sbin/chkconfig rawdevices off
/sbin/chkconfig readahead_early off
/sbin/chkconfig rpcgssd off
/sbin/chkconfig rpcidmapd off
/sbin/chkconfig smartd off
/sbin/chkconfig xfs off
/sbin/chkconfig avahi-daemon off
/sbin/chkconfig firstboot off
/sbin/chkconfig yum-updatesd off
/sbin/chkconfig sendmail off
/sbin/chkconfig mcstrans off
/sbin/chkconfig pcscd off
/sbin/chkconfig bluetooth off
/sbin/chkconfig hidd off
/sbin/chkconfig microcode_ctl off
/sbin/chkconfig irqbalance off
/sbin/chkconfig haldaemon off
/sbin/chkconfig messagebus off
/sbin/chkconfig mdmonitor off
/sbin/chkconfig autofs off
/sbin/chkconfig cpuspeed off
/sbin/chkconfig gpm off
/sbin/chkconfig netfs off
/sbin/chkconfig nfslock off
/sbin/chkconfig portmap off
/sbin/chkconfig rawdevices off
/sbin/chkconfig readahead_early off
/sbin/chkconfig rpcgssd off
/sbin/chkconfig rpcidmapd off
/sbin/chkconfig smartd off
/sbin/chkconfig xfs off
/sbin/chkconfig avahi-daemon off
/sbin/chkconfig firstboot off
/sbin/chkconfig yum-updatesd off
/sbin/chkconfig sendmail off
/sbin/chkconfig mcstrans off
/sbin/chkconfig pcscd off
/sbin/chkconfig bluetooth off
/sbin/chkconfig hidd off
/sbin/chkconfig microcode_ctl off
/sbin/chkconfig irqbalance off
/sbin/chkconfig haldaemon off
/sbin/chkconfig messagebus off
/sbin/chkconfig mdmonitor off
/sbin/chkconfig auditd off
/sbin/chkconfig iscsi off
/sbin/chkconfig iscsid off
/sbin/chkconfig lm_sensors off
/sbin/chkconfig lvm2-monitor off
/sbin/chkconfig restorecond off
/sbin/chkconfig setroubleshoot off
/sbin/chkconfig ip6tables off
/sbin/chkconfig kudzu off
/sbin/chkconfig iscsi off
/sbin/chkconfig iscsid off
/sbin/chkconfig lm_sensors off
/sbin/chkconfig lvm2-monitor off
/sbin/chkconfig restorecond off
/sbin/chkconfig setroubleshoot off
/sbin/chkconfig ip6tables off
/sbin/chkconfig kudzu off
8.線上更新
$yum -y update
9.建立使用者
$useradd cent
$passwd cent
$vi /etc/sudoers
第83行加入
cnet ALL=(ALL) ALL
$su cent
$PATH=$PATH:/sbin:/usr/bin
10修改ssh port 並且不能使用root登入
$vi /etc/ssh/sshd_config
第13行
Port 12846
第39行
PermitRootLogin no
/etc/init.d/sshd restart
注意:如果使用遠端控制設定要小心斷線
11.建立firewall
$vi /sbin/firewall
#!/bin/bash
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -F INPUT
/sbin/iptables -F OUTPUT
/sbin/iptables -F FORWARD
/sbin/iptables -F POSTROUTING -t nat
/sbin/iptables -F PREROUTING -t nat
/sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A INPUT -p icmp -j ACCEPT
$/etc/init.d/iptables save
附加Firewall
# yum -y install lynx
12.更新時間
$ntpdate -s watch.stdtime.gov.tw
$hwclock --systohc
$yum -y update
9.建立使用者
$useradd cent
$passwd cent
$vi /etc/sudoers
第83行加入
cnet ALL=(ALL) ALL
$su cent
$PATH=$PATH:/sbin:/usr/bin
10修改ssh port 並且不能使用root登入
$vi /etc/ssh/sshd_config
第13行
Port 12846
第39行
PermitRootLogin no
/etc/init.d/sshd restart
注意:如果使用遠端控制設定要小心斷線
11.建立firewall
$vi /sbin/firewall
#!/bin/bash
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -F INPUT
/sbin/iptables -F OUTPUT
/sbin/iptables -F FORWARD
/sbin/iptables -F POSTROUTING -t nat
/sbin/iptables -F PREROUTING -t nat
/sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A INPUT -p icmp -j ACCEPT
$/etc/init.d/iptables save
附加Firewall
# yum -y install lynx
12.更新時間
$ntpdate -s watch.stdtime.gov.tw
$hwclock --systohc
13.建立自動更新
#crontab -e
40 5 * * * root yum -y update && yum clean packages
#crontab -e
40 5 * * * root yum -y update && yum clean packages
問題:
Q:忘記root密碼
A:開機按e進入開機選單
在按e進入編輯模式,在最後面加入「single」,按Enter,回開機選單
安B進入root
$setenforce 0 //關閉Selinux
$passwd //修改密碼。
Q:忘記root密碼
A:開機按e進入開機選單
在按e進入編輯模式,在最後面加入「single」,按Enter,回開機選單
安B進入root
$setenforce 0 //關閉Selinux
$passwd //修改密碼。
沒有留言:
張貼留言