LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 911|回复: 1

The X Server Configuration HOWTO

[复制链接]
发表于 2007-4-1 17:01:35 | 显示全部楼层 |阅读模式
[size=+2]The X Server Configuration HOWTO

X服务器配置指南

原文更新时间: February 17, 2007
从zhllg介绍这篇文章让我读以来,啃了几天,里面还不知有多少问题,故将原文奉上,还望大家指点一二,以便真正安装好 Xorg的配置文件。

内容简介: Xorg是一个允许用户通过简单的设置来使用图形界面环境的X Windows服务
器。这篇指南解释了什么是Xorg,如何配置基本的Xorg以及其它相关的各种基本配置选项。

1. 什么是X Window 服务器?
2. 安装 Xorg
3. 配置 Xorg
4。优化xorg.conf
5. 资源

1. 什么是X Window 服务器?

图形界面 与 命令行


       大多数用户对于命令行的使用感到害怕。既然Gentoo(或者其他的Linux 发行版)给我们提供了一定的自由度,为什么我们不能通过点击来完成我们的工作?(是的,你当然可以这么做 :-) Linux提供了许多优秀的用户界面和环境,你可以在现有的系统基础上来对它们进行安装配置。


       一个最让新用户十分惊奇的事是:一种图形用户界面并不比运行在系统上的一个应用程序多什么东西。它不是Linux内核的一部分,也没有集成在你的系统里。它是一个可以为你的工作站提供图形界面的强大工具。


       由于标准的重要性,用户通过基本的鼠标和键盘及其它重要的方面在屏幕上绘制和移动来实现与程序间的互动,而创建一种标准,这种标准就叫做X Window 系统,它常常缩写为 X11 或者X。它常应用于Unix,Linux,以及类似Unix的操作系统上。


       为Linux用户提供运行图形界面能力并且使用X11标准的应用程序是Xorg-X11―― XFree86项目的一个分支。XFree86决定使用与GPL不共用的许可证,使用 Xorg因此被推荐。公开的portage 树不再支持任何一个XFree86软件包。


X.org 项目

.
       X.org项目创建并且维护了一个自由的redistributable,X11系统的开源工具它是一个基于X11开源桌面的基础结构。


       Xorg在你的硬件和想运行的图形界面软件之间提供了一个接口。除此之外,Xorg完全具有网络意识,这意味着当你在一个系统上运行一个程序时,可以在另一个系统上查看它。


2. 安装 Xorg

用 emerge

       闲聊至此,让我们开始做正事吧。要安装Xorg,你需要运行emerge xorg-x11。但安装Xorg确实需要一段时间,因此在你正在等待时,你可以吃一点点心。

Before installing Xorg you have to configure two important variables in the /etc/make.conf file
         安装xorg之前,你必须在/etc/make.conf文件中配置二个重要的参数。

The first one is VIDEO_CARDS. This is used to set the video drivers that you intend to use and is usually based on the kind and brand of card you have. The most common settings are nvidia for Nvidia cards or fglrx for ATI Radeon cards. Those are the proprietary drivers from Nvidia and ATI respectively. If you would like to use the open source versions, use nv rather than nvidia in the variable, but bear in mind that using this driver means no 3d acceleration at all. Use radeon in case you have an ATI card for the same. VIDEO_CARDS may contain more than one driver, in this case list of them should be separated with spaces.

       第一个是VIDEO_CARDS. 它常被用来设置为你打算使用的显示驱动和依据你现有显卡的种类。最通用的设置是nvidia 为Nvidia 显卡或fglrx 为ATI Radeon 显卡。那些是Nvidia 和ATI 各自私有的驱动。如果 您想使用开源版本, 在这个变量中用nv 而不是nvidia , 但记住, 使用这个驱动意味着根本没有3d 加速度。使用radeon 如果您有一张ATI 显卡也是同样。 VIDEO_CARDS 也许包含超过一个驱动, 在这种情况下他们的名单用空格被分离开。

The second variable is INPUT_DEVICES and is used to determine which drivers are to be built for input devices. In most cases setting it to keyboard mouse should work just fine.

     第二个参数是INPUT_DEVICES,它常常用来确定要构建哪个输入设备,大多数的情况设置键盘鼠标为良好地运行。

Now you should decide which drivers you will use and add necessary settings to the /etc/make.conf file:

    现在你应该决定在/etc/make.conf中你将用哪种驱动和需要的设置。

代码2。1: make.conf的例子

  1. (For mouse and keyboard support) //键盘鼠标支持
  2. INPUT_DEVICES="keyboard mouse"
  3. (For Nvidia cards)//对Nvidia显卡
  4. VIDEO_CARDS="nvidia"
  5. (OR, for ATI Radeon cards)//对所有Radeon显卡
  6. VIDEO_CARDS="fglrx"
复制代码



More instructions on how to configure Nvidia and ATI cards can be found in Gentoo Linux nVidia Guide and in Gentoo Linux ATI FAQ. If you don't know which drivers you should choose, refer to these guides for more information.

    关于如何配置Nvidia和ATI显卡的指示,你能在Gentoo Linux nVidia Guide和Gentoo Linux ATI FAQ中找到更多。如果你不知道你应该选择哪一个,参考手册中的更多信息。

Note: If the suggested settings don't work for you, you should run emerge -pv xorg-x11, check all the options available and choose those which apply to your system. In different versions of Xorg and on different architectures displaying these variables can be done with emerge -pv xorg-server commandrather than the one above. The example is for x86 architecture and xorg-x11-7.0.

   注意:如果 建议的设置对你来说,不能正常运行,你应该运行 emerge -pv xorg-x11, 检查所有可以利用的选项,随后选择加入到你的系统中。在不同的Xorg版本和不同的显卡结构中,用emerge -pv xorg-server命令查找这些变量而不是上面的哪个。这个例子是对x86结构和xorg-x11-7.0来说的。

代码2。2: 显示所有可利用的驱动

  1. # emerge -pv xorg-x11
  2. These are the packages that would be merged, in order:
  3. Calculating dependencies... done!
  4. [ebuild   R   ] x11-base/xorg-x11-7.0-r1  USE="-3dfx" INPUT_DEVICES="keyboard
  5. mouse -acecad -aiptek -calcomp -citron -digitaledge -dmc -dynapro -elo2300 -
  6. elographics -evdev -fpit -hyperpen -jamstudio -joystick -magellan -magictouch
  7. -microtouch -mutouch -palmax -penmount -spaceorb -summa -synaptics -tek4957 -ur98 -vmmouse -void -wacom" VIDEO_CARDS="nvidia -apm -ark -chips -cirrus -cyrix -dummy -fbdev -fglrx -glint -i128 -i740 -i810 -imstt -mach64 -mga -neomagic -nsc -nv -r128 -radeon -rendition -s3 -s3virge -savage
  8. -siliconmotion-sis -sisusb -tdfx -tga -trident -tseng -v4l -vesa -vga -via
  9. -vmware -voodoo" 0kB
复制代码

  
    设置完所有必须的参数后,可以安装Xorg包了,

代码 2.1: 安装 Xorg

  1. # emerge xorg-x11
复制代码


When the installation is finished, you might need to re-initialise some
environment variables before you continue. Just run env-update followed by
source /etc/profile and you're all set.
        安装结束后,你可能需要重新初始化一些变量后才能继续。只需要运行env-
update 后再运行source /etc/profile就可完成这一工作。您是全部设置过了。

代码 2.2: 重新初始化环境变量
  1. # env-update
  2. # source /etc/profile
复制代码



3. 配置 Xorg

xorg.conf 文件

The configuration file of Xorg is called xorg.conf and it resides in
/etc/X11. The Xorg-X11 package provides an example configuration as
/etc/X11/xorg.conf.example which you can use to create your own
configuration. It is heavily commented, but if you are in need of more
documentation regarding the syntax, don't hesitate to read the man page:

       Xorg的配置文件名叫xorg.conf,它存在/etc/X11中。 Xorg-X11软件包提供了一
个/etc/X11/xorg.conf.example的样本配置文件。如果你需要更多的相关语法的文档,
这有一个更全面的介绍,推荐你阅读man帮助手册:

代码 3.1: 阅读xorg.conf帮助手册
  1. # man 5 xorg.conf
复制代码


Happy reading for those of you willing to. We surely don't so we'll continue
with checking out how we can create the file automatically.
      快乐地阅读那些您想要了解的文档。我们相信不是这样的,所以请继续看如何自
动创建配置文件。

默认操作: 自动创建xorg.conf

Xorg itself is able to guess most parameters for you. In most cases, you will
only have to change some lines to get the resolution you want up and running.
If you are interested in more in-depth tweaking, be sure to check the
resources at the end of this chapter. But first, let us generate a (hopefully
working) Xorg configuration file

       Xorg可以自动为你配置好大多数的选项。在多数情况下,你只需要修改其中的某
些行列来调整你想要的分辨率。如果你对深层次的优化感兴趣,那么请阅读文章最后所
提供的资源。但首先,让我们生成一个Xorg配置文件(希望正常工作)。

代码 3.2: 创建xorg.conf文件
  1. # Xorg -configure
复制代码

Be sure to read the last lines printed on your screen when Xorg has finished
probing your hardware. If it tells you it failed at some point, you're forced
to manually write an xorg.conf file. Assuming that it didn't fail, it will
have told you that it has written /root/xorg.conf.new ready for you to test.
So let's test

       当Xorg检测完你的硬件后,请务必注意屏幕上的最后一行显示。如果它告诉你某
个地方检测失败,那么你就不得不手工编辑一个xorg.conf文件;如果没有,那么它会告
诉你 /root/xorg.conf.new已经创建并可以供你测试了。那么,就让我们测试一下吧

Code Listing 3.3: Testing the xorg.conf.new file
代码 3.3: 测试你的xorg.conf.new文件
  1. # Xorg -config /root/xorg.conf.new
复制代码

If all goes well, you should see a simple black and white pattern. Verify if
your mouse works correctly and if the resolution is good. If you received
errors about "/dev/mouse", try changing your mouse device to /dev/input/mice
in the "InputDevice" section of xorg.conf. You might not be able to deduce
the exact resolution, but you should be able to see if it's too low. You can
exit any time by pressing Ctrl-Alt-Backspace.

       如果一切顺利,你会看到一个简单的黑白相间的样式 核实你的鼠标正常运行并
且屏幕分辨率正好。如果你得到关于“/etc/mouse”的错误,试着在xorg.con
的"InputDevice"选项中改变你的鼠标驱动为/dev/input/mice。你也许不能确定正确的
分辩率,但你应该能看到它是否显示太低的分辩率。你可以在任何时间按下Ctrl-Alt-
Backspace来退出。


可选操作: 半自动创建xorg.conf

Xorg provides a tool called xorgconfig which will ask you for various
information regarding your system (graphical adapter, keyboard, ...). Based
on your input it will create a xorg.conf file.
       Xorg提供了一个名叫xorgconfig的工具,它将询问你有关系统的各种信息(图
适配器、键盘……),并根据你输入的信息来创建xorg.conf文件。

代码 3.4: 半自动创建xorg.conf
  1. # xorgconfig
复制代码


Another tool, also provided by Xorg, is xorgcfg, which will first attempt to
run Xorg -configure and then start the X server for more final tweaking.
    另一个工具,也被Xorg支持,它是xorgcfg,  它将首先试运行Xorg -configure,随
后为更多的最后优化启动X服务器  。

代码3。5:使用xorgcfg

  1. # xorgcfg
  2. (In case X crashes or the configuration fails, try:)//X崩溃或者配置失败,试:
  3. # xorgcfg -textmode
复制代码



复制xorg.conf

Let us copy over the xorg.conf.new to /etc/X11/xorg.conf now, so we won't
have to continuously run X -config -- typing just X or startx is far more
easy
       先让我们将xorg.conf.new复制为/etc/X11/xorg.conf,这样我们不必连续运行
Xorg -config了――直接输入startx显然要轻松得多。


代码 3.6: 复制xorg.conf
  1. # cp /root/xorg.conf.new /etc/X11/xorg.conf
复制代码



   使用 startx

Now try startx to start up your X server. startx is a script that executes an
X session, that is, it starts the X servers and some graphical applications
on top of it. It decides which applications to run using the following logic:
    现在开始试用startx来启动X服务器。startx是一个可执行的X session脚本。这就
是说,它启动了X服务器和在它上面的一些图形应用程序。用下面的逻辑,它决定运行那
些应用程序:

      *If a file named .xinitrc exists in the home directory, it will execute
the commands listed there.
      *如果在家目录有文件名为.xinitrc的文件存在, 它将执行那里列出的命令。

      *Otherwise, it will read the value of the XSESSION variable and will
execute one of the sessions available in /etc/X11/Sessions/ accordingly (you
can set the value of XSESSION in /etc/rc.conf to make it a default for all
the users on the system).

      * 否则,它将读XSESSION参数的变量值,并且将相应地执行在/etc/X11/Sessions/中可利用sessions的一个(你能在/etc/rc.conf中设置XSESSION的变量,并让它成为所有的系统用户的默认值。)

    *If all of the above fail, it will fall back to a simple window manager,
usually twm.
    *如果上述都失败了,它将回到一个简单的窗口管理器,一般为twm.

代码3。7: 启动X
  1. # startx[/coe]
  2. If you see an ugly, loathsome, repulsive, deformed window manager, that's
  3. twm. To finish the twm session, type in exit or Ctrl-D in the upcoming
  4. xterms. You can also kill the X session using the Ctrl-Alt-Backspace
  5. combination. This will however make X exit disgracefully -- something that
  6. you might not always want. It doesn't hurt though :)

  7.        如果你看到一个不美观的、令人讨厌的、不成形的的窗口管理器,它是twm.要结
  8. 束twm session,在活动的xterms中输入exit或者直接按下Ctrl-D 组合键即可,你可以
  9. 按下Ctrl-Alt-Backspace来终止X服务器。这将使你的X无碍地退出――这类事,你并不
  10. 想这样做。虽然,这对你的系统并无大碍 :)

  11. 4。优化xorg.conf

  12. 设置分辨率

  13. If you feel that the screen resolution is wrong, you will need to check two
  14. sections in your configuration. First of all, you have the Screen section
  15. which lists the resolutions, if any that your X server will run at. By
  16. default, this section might not list any resolutions at all. If this is the
  17. case, Xorg will estimate the resolutions based on the information in the
  18. second section, Monitor.

  19.        如果你觉得屏幕分辨率有问题,你需要检查配置文件中的两个段落。首先看看列
  20. 出了分辨率的Screen段落,是否你的服务器在任一*(部分)运行。在默认情况下,这个
  21. 段落根本不列出任何分辨率。如果是这种情况,Xorg将根据Monitor段落中的信息来给出
  22. 一个大概的分辨率。

  23. What happens is that Xorg checks the settings of HorizSync and VertRefresh in
  24. the Monitor section to compute valid resolutions. For now, leave these
  25. settings as-is. Only when the changes to the Screen section (which we will
  26. describe in a minute) don't work, then you will need to look up the specs for
  27. your monitor and fill in the correct values. You can also use a tool that
  28. searches for your monitor's specs, such as sys-apps/ddcxinfo-knoppix.

  29.        Xorg检查Monitor段落中的HorizSync和VertRefresh 设置并计算出一个有效的分
  30. 辨率时,会出现什么。眼下,先把这些设置放到一边,只有当Screen段落(接下来将会提到)中更改后的设置无法正常工作时,你才需要看看你的显示器相关规格然后赋予正确的数值。你也可以使用工具来检测你的显示器规格,比如sys-apps/ddcxinfo-knoppix。

  31. Warning: Do not "just" change the values of these two monitor related
  32. variables without consulting the technical specifications of your monitor.
  33. Setting incorrect values lead to out-of-sync errors at best and smoked up
  34. screens at worst

  35. 警告:不要在没有考虑您的显示器的技术规格的情况下更改这两个与显示器规格有关的
  36. 变量,设置不正确值最好的结局是会导致不同步的错误,最坏结局则是会烧坏显示器。

  37. Now let us change the resolutions. In the next example from
  38. /etc/X11/xorg.conf we add the Modes lines and the DefaultDepth so that our X
  39. server starts with 24 bits at 1024x768 by default. Don't mind the given
  40. strings -- they are examples and will most likely differ from the settings on
  41. your system.

  42.        现在让我们来更改分辨率。在接下来的/etc/X11/xorg.conf的例子中,我们将加
  43. 入Modes和DefaultDepth使X服务器用24位色深和1024x768分辨率作为默认值启动。不要
  44. 在意下面给出的字符――它只是一个样本,并且里面的多数设置可能与你的计算机设置
  45. 不同。

  46. 代码 4.1: 修改/etc/X11/xorg.conf中的Screen段落
  47. [code]Section "Screen"
  48.   Identifier  "Default Screen"
  49.   Device    "S3 Inc. ProSavage KN133 [Twister K]"
  50.   Monitor   "Generic Monitor"
  51.   DefaultDepth  24
  52. # Skipping some text to improve readability
  53. # 为了便于寻找和阅读请跳过一些内容
  54.   SubSection "Display"
  55.     Depth   24
  56.     Modes   "1024x768"
  57.   EndSubSection
  58. EndSection
复制代码


       运行X (startx),看它是否启用了你所需要的分辨率

配置键盘

To setup X to use an international keyboard, search for the InputDevice
section that configures the keyboard and add the XkbLayout option to point to
the keyboard layout you want. As an example, we show you how to apply for the Belgian layout. Just substitute the country-keycode with yours:

     要设置X使用国际键盘的布局,请找到与键盘设置相关的InputDevice段落,并且加
入XkbLayout 选项来指明你想使用的键盘布局。比如,接下来我们将为你说明如何应用
比利时的键盘布局。你只需要将国家代码替换为你自己的即可。


代码 4.2: 更改键盘布局
  1. Section "InputDevice"
  2.   Identifier  "Generic Keyboard"
  3.   Driver    "keyboard"
  4.   Option    "CoreKeyboard"
  5.   Option    "XkbRules"  "xorg"
  6.   Option    "XkbModel"  "pc105"
  7.   Option    "XkbLayout" "be"
  8. EndSection
复制代码


配置鼠标

If your mouse isn't working, you will first need to find out if it is
detected by the kernel at all. Mice are (device-wise) seen as
/dev/input/mouse0 (or /dev/input/mice if you want to use several mice). In
some cases /dev/psaux is used. In either case you can check if the devices do
represent your mouse by checking the output of those files when you move your mouse. You will usually see some junk on your screen. To end the session
press Ctrl-C.

       如果你的鼠标没有正常工作,你应该首先检查你的鼠标是否已经被系统内核检测到。Mice(device-wise)应该是作为/dev/input/mouse0(或者是你想使用几种mice时使用/dev/input/mice)出现的。而其他情况下/dev/psaux。你可以移动一下你的鼠标,然
后检查这些文件的输出是否已经指向你的鼠标,通常你将在屏幕上看到一些无用的东西。要结束它,按Ctrl-C。

代码 4.3: 检查设备文件
  1. # cat /dev/input
  2. (Don't forget to press Ctrl-C to end this)
  3. (不要忘记按Ctrl-C来结束这项工作)
复制代码



       如果你的鼠标未被检测到,请检查必要的模块是否已经被载入。

If your mouse is detected, fill in the device in the appropriate InputDevice
section. In the next example you'll see we also set two other options:
Protocol (which lists the mouse protocol to be used -- most users will use
PS/2 or IMPS/2) and ZAxisMapping (which allows for the mousewheel (if
applicable) to be used).

       如果你的鼠标已经被检测到,那么就在InputDevice段落中合适的位置填入你的
设备。在接下来的例子中,你可以看到我们将设置其它两个选项:Protocol(它列出了
可以使用的鼠标协议――大多数用户使用的是PS/2或者IMPS/2)以及ZAxisMapping(对
鼠标滚轮的支持(如果可用的话))。

代码 4.4: 在Xorg中改变鼠标设置
  1. Section "InputDevice"
  2.   Identifier  "TouchPad Mouse"
  3.   Driver    "mouse"
  4.   Option    "CorePointer"
  5.   Option    "Device"    "/dev/psaux"Option    "Protocol"    "IMPS/2"Option   

  6. "ZAxisMapping"    "4 5"
  7. EndSection
复制代码


Run startx and be happy about the result Congratulations, you now
(hopefully) have a working Xorg on your system. The next step is to remove
this ugly lightweight window manager and use a high-feature one (or even a
desktop environment) such as KDE or GNOME, but that's not part of this guide
      
  运行startx然后期待结果吧恭喜,(希望)现在你的系统上已经有一个工作着
的Xorg了。接下来就是删除这个不美观轻量级的窗口管理器,然后装上一个功能丰富的
窗口管理器(甚至是桌面环境),比如KDE或者GNOME,但是这已经超出我们所讨论的范
围了


5. 资源

创建一个优化的xorg.conf

First of all, man 5 xorg.conf provides a quick yet complete reference about
the syntaxis used by the configuration file. Be sure to have it open on a
terminal near you when you edit your configuration file!
       首先,man 5 xorg.conf提供了关于常常被配置文件使用syntaxis的快速而又完
备的参考。当你编辑你的配置文件的时候,请务必安排在一个类似的终端上打开在这些
资料。

A second point of resources on your system is the /usr/X11R6/lib/X11/doc
directory with various README's for individual graphical chipsets
       第二个资源是在你系统上的包含了各种图形芯片相关的README文件的
/usr/X11R6/lib/X11/doc目录中。

There are also many online resources on editing xorg.conf. We only list few
of them here, be sure to Google for more As xorg.conf and XF86Config (the
configuration file for the XFree86 project) use the same syntaxis for most
configuration options and more information about XF86Config is available,
we'll list those resources as well.

       互联网上有许多关于编辑修改xorg.conf的在线资源,我们只在这里列出其中的
一小部分,你可以使用Google来搜索更多的资料 由于xorg.conf和XF86Config
(XFree86项目使用的配置文件)在多数配置上使用相同的句法,而且有关XF86Config的
信息相对更多一点,因此我们也同样列出了 XFree的相关资源。


An Introduction to XFree 4.x by Chris Houser


其它源
.      略
 楼主| 发表于 2007-4-1 17:48:35 | 显示全部楼层
我的主板是i845集成显卡,用“VIDEO_CARDS="i810"”不对吗?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表