freebsd 8.1-基本配置(网络、port、package、x11、gnome)



 本文由深未来原创:http://deepfuture.iteye.com/,转载,请注明出处。

1、配置登录用户可以具有SU的权限,就是可以转到root用户。

直接修改/etc/group文件,把相应的用户加到wheel组就可以
      wheel:*:0:root,username

本文由深未来原创:http://deepfuture.iteye.com/,转载,请注明出处。


2、配置网卡

1)查看网卡

ifconfig

rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 00:0a:eb:69:5d:a1
        inet 192.168.1.168 netmask 0xffffff00 broadcast 192.168.1.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
rl1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 00:0a:eb:5c:25:87
        media: Ethernet autoselect
        status: no carrier
plip0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> metric 0 mtu 1500
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
        inet6 ::1 prefixlen 128
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>

本机有2块网卡,我只使用其中一块:rl0

本文由深未来原创:http://deepfuture.iteye.com/,转载,请注明出处。

2)

A)配置IP和网关

/etc/rc.conf

ee /etc/rc.conf

# -- sysinstall generated deltas -- # Tue Jan  1 08:21:16 2002
# Created: Tue Jan  1 08:21:16 2002
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
inetd_enable="YES"
sshd_enable="YES"
ifconfig_rl0="inet 192.168.1.168 netmask  255.255.255.0" 
defaultrouter="192.168.1.1"

其中ifconfig_rl0为配置网卡1,网关为192.168.1.1

B)配置dns

ee /etc/resolv.conf

=====line 2 col 24 lines from top 2 ===========================================
nameserver 58.20.127.170
nameserver 58.20.127.238

C)重新启动,生效:

reboot

D)测试是否成功

# ping www.163.com
PING 163.xdwscache.glb0.lxdns.com (58.248.245.40): 56 data bytes
64 bytes from 58.248.245.40: icmp_seq=0 ttl=55 time=38.687 ms
64 bytes from 58.248.245.40: icmp_seq=1 ttl=55 time=40.063 ms
64 bytes from 58.248.245.40: icmp_seq=2 ttl=55 time=118.553 ms
64 bytes from 58.248.245.40: icmp_seq=3 ttl=55 time=40.267 ms
64 bytes from 58.248.245.40: icmp_seq=5 ttl=55 time=39.294 ms

3、port ,是指从源代码安装,但是这个源代码是经过整理的,在port的管理下,而且可以通过port来自动升级和管理。

1)ports collection

A)如果ports collection没有安装则:

可以通过使用sysinstall命令安装ports collection,在不联网的情况下。

在联网的情况下,可以如下操作

先删除/usr/ports目录下的所有文件

# cd /usr/ports
# ls
.cvsignore      README          benchmarks      dns             hungarian       multimedia      print           x11
CHANGES         Templates       biology         editors         irc             net             russian         x11-clocks
COPYRIGHT       Tools           cad             emulators       japanese        net-im          science         x11-drivers
GIDs            UIDs            chinese         finance         java            net-mgmt        security        x11-fm
INDEX-8         UPDATING        comms           french          korean          net-p2p         shells          x11-fonts
KNOBS           accessibility   converters      ftp             lang            news            sysutils        x11-servers
LEGAL           arabic          databases       games           mail            palm            textproc        x11-themes
MOVED           archivers       deskutils       german          math            polish          ukrainian       x11-toolkits
Makefile        astro           devel           graphics        mbone           ports-mgmt      vietnamese      x11-wm
Mk              audio           distfiles       hebrew          misc            portuguese      www

 # rm -rf /usr/ports/*

#cp /usr/share/examples/cvsup/ports-supfile /root/ports-supfile

#ee /root/ports-supfile

# prefix=/usr
#               This specifies where to place the requested files.  A
#               setting of "/usr" will place all of the files requested
#               in "/usr/ports" (e.g., "/usr/ports/devel", "/usr/ports/lang").
#               The prefix directory must exist in order to run CVSup.

# Defaults that apply to all the collections
#
# IMPORTANT: Change the next line to use one of the CVSup mirror sites
# listed at http://www.freebsd.org/doc/handbook/mirrors.html .
*default host=cvsup.FreeBSD.org     
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=.

然后开始安装ports collection

# csup -L 2 /root/ports-supfile
Parsing supfile "/root/supfile"
Connecting to cvsup.FreeBSD.org
Connected to 72.233.193.64
Server software version: SNAP_16_1h
Negotiating file attribute support
Exchanging collection information

查看ports collection

 # cd /usr/ports
# ls
.cvsignore      KNOBS           Mk              UIDs            archivers       biology         converters
CHANGES         LEGAL           README          UPDATING        astro           cad             databases
COPYRIGHT       MOVED           Templates       accessibility   audio           chinese         deskutils
GIDs            Makefile        Tools           arabic          benchmarks      comms           devel

B)如果ports collection已经安装,则安装portsnap,portsnap可以更快地管理ports

安装protsnap

#pkg_add -r portsnap

获得数据

#portsnap fetch

如果你是第一次使用portsnap,则展开它

#portsnap extract

更新ports

#portsnap update

2)安装 ports

以安装 sqlite为例

# cd databases/sqlite34

# make

===>  Vulnerability check disabled, database not found
===>  License check disabled, port has not defined LICENSE
===>  Found saved configuration for sqlite34-3.4.2
=> sqlite-3.4.2.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/local-distfiles/mnag/sqlite34/ .
sqlite-3.4.2.tar.gz                           100% of 2321 kB   60 kBps 00m00s
===>  Extracting for sqlite34-3.4.2
=> SHA256 Checksum OK for sqlite-3.4.2.tar.gz.
===>  Patching for sqlite34-3.4.2
===>   Converting DOS text file to UNIX text file:
===>  Applying FreeBSD patches for sqlite34-3.4.2
===>   sqlite34-3.4.2 depends on executable: tclsh8.5 - not found
===>    Verifying install for tclsh8.5 in /usr/ports/lang/tcl85
     => No directory for tclsh8.5.  Skipping..
===>   sqlite34-3.4.2 depends on executable: gmake - not found
===>    Verifying install for gmake in /usr/ports/devel/gmake
===>  Vulnerability check disabled, database not found
===>  License check disabled, port has not defined LICENSE
=> make-3.81.tar.bz2 doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://ftp.gnu.org/gnu/make/ .

#make install

#make clean

===>  Cleaning for tcl-8.5.9
===>  Cleaning for gmake-3.81_4
===>  Cleaning for libtool-2.2.10
===>  Cleaning for pkg-config-0.25_1
===>  Cleaning for tcl-modules-8.5.9
===>  Cleaning for gettext-0.18.1.1
===>  Cleaning for libiconv-1.13.1_1
===>  Cleaning for sqlite34-3.4.2

2)查看哪些ports需要升级

# pkg_version -v
en-freebsd-doc-20100625             <   needs updating (port has 20110110)
gettext-0.18.1.1                    =   up-to-date with port
gmake-3.81_4                        =   up-to-date with port
libiconv-1.13.1_1                   =   up-to-date with port
libtool-2.2.10                      =   up-to-date with port
pkg-config-0.25_1                   =   up-to-date with port
sqlite34-3.4.2                      =   up-to-date with port
tcl-8.5.9                           =   up-to-date with port
tcl-modules-8.5.9                   =   up-to-date with port
zh_cn-freebsd-doc-20100625          <   needs updating (port has 20110110)

 本文由深未来原创:http://deepfuture.iteye.com/,转载,请注明出处。

4、package

1)列出所有安装的软件包

# pkg_info
en-freebsd-doc-20100625 Documentation from the FreeBSD Documentation Project
gettext-0.18.1.1    GNU gettext package
gmake-3.81_4        GNU version of 'make' utility
libiconv-1.13.1_1   A character set conversion library
libtool-2.2.10      Generic shared library support script
pkg-config-0.25_1   A utility to retrieve information about installed libraries
sqlite34-3.4.2      An SQL database engine in a C library
tcl-8.5.9           Tool Command Language
tcl-modules-8.5.9   Tcl common modules
zh_cn-freebsd-doc-20100625 Simplified Chinese translation of the FreeBSD Documentation
2)下载并安装软件,以portupdate为例

# pkg_add -r portupgrade
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.1-release/Latest/portupgrade.tbz ... Done.
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.1-release/All/ruby-1.8.7.248_2,1.tbz ...
3)portupgrade 可用于升级现有软件包

portupgrade -ai 升级所有包

portupgrade  包名

查看某个软件包的信息

# whereis portupgrade
portupgrade: /usr/local/sbin/portupgrade /usr/local/man/man1/portupgrade.1.gz /usr/ports/ports-mgmt/portupgrade

修正

#pkgdb -f

升级

# /usr/local/sbin/portupgrade -ai
--->  Session started at: Tue, 18 Jan 2011 20:27:55 +0800
/usr/ports/INDEX-8.bz2                        100% of 1447 kB   47 kBps 00m00s

5、x11

#cd /usr/ports/x11/xorg

#make install clean

 本文由深未来原创:http://deepfuture.iteye.com/ ,转载,请注明出处。

然后编辑/etc/rc.conf

hald_enable=yes
dbus_enable=yes 

重新启动电脑

#reboot

查看startx目录

# whereis startx
startx: /usr/local/bin/startx /usr/local/man/man1/startx.1.gz

首先启动一下能否运行

#/usr/local/bin/startx

然后按alt+shift+Fn,通常是alt+shift+F2,进入虚拟控制台后,重新启动电脑

#reboot
建立配置文件

# Xorg -configure

X.Org X Server 1.7.5
Release Date: 2010-02-16
X Protocol Version 11, Revision 0
Build Operating System: FreeBSD 8.1-RELEASE i386
Current Operating System: FreeBSD  8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010     [email protected]:/usr/obj/usr/src/sys/GENERIC i386

会在/root中生成一个叫做xorg.conf.new的配置文件
测试配置是否成功

#Xorg -config /root/xorg.conf.new -retro

进入虚拟控制台,然后重启电脑

再配置屏幕

#ee /root/xorg.conf.new

刷新率配置

Section "Monitor"
        #DisplaySize      300   230     # mm
        Identifier   "Monitor0"
        VendorName   "SAM"
        ModelName    "SyncMaster"
        HorizSync    30.0 - 61.0
        VertRefresh  56.0 - 75.0
        Option      "DPMS"
EndSection
分辨率和色深配置screen节,DefaultDepth指定默认色深

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        DefaultDepth 24

        SubSection "Display"
                Viewport   0 0
                Depth     24
                Modes "1024x768"
        EndSubSection

特殊显示环境配置

首先需要知道驱动程序对应的ModeLines

ee /var/log/Xorg.0.log 找到足够的信息

ModeLine格式如下:

ModeLine 分辨率 时钟 <4 horiz.timings> <4 vert.timings> 

比如:

Modeline "1024x768"   65.00  1024 1048 1184 1344  768 771 777 806

然后设置/root/xorg.conf.new

Modeline "1024x768"   65.00  1024 1048 1184 1344  768 771 777 806

Section "Monitor"
        Identifier   "Monitor0"
        VendorName   "SAM"
        ModelName    "MybestModel"

        Modeline "1024x768"   65.00  1024 1048 1184 1344  768 771 777 806
        HorizSync    30.0 - 61.0
        VertRefresh  56.0 - 75.0
        Option      "DPMS"
EndSection

然后再测试,

#Xorg -config /root/xorg.conf.new -retro

成功后就可以将配置文件保存了

# cp /root/xorg.conf.new /etc/X11/xorg.conf

启动xorg

#startx


按alt+ctrl+Fn来切换到用于启动X的虚拟控制台

退出x环境

6、gnome

1)安装gnome2 

为防止安装过程出错,可以先更新ports

#portupgrade -a

再安装,可以使用2种方法安装

A)ports

#cd /usr/ports/x11/gnome2

#make install clean

B)package

#pkg_add -r gnome2

2)配置

如果事先已经使用了一些旧式的显示管理器,则必须取代这些管理器:

echo "#!/bin/sh" >~/.xinitrc

echo "/usr/local/bin/gnome-session">> ~/.xinitrc

chmod +x ~/.xsession

如果没有,则:

echo "/usr/local/bin/gnome-session"> ~/.xinitrc

然后reboot

最后启动

startx

中文环境配置

#cd ~         \\切换到用户根目录
#ee .cshrc  

加入下面的内容:
setenv LANG zh_CN.eucCN              (或  export  LANG='zh_CN.eucCN' )
setenv LC_LANG zh_CN.eucCN           (或  export  LC_LANG='zh_CN.eucCN' )
保存、退出、重启电脑,登陆后运行startx,进入Gnome,此时界面已经是中文版。

3)如果你想使用gdm,则需要安装

首先保证startx能正常启动GNOME,然后

A)安装

先卸载

#pkg_delete gdm或

#cd /usr/ports/x11/gdm

#make deinstall

然后安装

#cd /usr/ports/x11/gdm

#make install clean

B)激活gdm

#cp /usr/X11R6/etc/rc.d/gdm  /usr/local/etc/rc.d/gdm.sh

C)gdm配置为自动启动

# ee /etc/rc.conf

# -- sysinstall generated deltas -- # Fri Jan 14 08:23:27 2005
# Created: Fri Jan 14 08:23:27 2005
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
hald_enable=yes            
dbus_enable=yes            
inetd_enable="YES"         
moused_enable="YES"        
ntpdate_enable="YES"       
gdm_enable="YES"    

 本文由深未来原创:http://deepfuture.iteye.com/ ,转载,请注明出处。

如果你想使用gnome的所有服务,可以使用

gnome_enable="YES"   

猜你喜欢

转载自deepfuture.iteye.com/blog/875847