SST Lab Dokuwiki Header header picture

ユーザ用ツール

サイト用ツール


linux:webserver

文書の過去の版を表示しています。


Linux環境構築(サーバ編)

Ubuntuによるデスクトップ環境構築

Ubuntu Serverをインストール

Ubuntuのアップデート/アップグレード

Ubuntu ServerによるWeb Serverの構築

  1. 適当な機器にUbuntu ServerをインストールしてLAMPサーバとしてセットアップしておく

Ubuntu ServerによるMail Serverの構築

  1. 適当な機器にUbuntu ServerをインストールしてLAMPサーバとしてセットアップしておく

最新のノートPCをUPS付きサーバに

  • BIOS Boot USB Hard Disk

蓋をしてもスリープしない

 $ sudo vi /etc/systemd/logind.conf 
#HandleLidSwitch= suspend
#HandleLidSwitchExternalPower= suspend
#HandleLidSwitchDocked= suspend

HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore

に変更。

sshで

WARNING: POSSIBLE DNS SPOOFING DETECTED!

とか

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

とかいうときは

$HOME/.ssh/known_hosts

を編集するか

ssh-keygen -R HOST名

でエントリーを削除する。

固定IPv4アドレスに

サーバの運用は固定IPアドレスで行うのが普通。そこで固定IPアドレスを設定する。 ubuntu-20.04.2の場合は

$ cat /etc/netplan/00-installer-config.yaml 
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp3s0:
      addresses:
      - 192.168.10.4/24
      gateway4: 192.168.10.254
      nameservers:
        addresses:
        - 192.168.10.1
        search:
        - ee.ous.ac.jp
  version: 2
$

で確認できる。

Step 1: Check Virtualization Support in Ubuntu

$ egrep -c '(vmx|svm)' /proc/cpuinfo
12
$ sudo apt install cpu-checker
Reading package lists... Done
.
.
.
Setting up cpu-checker (0.7-1.1) ...
Processing triggers for man-db (2.9.1-1) ...
$ sudo kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
$ 

Step 2: Install KVM on Ubuntu 20.04 LTS

$ sudo apt install libvirt-clients
$ virsh
Welcome to virsh, the virtualization interactive terminal.
 
Type:  'help' for help with commands
       'quit' to quit
 
virsh # quit
$
 
$ sudo apt install qemu-utils
$ qemu-img
qemu-img: Not enough arguments
Try 'qemu-img --help' for more information
$
 
$ sudo apt install qemu-kvm
$ kvm
Unable to init server: Could not connect: Connection refused
Could not access KVM kernel module: Permission denied
qemu-system-x86_64: failed to initialize KVM: Permission denied
$
 
$ sudo apt install virtinst
 
$ sudo virsh list
error: failed to connect to the hypervisor
error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
 
$ sudo apt install libvirt-bin
$ sudo apt install qemu
$ sudo apt install qemu-kvm
$ sudo apt install libvirt-bin
$ sudo apt install virt-manager
$ sudo virsh list
 Id   Name   State
--------------------
 
$ sudo apt install bridge-utils
$
$ sudo systemctl status libvirtd
[sudo] password for kimi: 
● libvirtd.service - Virtualization daemon
     Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor pres>
     Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor pres>
● libvirtd.service - Virtualization daemon
     Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor pres>
     Active: active (running) since Tue 2021-02-23 07:16:19 UTC; 2min 36s ago
TriggeredBy: ● libvirtd-ro.socket
             ● libvirtd-admin.socket
             ● libvirtd.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
   Main PID: 982 (libvirtd)
      Tasks: 19 (limit: 32768)
     Memory: 41.8M
     CGroup: /system.slice/libvirtd.service
             ├─ 982 /usr/sbin/libvirtd
             ├─1099 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defa>
             └─1100 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defa>
 
Feb 23 07:16:20 sstw dnsmasq[1099]: compile time options: IPv6 GNU-getopt DBus >
Feb 23 07:16:20 sstw dnsmasq-dhcp[1099]: DHCP, IP range 192.168.122.2 -- 192.16>
Feb 23 07:16:20 sstw dnsmasq-dhcp[1099]: DHCP, sockets bound exclusively to int>
Feb 23 07:16:20 sstw dnsmasq[1099]: reading /etc/resolv.conf
Feb 23 07:16:20 sstw dnsmasq[1099]: using nameserver 127.0.0.53#53
Feb 23 07:16:20 sstw dnsmasq[1099]: read /etc/hosts - 7 addresses
Feb 23 07:16:20 sstw dnsmasq[1099]: read /var/lib/libvirt/dnsmasq/default.addnh>
Feb 23 07:16:20 sstw dnsmasq-dhcp[1099]: read /var/lib/libvirt/dnsmasq/default.>
Feb 23 07:16:20 sstw dnsmasq[1099]: reading /etc/resolv.conf
Feb 23 07:16:20 sstw dnsmasq[1099]: using nameserver 127.0.0.53#53
$ 
$ lsmod | grep -i kvm
kvm_intel             282624  0
kvm                   663552  1 kvm_intel
$ 

Step 3: Creating a Virtual Machine in Ubuntu

$ qemu-img create -f qcow2 ssp0.qcow2 150G
Formatting 'ssp0.qcow2', fmt=qcow2 size=161061273600 cluster_size=65536 lazy_refcounts=off refcount_bits=16
$
~$ virt-install -n ssp0 -r 8192 --disk=ssp0.qcow2,bus=virtio --graphics vnc,password=vnc,listen=0.0.0.0,keymap=ja --noautoconsole -v --boot hd --cdrom ubuntu-20.04.2-live-server-amd64.iso 
 
Starting install...
Domain installation still in progress. You can reconnect to 
the console to complete the installation process.
$
  1. Finderから「サーバへ接続」
  2. vnc:/ / <サーバのIPアドレス>/
linux/webserver.1614131511.txt.gz · 最終更新: 2022/08/23 13:34 (外部編集)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki