国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 幫助中心 > 正文

CentOS7安裝GUI界面及遠程連接的實現

2024-07-09 22:40:37
字體:
來源:轉載
供稿:網友

用基于瀏覽器(webdriver)的selenium技術爬取數據,所以程序需運行在GUI環境下。本文分三個部分簡要介紹安裝GUI界面及遠程連接的步驟。

安裝GUI界面

大多數云服務器廠商提供的鏡像都無GUI界面,所以要先安裝圖形環境。本文使用GNOME桌面環境:

yum -y groups install "GNOME Desktop"

這條命令將安裝GNOME桌面的必要軟件包,執行完后配置X系統使用GNOME:

echo "exec gnome-session" >> ~/.xinitrc

安裝KDE或者MATE桌面環境的兩個命令稍微不一樣:

# kdeyum -y groups install "KDE Plasma Workspaces"echo "exec startkde" >> ~/.xinitrc# mateyum --enablerepo=epel -y groups install "MATE Desktop"​echo "exec /usr/bin/mate-session" >> ~/.xinitrc

以上便安裝好了GUI桌面環境。

啟動桌面環境有兩種方式:

一次性的:在終端里輸入startx; 系統啟動時默認進入桌面環境: systemctl set-default graphical.target,然后重啟;

安裝vnc-server

有了桌面環境,一般可以通過云服務器廠商提供的web終端遠程連接進入桌面。用web終端每次都需要打開瀏覽器,然后登陸云管理后臺再連接,比較麻煩。我們采取直接從桌面客戶端遠程連接的方式,省去打開瀏覽器和登錄云管理后臺的操作。

遠程桌面技術有多種,例如VNC, TeamViewer, RDP等,本文使用免費且廣泛使用的VNC。

在服務器上先安裝服務端(tigervnc是tightvnc的分支):

yum install -y tigervnc-server

接著復制一份VNC配置:

cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

注意上述命令參數重的“@:1”,可以將數字1換成30000內的任意數字,“5900+數字”即為程序的顯示(監聽)端口,如”@:1″表示監聽5901端口。

編輯該配置文件,將文件內的<USER>替換成遠程連接時的登錄用戶名(如果是root,注意將第二個<USER>所在行的”/home”移除掉)。以root身份的配置示例:

# The vncserver service unit file## Quick HowTo:# 1. Copy this file to /etc/systemd/system/vncserver@.service# 2. Replace <USER> with the actual user name and edit vncserver#  parameters appropriately#  (ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"#   PIDFile=/home/<USER>/.vnc/%H%i.pid)# 3. Run `systemctl daemon-reload`# 4. Run `systemctl enable vncserver@:<display>.service`## DO NOT RUN THIS SERVICE if your local area network is# untrusted! For a secure way of using VNC, you should# limit connections to the local host and then tunnel from# the machine you want to view VNC on (host A) to the machine# whose VNC output you want to view (host B)## [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB## this will open a connection on port 590N of your hostA to hostB's port 590M# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).# See the ssh man page for details on port forwarding)## You can then point a VNC client on hostA at vncdisplay N of localhost and with# the help of ssh, you end up seeing what hostB makes available on port 590M## Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.## Use "-localhost" to prevent remote VNC clients connecting except when# doing so through a secure tunnel. See the "-via" option in the# `man vncviewer' manual page.[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=forking# Clean any existing files in /tmp/.X11-unix environmentExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"PIDFile=/root/.vnc/%H%i.pidExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install]WantedBy=multi-user.target
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 马关县| 榆树市| 衡南县| 弋阳县| 壤塘县| 宁都县| 大丰市| 邵阳县| 且末县| 绥德县| 佛教| 柞水县| 新疆| 怀集县| 新安县| 张家口市| 疏勒县| 鄢陵县| 沽源县| 古丈县| 专栏| 昔阳县| 太仓市| 临武县| 尼木县| 图片| 聂拉木县| 北京市| 枣强县| 富川| 山阴县| 静乐县| 三门峡市| 龙口市| 舒兰市| 千阳县| 琼结县| 苍溪县| 吉木萨尔县| 清镇市| 哈巴河县|