GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare il server VNC su Ubuntu 14.04+

Questa guida ti mostrerà come installare una GUI o un desktop su una macchina Headless/Server. Funzionerà con Ubuntu 14.04+

Come al solito aggiorno sempre il mio sistema prima di installare qualsiasi cosa. È buona norma proteggere anche i nostri server/macchine

apt-get update && apt-get upgrade

Installa GUI Desktop

Sto usando Ubuntu 14.04 Server a 64 bit per questo tutorial, quindi installerò una GUI a mia scelta, XFCE è sempre il mio ambiente desktop preferito. Puoi installarne altri ma per lo shake di questo tutorial userò solo XFCE.

apt-get install xubuntu-desktop xfce4 firefox nano

Installa il server VNC su Ubuntu 14.04

Installare VNC Server su Ubuntu 14.04 è semplice, ma la configurazione è una storia diversa.

apt-get install vnc4server

Configura il server VNC per funzionare su Ubuntu

Aggiunta utente VNC
Puoi sempre eseguire il tuo sistema con root, ma non è una buona pratica di sicurezza. Se hai un utente normale/privilegiato, puoi saltare questo passaggio. Se stai usando root, ti consiglio vivamente di creare un utente normale/privilegiato e di usare questo utente invece di root. Ai fini di questo tutorial, sto creando un utente "puremedia", ma puoi scegliere qualsiasi utente/nome utente che desideri utilizzare o anche il tuo utente privilegiato in uscita.

adduser puremedia

Lascia che li aggiungano all'elenco sudo per consentire l'installazione e l'aggiornamento delle applicazioni

adduser puremedia sudo

Ora consente di accedere come quell'utente per generare la configurazione predefinita per VNC

su puremedia

Avviamo VNCserver come questo utente

vncserver

La prima volta che avvii vncserver, ti verrà chiesto di fornire la password di vnc per accedere al tuo server VNC. Questa password può essere uguale alla password del tuo utente o diversa, dipende da te, ma ti consiglio vivamente di impostare questa password diversa dalla password del tuo utente per una migliore misura di sicurezza.

Il passaggio successivo è disattivare vncserver per modificare il file xstartup (script di avvio) per fare in modo che vncserver inizi con xfce4 (abbiamo installato xfce4 per questo tutorial)

vncserver -kill :1

Ora modifichiamo xstartup per vncserver

cd

nano .vnc/xstartup

Questo è il file di configurazione originale

#!/bin/sh
 
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
 
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &

Quello che devi fare è decommentare due righe "unset SESSION_MANAGER" e "exec /etc/X11/xinit/xinitrc", quindi aggiungere "startxfce4 &" al file. Il file xstartup modificato dovrebbe assomigliare a questo

#!/bin/sh
 
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
 
startxfce4 &
 
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &

Salva xstartup quando hai finito.

CTRL + X

Crea script di stato del server VNC

sudo nano /etc/init.d/vncserver

Ora aggiungi

#!/bin/bash
### BEGIN INIT INFO
# Provides:          tightvncserver
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: vncserver
#
### END INIT INFO
 
unset VNCSERVERARGS
VNCSERVERS=""
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
prog=$"VNC server"
start() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
DISP="${display%%:*}"
export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
fi
done
}
stop() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Shutting down VNCServer: "
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
export USER="${display##*:}"
su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
fi
done
echo -e "n"
echo "VNCServer Stopped"
}
case "$1" in
start)
start [email protected]
;;
stop)
stop [email protected]
;;
restart|reload)
stop [email protected]
sleep 3
start [email protected]
;;
condrestart)
if [ -f /var/lock/subsys/vncserver ]; then
stop [email protected]
sleep 3
start [email protected]
fi
;;
status)
status Xvnc
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

Consenti a questo file di essere eseguito

sudo chmod +x /etc/init.d/vncserver

Crea file di configurazione del server VNC

Creeremo il file vncservers.conf nella directory /etc/vncserver per impostare la porta di VNC, la risoluzione dello schermo per ogni utente.

mkdir -p /etc/vncserver

nano /etc/vncserver/vncservers.conf

# VNC port:user
# 1 for port 1 and 5901, 2 for port 2 and 5902, 3 for port 3 and 5903, and so on
VNCSERVERS="1:puremedia"
 
# VNC screen resolution
#GEOMETRY="<WIDTH>x<HEIGHT>"
VNCSERVERARGS[1]="-geometry 1024x768"
 
# Color depth (choose 8, 16, or 32)
DEPTH="32"

Salva di nuovo

CTRL + X

Imposta VNC per l'avvio all'avvio

update-rc.d vncserver defaults 99


Ubuntu
  1. Come installare Hadoop su Ubuntu 18.04 o 20.04

  2. Come installare e configurare VNC su Ubuntu 20.04

  3. Come installare MySQL su Ubuntu 18.04

  4. Come installare Zimbra 8.6 su Ubuntu 14.04 Server

  5. Come installare un server PostgreSQL su Ubuntu 18.04

Come installare VNC su Ubuntu 16.04

Come installare il server VNC su Ubuntu 20.04

Come installare e configurare VNC su Ubuntu Server 20.04

Come installare il server VNC su Ubuntu 14.04

Come installare il server VNC su Ubuntu 18.04 LTS

Come installare il server VNC su Ubuntu 20.04 LTS