簡(jiǎn)單CentOS配置步驟
CentOS是Linux發(fā)行版之一,它是來自于Red Hat Enterprise Linux依照開放源代碼規(guī)定釋出的源代碼所編譯而成。這次,我們主要來學(xué)習(xí)一下簡(jiǎn)單的CentOS配置。
(一)CentOS配置YUM:
國(guó)內(nèi)最快的源:http://centos.ustc.edu.cn/
我安裝CentOS 5的方法:
下載centos/5.4 CentOS-5.4-i386(或x86_64)-netinstall.iso,刻盤安裝CentOS5.4,安裝地方設(shè)置為HTTP,Server centos.ustc.edu.cn, 目錄 為centos/5.4/os/i386 或 centos/5.4/os/x86_64。
安裝后請(qǐng)按照以下步驟修改CenOS-Base.repo,以后就可以方便的用yum安裝軟件了.
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.save
wget http://centos.ustc.edu.cn/CentOS-Base.repo.5
mv CentOS-Base.repo.5 CentOS-Base.repo
RHEL = Red Hat Enterprise Linux
EPEL :
EPEL(http://fedoraproject.org/wiki/EPEL ) 是由 Fedora 社區(qū)打造,為 RHEL 及衍生發(fā)行版如 CentOS、Scientific Linux
等提供高質(zhì)量軟件包的項(xiàng)目。裝上了 EPEL,就像在 Fedora 上一樣,可以通過 yum install package-name,隨意安裝軟件。
我們前面提到的 Func 、Cobbler 等軟件都能在 EPEL Repo 中找到。
安裝 EPEL 非常簡(jiǎn)單:
* RHEL 4: rpm -Uvh http://download.fedora.redhat.com/pub/epel/4/i386/epel-release-4-9.noarch.rpm
* RHEL 5: rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
安裝完畢之后,即可使用 yum 來安裝軟件,比如 nginx
yum install nginx
(二)CentOS配置時(shí)修改打開文件數(shù):
在 /etc/security/limits.conf 增加:
soft nofile 65535
hard nofile 65535
(三)CentOS配置時(shí)安裝c/c++編譯
yum install ncurses-devel (安裝nload 需要次lib)
yum insall gcc gcc-c++
(四)CentOS配置時(shí)安裝nload
安裝環(huán)境RHEL5 nload 0.7.2 下載路徑:
http://www.roland-riegel.de/nload/index.html (建議用IE下載)142KB
tar zxvf nload-0.7.2.tar.gz
cd nload-0.7.2
./configure
make
make install
(五)CentOS配置時(shí)安裝net-snmpd
yum instll net-snmp
編輯 /etc/snmp/snmpd.conf
刪除其他,只留下這一行:
rocommunity public 121.14.117.52(cacti安裝的機(jī)器的ip)
(六)CentOS配置時(shí)配置 同步工具 rsync
[root@localhost html]# nano -w /home/zyh/rsync_client.sh
#/bin/bash
/usr/bin/rsync -auv --progress 219.134.132.75::html /data/html
(七)CentOS配置時(shí)增加用戶:
#useradd zyh -m -G users,wheel -s /bin/bash
配置sudo
#visudo
zyh ALL=(ALL) ALL
(八)CentOS配置時(shí)設(shè)置時(shí)區(qū)和同步時(shí)鐘
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
或者使用 tzselect 命令 選擇時(shí)區(qū)
沒安裝ntp 的先安裝: yum install ntpdate
yum install -y ntpdate
crontab -e
0 5 * * * /usr/sbin/ntpdate stdtime.gov.hk
(九)CentOS配置時(shí)解決putty 中文亂碼問題
如果系統(tǒng)語(yǔ)言環(huán)境設(shè)置為簡(jiǎn)體中文,使用putty 登陸后,可以有些中文看到是亂碼。
這是putty和centOS的語(yǔ)言環(huán)境不一樣導(dǎo)致的,可以在putty 設(shè)置跟centOS一樣語(yǔ)言環(huán)境
解決這個(gè)問題,putty-->window-->translation-->Received data assumed to be in which character set:(選擇相應(yīng)的編碼)。
例如:centOS:
cat /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
putty :相應(yīng)選擇:UTF-8
這樣就可以解決中文亂碼的問題
(十)CentOS配置時(shí)修改默認(rèn)語(yǔ)言
vi /etc/sysconfig/i18n
改成LANG=”en_US.UTF-8″
然后生效配置文件
source /etc/sysconfig/i18n
重新登陸后,發(fā)現(xiàn)語(yǔ)言環(huán)境已經(jīng)變?yōu)橛⑽?/P>
(十一)CentOS配置時(shí)設(shè)置網(wǎng)卡
vi /etc/sysconfig/network-scripts/ifcfg-eth0
#service network restart
(十二)CentOS配置時(shí)更改主機(jī)名
vi /etc/sysconfig/network
HOSTNAME=yourhostname
(十三)CentOS配置時(shí)修改DNS,用opendns,當(dāng)然也可以用機(jī)房提供的.
vi /etc/resolv.conf
nameserver 208.67.222.222
nameserver 208.67.220.220
(十四)CentOS配置時(shí)更新常用編譯工具包
yum install -y glibc* cpp gcc* openssl* make
yum update -y
(十五)CentOS配置時(shí)關(guān)閉selinux
使用文本編輯工具打開 /etc/selinux/config
把 SELINUX=enforcing 注釋掉:#SELINUX=enforcing ,然后新加一行為:SELINUX=disabled
保存,關(guān)閉。
重啟系統(tǒng)。或開放防火墻 80端口:
通過/etc/init.d/iptables status命令查詢是否有打開80端口,如果沒有可通過兩種方式處理:
1.修改vi /etc/sysconfig/iptables命令添加使防火墻開放80端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
2.關(guān)閉防火墻
/etc/init.d/iptables stop
#start 開啟
#restart 重啟
***性關(guān)閉防火墻chkconfig --level 35 iptables off
這些CentOS配置只是一些簡(jiǎn)單的,如果要想更深入的研究使用,需要更多的知識(shí)。
【編輯推薦】