https://yq.aliyun.com/articles/53308
摘要: 有些時候,有些程序可能需要依賴圖形界面才能啟動,例如安裝Oracle時(其實oracle支持命令行安裝),例如需要啟動一個圖形界面的瀏覽器如firefox。作為服務端的系統,通常不會安裝臃腫的圖形界面。那么如何在不安裝圖形界面的的情況下啟動圖形界面的?聽起來很矛盾,但是實際上是可行的。 X Win
有些時候,有些程序可能需要依賴圖形界面才能啟動,例如安裝Oracle時(其實oracle支持命令行安裝),例如需要啟動一個圖形界面的瀏覽器如firefox。
作為服務端的系統,通常不會安裝臃腫的圖形界面。
那么如何在不安裝圖形界面的的情況下啟動圖形界面的?聽起來很矛盾,但是實際上是可行的。
X Window System(常被簡稱為X11或X),是一套基於X display protocol的windowing system,X GUI環境的功能包括窗口的繪制、移動,以及與鼠標、鍵盤等輸入設備的交互。
X采用C/S模型(這是關鍵):一個X server 和多個應用程序(client)通信。server接收client的請求繪制窗口,並將來自鼠標、鍵盤等設備的輸入傳遞給client。
因此 X server和client可以位於同一計算機上,例如在Linux主機上使用KDE等桌面環境就是這種模式。X server也可以通過同構網絡、異構網絡或Internet與client通信。
X server與client之間的通信是不加密的,這個問題可以通過SSH解決。SSH是Secure Shell的簡稱,SSH可以看作是通信被加密壓縮版的telnet。
需要用到SSH的forwarding功能,當X server與client所在計算機都支持SSH協議時,X server與client之間不安全的TCP/IP連接可以轉送到(forwarding)二者之間建立的SSH連接上。
了解原理后,我們就可以在本地自建X服務,然后服務器作為X client,把繪圖的請求發給本地的X server。 這樣就實現了本地顯示圖像的目的。
例子, 以本地為Windows為例,使用ssh連接到服務器, 把服務器的X請求轉發到本地的 X server。
簡單的幾個步驟即可
.1. 配置服務器的sshd,重啟服務
# vi /etc/ssh/sshd_config X11Forwarding yes X11DisplayOffset 10 X11UseLocalhost yes # service sshd restart
.2. 在windows主機安裝Xming, 啟動X server
option 1:
1.運行xmanger passive
2,觀察右下角的Xmanager 小窗口的 端口號 (比如【:1.0】或者【:0.0】),用於本地securecrt export DISPLAY 用。
option 2:
windows下的X server可以通過Xming軟件來構建。
https://sourceforge.net/projects/xming/
.3. 在windows主機安裝securecrt或putty
.4. 在windows主機配置securecrt或者putty,配置對應會話的轉發X11,並重新連接會話
.5. 在securecrt或putty命令行啟動GUI命令
開啟securecrt FORWARDX11后,會自動設置DISPLAY環境變量.
#echo $DISPLAY localhost_ip:1.0 或者
localhost_ip:0.0
# firefox
####xmnager
xmnager server 端在windows;
需要在UNIX client 端打開X11 轉發功能
/etc/sshd/sshd_config file
add two lines to ~/.ssh/config then connect the system
Host *
ForwardX11 yes
Brief
The X Window System (X or X11 for version 11, for short) is a platform independent method of providing graphics capabilities to an operating system, while also being network transparent. It is most commonly used on Unix and Unix-like systems such as Linux. X itself dates back to 1984 at MIT.
While other systems for providing graphics capabilities are possible, the standard graphical interface system on Linux is the X Window System.
X mechanics
Essentially, what X provides is a program (the X server) which controls the graphics card and performs actual graphics drawing tasks such as splitting the screen into windows, drawing the mouse pointer, drawing lines, accessing the keyboard, etc. It runs the actual video driver, as well as provides an interface through which other programs can issue drawing commands (using the X11 protocol), get input, etc, without having to know what hardware its running on Programs which attach to the X server are called X clients, and may include applications such as word processors, games, etc.
Window managers
One client is special, and is the window manager - X on its own does not manage drawing the window widgets (title bar and borders) and minimizing, maximizing, raising, and other specifics - this is delegated to the window manager. Before desktop environments became more commonly used, the window manager was the primary piece of software responsible for determining the look and feel of the GUI, however, window managers can only address look and feel at the window level - within the application consistency is derived from the use of a common toolkit, which was not a feature of X applications previously. Many window managers are available, such as metacity, kwin4, Window Maker, Enlightenment, and FVWM.
Gnome/KDE Installation and Configuration
The X/windows installing environment includes our recommended package selection as following:
Desktop shell(GNOME/KDE)
Office suit (OpenOffice.org)
Web browser
Email(Evolution)
Instant messaging
Sound and video applications
Software Development Tools
Administration Tools
A. Install Gnome/KDE from System Installation
When we start the Enterprise Linux installation, we'll find this screen: Package Group Selection
Package Group Selection
Select the package groups:
To select a package group, click on the check box beside it.
Once a package group has been selected, click on Details to view which packages are installed by default and to add or remove optional packages from that group.
Desktop
X Windows System
GNOME Desktop Environment
KDE(K Desktop Environment) and all sub categories.
Applications:
Editors ----Emacs/vim-enhanced/XEmacs
Graphical Internet
Text-based Internet
Office/Productivity
Sound and Video
Graphics
Administration Tools
Printing Support
B. No Gnome/KDE even no X Window System's environment
Using ssh X-forward to install the software.
We can use other Linux do below action:
add two lines to ~/.ssh/config then connect the system
Host *
ForwardX11 yes
a. Please install system-config-packages*.rpm by dependence:
insert CD-DISK
# mount /media/cdrom
# rpm -Uvh /media/cdrom/system-config-packages*.rpm
b. Run Redhat Package Management
# system-config-packages
After boot configuration
There are a few more steps to take before your system is ready to use.
The Setup Agent will now guide you through some basic configuration. Please fill appropriate information and click the "Next" button in the lower right corner to continue to finish setup.
Service/Server management
For Gnome please run:
# gnome-session-properties
For KDE please run:
# kcontrol
It's very easy to manage Service/Session using KDE Control Center.
X Window System log
The X Window System log file contain much useful information blow:
/var/log/Xorg.0.log
/var/log/Xorg.1.log
External links
http://en.wikipedia.org/wiki/X_Window_System
http://www.x.org
http://www.xfree86.org