From 5fe7a015a0dc5f4cc0645e808a9522af289480f9 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Fri, 14 Apr 2023 17:18:50 -0400 Subject: [PATCH 01/11] Update and correct KVM setup guide --- guides/setup-qemu-kvm.html | 54 +++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/guides/setup-qemu-kvm.html b/guides/setup-qemu-kvm.html index 32df243..1aa97fb 100644 --- a/guides/setup-qemu-kvm.html +++ b/guides/setup-qemu-kvm.html @@ -10,13 +10,13 @@ - Setup KVM/QEMU virtualisation + Setup QEMU/KVM virtualisation
Jump directly to main content -

Setup KVM/QEMU virtualisation

+

Setup QEMU/KVM virtualisation


@@ -33,8 +33,54 @@
-

This is an intro, you gotta believe me

-

Heading

+

Virtualisation is the act of creating a virtualised computer (guest), inside another computer (the host) by sharing the hardware. This allows a single host the ability to run all your services, whilst keeping a level of SoC.

+ +

Enable in the BIOS

+

To run virtual machines, certain flags in the bios need to be set. If you don't want to bring down an existing server to check, then check the next section first.

+
    +
  • Reboot your PC
  • +
  • At the BIOS splashscreen, press your motherboard's prefered key (typically ESC, F3, or F12).
  • +
  • Find and enable the virtualisation setting(s). +
      +
    • One of VT-x, AMD-V, SVM, or Vanderpool.
    • +
    • One of Intel VT-d, or AMD IOMMU (if available)
    • +
    +
  • +
+ +

Check Virtualisation is enabled

+

Double check to make sure your server can be used for virtualisation, if you've enabled it in the BIOS it should be good. Just run one of the following command

+
lscpu | grep 'Virtualization'
+
grep -E --color '(vmx|svm)' /proc/cpuinfo
+ +

Install the packages

+

The easiest part, just copy and paste the below to install the required packages.

+
sudo apt install qemu-kvm libvirt-clients libvirt-daemon libvirt-daemon-system virtinst
+ +

Sessions

+

There are two different session types for VMs, user, and system sessions. If you are using a desktop, and intend to virtualise other desktop OSs I recommend user sessions. If you're setting up a server hypervisor, then use System sessions.

+ +

User Session

+

A user session VM is what I recommend for personal PCs, laptops, etc. as it's the best option for desktop virtualisation (e.g. a Kali install for l33t hackers).

+ +

Add user to group

+
sudo adduser $USER libvirt
+ +

Enable default network

+

Check the name of your default network (typically just 'default').

+
sudo virsh net-list --all
+

Enable the network.

+
sudo virsh net-start default
+

(Optionally) Set it to turn on with system boot.

+
sudo virsh net-autostart default
+ +

System Session

+

For now all that's needed to know is that you run sudo before any virsh commands, and that the VMs will launch with root permissions.

+ +

Extra

+

Setup bridge adapter for KVM

+

Optimisations for KVM Virtual Machines

+
From 3fb70d2c3fc327d83162455a4259dfdcbe062194 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Fri, 14 Apr 2023 17:19:34 -0400 Subject: [PATCH 02/11] Correct and improve bridge network guide --- guides/setup-kvm-bridge.html | 81 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/guides/setup-kvm-bridge.html b/guides/setup-kvm-bridge.html index 186e5cc..0a2d91d 100644 --- a/guides/setup-kvm-bridge.html +++ b/guides/setup-kvm-bridge.html @@ -33,69 +33,68 @@
-

A bridge network is a means to connect/bridge different networks together to act like a single network. In this case, it allows any connections to the bridge network to get their own internal IPs, as if plugged into the network directly, and work as you'd expect a completely new physical PC to work. i.e. Accessble to other clients outside of the host.

+

A bridge network is a means to connect/bridge different networks together to act as a single network. In this case, it allows any virtual connections to the bridge network to get their own internal IPs, as if plugged into the network directly.

+

Install bridge-utils

sudo apt install bridge-utils
-

Find the network to bridge

-

First we need to find the network we want to bridge to the VMs

-
ip a
+

Find the network device to bridge

+

First we need to find the network device we want to bridge to the VMs.

+
ip link
+

You'll likely have a device called something similar to enp1s0, or eth0.

-

Bridge it

+

Create the bridge network

This will be familiar to those who have set a static ip on linux, as it's essentially the same, with a few additional lines related to bridging

-

This can be done by editing /etc/network/interfaces

+

Remove interface from interfaces file

+

First step is to remove any references to your network device from /etc/network/interfaces, if this file is untouched there will likely be two lines at the bottom.

sudo vim /etc/network/interfaces
-

And setting the following lines

- -

Change existing port to manual

-

There will already exist some lines with your chosen network adapter, such as

-
iface enp2s0 inet auto
-

Change this to contain manual instead

-
iface enp2s0 inet manual
-

Static Bridge

-

If you want your server to have a static IP use this

+

Create a new bridge interface

+

Now create a file in the /etc/network/interfaces.d/ directory, with the name of your bridge (I like br0).

+

Static IP

auto br0
-iface br0 inet static
-	bridge_ports enp2s0 # which port(s) to bridge together
-                address 192.168.0.100 # Static IP
-                netmask 255.255.255.0
-                network 192.168.0.1
-                broadcast 192.168.0.255
-                gateway 192.168.0.1
-                bridge_stp off # New
-                bridge_fd 0 # New
-                bridge_maxwait 0 # New
-                dns-nameservers 8.8.8.8 8.8.1.1
-

Dynamic Bridge

-

If instead you wish your server to have a dynamic IP (not recommended). A bridged network can be set, with a dynamic DHCP set IP

+iface br0 inet static # Name the same as your file (br0) + address 192.168.0.100 + broadcast 192.168.0.255 + netmask 255.255.255.0 + gateway 192.168.0.1 # Normally your router's IP + dns-nameservers 192.168.0.1 8.8.8.8 8.8.4.4 # Don't set if resolveconf is installed, comment if internet borked + bridge_ports enp1s0 # Your device name + bridge_stp off # Disable Spanning Tree Protocol + bridge_waitport 0 # No delay before a port becomes available + bridge_fd 0 # No forwarding delay (Connects to network immediately) +

Dynamic IP

iface br0 inet dhcp
     bridge_ports enp2s0
-

Create Virtual Network

-

To make it easier to manage with VMs, this new bridge can be made into a Virtual Network.

-

Open up a text-editor, and create a file called bridged-network.xml

-
vim bridged-network.xml
+

(Optional) Create Virtual Network

+

To make it easier to manage with VMs, this new bridge can also be made into a Virtual Network (Basically so you can select it from a dropdown).

+

Create XML file

+

Open up a text-editor, and create a file called br0.xml, named after the bridge itself.

+
vim br0.xml

Enter the following, then save

<network>
-	<name>bridged-network</name>
+	<name>br0</name>
 	<forward mode="bridge"/>
 	<bridge name="br0"/>
 </network>
-

Then pass the file to virsh net-define

-
sudo virsh net-define bridged-network.xml
-

Active, and auto-start the new network

-
sudo virsh net-start bridged-network
-
sudo virsh net-autostart bridged-network
+ +

Create the virtual network

+
sudo virsh net-define br0.xml
+

Activate, and auto-start (on boot) the new network.

+
sudo virsh net-start br0
+
sudo virsh net-autostart br0
+

You can now remove the br0.xml file.

Reload the network

sudo systemctl restart networking
-

If this creates the bridge, but claims to have failed, restart your PC

+

This may claim to have failed, but if checking with ip link shows the bridge, reboot. Essentially the bridge has been brought up, and it's trying to bring it up again (and can't), then throws an error.

sudo reboot

Check it's there

-

Run another check for networks, and you should now see br0

-
ip a
+				

Run some checks and you should now see br0, with an IP4 address.

+
ip a
+
ping google.co.uk
From a0898971c8bc6d1a9f6b0deab4cd4d2cedea1b53 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Fri, 14 Apr 2023 17:20:44 -0400 Subject: [PATCH 03/11] Content changes, and move virtualisation section --- guides/guide-to-server-hosting.html | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/guides/guide-to-server-hosting.html b/guides/guide-to-server-hosting.html index 4e6d7fc..1e0538c 100644 --- a/guides/guide-to-server-hosting.html +++ b/guides/guide-to-server-hosting.html @@ -34,8 +34,6 @@

If you want to start getting into server hosting, system administration, or just want to get a basic minecraft/web server up for you and your friends, then welcome. We all start somewhere, and I would love if I could get your foot in the door.

-

Notice

-

This is heavily a WIP, so I'll be adding to this guide whenever I get time, and will update it's readibility, and correct/add anything missing once it's 'complete'. If I didn't put it up in an unfinished state, it would never go live, so bear with.

Basic Server setup

    @@ -47,6 +45,16 @@

Now you officially own, and have setup a server. Currently all you can do is SSH into it though, so let's get some services on there

+

Virtualisation

+

Virtual machines allow you to use your server as multiple servers at once, with different operating systems, services, files, etc. If you're self-hosting this is a great way to separate concerns, having one system for each distinct task.

+ +

Nginx Webserver

A great first service for any server is a website, even if it's just a little page to let people know you own the server/domain name

- - -

Run virtual machines

-

Virtual machines allow you to use your server as multiple servers at once, with different operating systems, services, files, etc. If you're self-hosting this is a great way to separate concerns, having one system for each distinct task.

- -

Additional services/potential guides

Unless there is an anchor, these are all "TODO", and may just be omitted from this list

Useful tidbits

From 3663d1a0ef2f0849eed86911e27b6af0650ad78b Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Sat, 15 Apr 2023 15:00:06 -0400 Subject: [PATCH 04/11] Update domain name guide --- guides/get-a-domain-name.html | 11 +++++------ guides/guide-to-server-hosting.html | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/guides/get-a-domain-name.html b/guides/get-a-domain-name.html index 89e653c..830c62b 100644 --- a/guides/get-a-domain-name.html +++ b/guides/get-a-domain-name.html @@ -4,7 +4,6 @@ - @@ -33,19 +32,19 @@
-

A domain name, as many will know is what people typing into their browser, e.g. google.com, facebook.com, etc.

-

The primary use for these is to have a memorable thing for users, instead of needing to type the IP address of the server

+

A domain name, as many will know is what you type into a browser to access a website. Without a domain name, everyone accessing your server/website would need to be entering the IP address.

Choose a registrar

-

First thing is to choose a registrar (who you are leasing the domain from). You can search for "domain name registrars" and find who is cheapest. So long as they handle DNS (which all I've used do) you're good.

+

First thing is to choose a registrar (who you are leasing the domain from). You can search for "domain name registrars" and find who is cheapest. So long as they handle DNS (which most do) you're good.

I'm currently using tsohost.com, as they're pretty cheap, and besides a few little issues, it works for me.

Choose a domain name

-

On the registrar's website there will be a section to purchase a domain. Upon clicking this you'll likely be greeted with a searchbar, search for whatever domain you'd like here, and they'll let you know if it's available, and what similar domains there are

+

On the registrar's website there will be a section to purchase a domain. Upon clicking this you'll likely be greeted with a searchbar, search for whatever domain you'd like here, and they'll let you know if it's available, and what similar domains there are.

Select the domain(s) you wish, and add it/them to your cart.

Purchase your domain name

-

Simply checkout, and make your way through the process

+

Simply checkout, and make your way through the process. Tada, you now have a domain name!

+

Next up you'll need to link your server and domain name with DNS.

diff --git a/guides/guide-to-server-hosting.html b/guides/guide-to-server-hosting.html index 1e0538c..0e6bb65 100644 --- a/guides/guide-to-server-hosting.html +++ b/guides/guide-to-server-hosting.html @@ -39,7 +39,7 @@ From 05a711e19ba121f889d2434d0a646d132164a557 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Sat, 15 Apr 2023 15:15:15 -0400 Subject: [PATCH 05/11] Update domain name DNS guide --- guides/add-domain-to-server.html | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/guides/add-domain-to-server.html b/guides/add-domain-to-server.html index 7e1cc0a..cbf4963 100644 --- a/guides/add-domain-to-server.html +++ b/guides/add-domain-to-server.html @@ -4,7 +4,6 @@ - @@ -33,28 +32,26 @@
-

To avoid needing to remember an IP, this guide will help to link your domain name to your server.

+

To avoid needing to remember an IP, this guide will help to link your domain name to your server. It assumes you have already attained a domain name.

+

Login to your domain name registrar

Login to the registrar, and select the domain name you want to point at your server.

Find the section for DNS

-

The domain name should have a section named, "DNS", "Custom DNS records", or something similar to this. Find, and open it, there should be a bunch of boxes and an option to add a new record

+

The domain name should have a section named, "DNS", "Custom DNS records", or something similar to this. Find, and open it, there should be a bunch of boxes and an option to add a new record.

Add the A record

-

There will likely be many option for adding records, but all we need is to add a singular A record

-

Find the box that allows you to "Add a new record" and input the below, changing and with your IP address, and domain name

- -
+

Find the box that allows you to "Add a new record" and input the below, changing and with your IP address, and domain name.

-

If there are not multiple boxes, but instead a single box to input your record into, this will be what you add instead

- -
+
<DOMAIN> A 86400 <IP>

Wait for propagation

Now there's a bit of a waiting game, as you need to wait for the new DNS record to propagate (get updated) for all nameservers. This can be anywhere from instantly to 72 hours, but typically takes an hour or two.

Check your domain has propagated

-

Pinging the domain name will let you know when the IP has propagated, as when the ping command shows your IP, you're all set

+

Pinging the domain name will let you know when the IP has propagated, as when the ping command shows your IP, you're all set.

+ +
ping -c 3 domainname.com
From a50a82f98585fc830aeddef687981a708de87615 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Sat, 15 Apr 2023 15:23:04 -0400 Subject: [PATCH 06/11] Un-"todo" SoC 'guide' --- guides/guide-to-server-hosting.html | 2 +- guides/vm-seperation-of-concerns.html | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/guides/guide-to-server-hosting.html b/guides/guide-to-server-hosting.html index 0e6bb65..ffb5fac 100644 --- a/guides/guide-to-server-hosting.html +++ b/guides/guide-to-server-hosting.html @@ -52,7 +52,7 @@
  • Setup a bridged adapter
  • TODO:Install a virtual machine
  • TODO:Virsh cheatsheet
  • -
  • TODO:Example of Separation of Concerns (SoC)
  • +
  • Example of Separation of Concerns (SoC)
  • Nginx Webserver

    diff --git a/guides/vm-seperation-of-concerns.html b/guides/vm-seperation-of-concerns.html index f9ddef1..e210c46 100644 --- a/guides/vm-seperation-of-concerns.html +++ b/guides/vm-seperation-of-concerns.html @@ -79,7 +79,6 @@

    Why not use a dedicated server for each concern?

    You can! No-one's going to stop you, but unless each concern requires (i.e. needs the dedicated hardware/isolation) its own dedicated server, it's hugely redundant. Again NAS as an example, would be good for a dedicated machine, as it'll be safer if there's no additional chance it goes down due to failure of an unrelated service.

    -

    Virtual Machines are wonderful, as they allow you to make use of more powerful/high spec machines while minimising the wasted usage...

    From b518b94fec2d840003ab6be41d6303f9dedb87a8 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Sun, 16 Apr 2023 06:21:27 -0400 Subject: [PATCH 07/11] Tidy up some guide pages --- guides/backup-with-rsync.html | 3 +-- guides/guide-to-server-hosting.html | 33 ++++++----------------------- guides/setup-git-server.html | 4 ++-- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/guides/backup-with-rsync.html b/guides/backup-with-rsync.html index 241eac5..0a7d210 100644 --- a/guides/backup-with-rsync.html +++ b/guides/backup-with-rsync.html @@ -59,8 +59,7 @@
    rsync -auv $USER@$HOST:$BACKUP $RESTORE

    Notes/Advanced

    -
    
    --r recursive. All files/directories in the path will be backed up
    +
    -r recursive. All files/directories in the path will be backed up
     -a archive mode. Recursive, but with file permissions, symlinks, etc retained.
     -z compress
     -b backups
    diff --git a/guides/guide-to-server-hosting.html b/guides/guide-to-server-hosting.html
    index ffb5fac..7dfb2ea 100644
    --- a/guides/guide-to-server-hosting.html
    +++ b/guides/guide-to-server-hosting.html
    @@ -61,9 +61,8 @@
     					
  • Install nginx
  • Setup an nginx website
  • Add an SSL certificate w/Certbot
  • -
  • TODO: Nginx web optimisation
  • +
  • TODO:Nginx web optimisation
  • TODO:(Optional) Add PHP to your webserver
  • -
  • TODO:Guide to front-end web development
  • MariaDB Database

    @@ -78,44 +77,26 @@

    Backup your server!

    Backups are super useful. If something breaks, or gets accidentally deleted you can always use a backup to get it back

    Additional services/potential guides

    Unless there is an anchor, these are all "TODO", and may just be omitted from this list

    Useful tidbits

    Additional Services

    • git
    • -
    • samba
    • -
    • Open Media Vault
    • -
    • umami
    • -
    • uptime kuma
    • +
    • Uptime Kuma
    • torrentbox
    • -
    • jellyfin
    • +
    • Jellyfin
    • VPN
    • -
    • mailserver
    • -
    • Host client websites
    • -
    - -

    Game Servers

    -
      -
    • minecraft
    • -
    • terraria
    • -
    • factorio
    • -
    - -

    Additional guides

    -

    These are some guides for specific use-cases, that will aid with setting up -

      -
    • Basic Homeserver for a web developer/designer
    diff --git a/guides/setup-git-server.html b/guides/setup-git-server.html index 524bcea..b0c0bf6 100644 --- a/guides/setup-git-server.html +++ b/guides/setup-git-server.html @@ -57,7 +57,7 @@

    Use the git server

    With all the setup out the way, the git server is now usable as a remote for any of your git repos.

    -

    So on another PC...

    +

    So on another PC, you can use git as normal. For example.

    Add remote to existing repo

    git remote add origin git@<your-server>:/<repo.git>

    Clone the repo

    @@ -69,7 +69,7 @@

    Giving you something like this

    git clone git@<your-server>:<port>/<repo.git>
    -
    +

    Completed

    From here you can use git as you would via any other provider, but with the knowledge that your remote is yours.

    From 72c8392e70b9572a779df2b880097f1446fe6d4a Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Wed, 19 Apr 2023 15:34:57 -0400 Subject: [PATCH 08/11] Update php/nginx guide --- guides/add-php-to-nginx.html | 26 +++++++++++--------------- guides/guide-to-server-hosting.html | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/guides/add-php-to-nginx.html b/guides/add-php-to-nginx.html index 456da21..f2fd409 100644 --- a/guides/add-php-to-nginx.html +++ b/guides/add-php-to-nginx.html @@ -36,42 +36,38 @@

    PHP is one of the highest used programming languages for websites, and it allows you to add practically any functionality you'd ever want to your sites.

    Install

    -
    sudo apt install php-fpm php-mysql
    - -

    Um, I forgor

    -
    sudo nano /etc/php//fpm/php.ini
    -

    Comment the cgi.fix_pathinfo line, to look like below

    -
    #set cgi.fix_pathinfo = 0
    +
    sudo apt install php-fpm
    +

    If you want to work with mysql, then you also need to install php-mysql.

    Add to Website's NGINX conf

    -

    For each website you want to use php, you'll need to edit the confige file

    +

    For each website you want to use php, you'll need to edit the config file.

    sudo vim /etc/nginx/sites-available/
    -

    The following code needs adding within the XXX block

    +

    The following code needs adding within the server block.

    location ~ \.php$ {
     	include snippets/fastcgi-php.conf;
    -	fastcgi_pass unix:/run/php/php-fpm.sock;
    +	fastcgi_pass unix:/run/php/php<VERSION>-fpm.sock;
     }
    -

    This will use nginx's fastcgi-php.conf snippet which is more secure by deafult than many other php/nginx configs because it 404s if the files doesn't exist. Read Neal Poole'sDon't trust the tutorials for more info.

    +

    This will use nginx's fastcgi-php.conf snippet which is more secure by default than many other php/nginx configs because it 404s if the requested file doesn't exist. Read Neal Poole's Don't trust the tutorials for more info.

    Reload NGINX

    sudo systemctl reload nginx

    Test it works

    -

    Create a PHP file e.g. filename.php in the website's directory, and add the snippet below into it

    -
    +

    Create a PHP file e.g. filename.php in the website's directory, and add the snippet below into it.

    +
    <?php phpinfo(); ?>

    Go to that webpage in your browser e.g. domain.co.uk/filename.php, and if php is working you should see a dump of your PHP's version, headers, etc.

    Make nginx use index.php as homepage/root

    -

    Now we'll set nginx to load up index.php as the root of the website, if it exists. Open the site's config with an editor

    +

    Now we'll set nginx to load up index.php as the root of the website, if it exists. Open the site's config with an editor.

    vim /etc/nginx/sites-available/
    -

    Change the index line to read as below. This will then tell the server to load index.php, and if it doesn't exists, load index.html in it's stead

    +

    Change the index line to read as below. This will then tell the server to load index.php, and if it doesn't exists, load index.html in its stead.

    index index.php index.html
    diff --git a/guides/guide-to-server-hosting.html b/guides/guide-to-server-hosting.html index 7dfb2ea..723b06e 100644 --- a/guides/guide-to-server-hosting.html +++ b/guides/guide-to-server-hosting.html @@ -62,7 +62,7 @@
  • Setup an nginx website
  • Add an SSL certificate w/Certbot
  • TODO:Nginx web optimisation
  • -
  • TODO:(Optional) Add PHP to your webserver
  • +
  • (Optional) Add PHP to your webserver
  • MariaDB Database

    From 1b973fe56ed08fa406e0412dbea43e6900fff239 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Wed, 19 Apr 2023 16:36:41 -0400 Subject: [PATCH 09/11] Update mariadb setup guide --- guides/install-mysql-mariadb.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/guides/install-mysql-mariadb.html b/guides/install-mysql-mariadb.html index c5e64d4..67cdae9 100644 --- a/guides/install-mysql-mariadb.html +++ b/guides/install-mysql-mariadb.html @@ -40,15 +40,20 @@

    Secure Install/Setup

    sudo mysql_secure_installation
    +

    Run the above command, and follow the instructions, if you don't want to then follow mine.

    +

    Press enter for the current password, and again when asked if you want to set a root password. Enter the password, then press enter for everything else.

    Create Admin user

    sudo mysql
    -
    GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
    +
    GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY '<DESIRED_PASSWORD>' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    exit;

    Test it works

    +

    Simply try logging in as the admin account.

    +
    mysql -u admin -p
    +

    It should ask for a password, so enter your DESIRED_PASSWORD, and if you get mysql access, it's successful.

    (Optional) Make it easier to access on command line

    If you're working with a terminal, when calling mysql you'll need to enter a password each time. You can store the passwordwith a special .cnf file, making it faster to get into writing SQL.

    @@ -56,9 +61,9 @@
    vim ~/.my.cnf

    Add the following, with your credentials

    [mysql]
    -user=
    -password=
    -

    The above can be used for mysqldump, mysqladmin, and others too, by replacing the [mysql] block

    +user=<USERNAME> +password=<PASSWORD>
    +

    The above can be used for mysqldump, mysqladmin, and others too, by replacing the [mysql] block, with the related. e.g. [mysqldump].

    From ea8580a90c8b180358f55c3127eb0730c2a6f593 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Wed, 19 Apr 2023 16:37:47 -0400 Subject: [PATCH 10/11] Update adminer setup guide --- guides/adminer-setup.html | 10 +++++----- guides/guide-to-server-hosting.html | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/guides/adminer-setup.html b/guides/adminer-setup.html index 2916b7d..a749f4e 100644 --- a/guides/adminer-setup.html +++ b/guides/adminer-setup.html @@ -50,10 +50,10 @@ chmod 755 /var/www/html/adminer.php

    Access it

    -

    Head to your /adminer.php, and you should load into the adminer login. Using your mysql/mariaDB credentials, you can then login, and use the GUI to manage your database(s)

    +

    Head to your <WEBSITE/IP>/adminer.php, and you should load into the adminer login. Using your mysql/mariaDB credentials, you can then login, and use the GUI to manage your database(s)

    Make it a directory, not a file

    -

    Instead of accessing /adminer.php?, we can make it look like /adminer/

    +

    Instead of accessing /adminer.php?<ARGUMENTS>, we can make it look like /adminer/<ARGUMENTS>

    location /adminer/ {
     	root /var/www/html ;
     	try_files $uri $uri/ /adminer/index.php/$is_args$args ;
    @@ -62,16 +62,16 @@ chmod 755 /var/www/html/adminer.php

    Password Protect

    An additional level of security, just in case. Using Htaccess, any file, or directory can be password protected

    sudo apt install apache2-utils
    -htpasswd -c /home//.htpasswd admin
    +htpasswd -c /home/<USER>/.htpasswd admin

    Add to location

    Add the location of the auth file to the adminer location block

    auth_basic "Adminer" ;
    -auth_basic_user_file /home//.htpasswd ;
    +auth_basic_user_file /home/<USER/>.htpasswd ;

    They block should look like below

    location /adminer/ {
     	auth_basic "Adminer" ;
    -	auth_basic_user_file /home//.htpasswd ;
    +	auth_basic_user_file /home/<USER>/.htpasswd ;
     	root /var/www/html ;
     	try_files $uri $uri/ /adminer/index.php/$is_args$args ;
     }
    diff --git a/guides/guide-to-server-hosting.html b/guides/guide-to-server-hosting.html index 723b06e..1f779ed 100644 --- a/guides/guide-to-server-hosting.html +++ b/guides/guide-to-server-hosting.html @@ -70,7 +70,7 @@ From 0a37652623ca0e07844dc8a8d54627fe68663ff1 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Wed, 17 May 2023 13:39:26 -0400 Subject: [PATCH 11/11] Add WIP kvm guide stuff --- guides/guide-to-server-hosting.html | 1 + guides/install-kvm-virtual-machine.html | 14 +++++ guides/kvm-optimisation.html | 73 +++++++++++++++++++++++++ guides/virsh-cheatsheet.html | 5 ++ 4 files changed, 93 insertions(+) create mode 100644 guides/kvm-optimisation.html diff --git a/guides/guide-to-server-hosting.html b/guides/guide-to-server-hosting.html index 1f779ed..447293a 100644 --- a/guides/guide-to-server-hosting.html +++ b/guides/guide-to-server-hosting.html @@ -51,6 +51,7 @@
  • Setup Qemu/KVM
  • Setup a bridged adapter
  • TODO:Install a virtual machine
  • +
  • TODO:Optimisate KVM Virtual Machines
  • TODO:Virsh cheatsheet
  • Example of Separation of Concerns (SoC)
  • diff --git a/guides/install-kvm-virtual-machine.html b/guides/install-kvm-virtual-machine.html index 3e2eac0..2659cd4 100644 --- a/guides/install-kvm-virtual-machine.html +++ b/guides/install-kvm-virtual-machine.html @@ -40,6 +40,20 @@

    Install with virt (CLI)

    Install with virt-manager (GUI)

    + +By default virsh lists vms belonging to user +virsh --connect qemu:///system list --all +The above run as root shows all vms + + +For virtmanager, etc to controll vms from an remote host +It needs ssh-key shared + +If a different port, then use virt-manager -c 'qemu+ssh://myuser@192.168.1.139:2222/system?keyfile=id_rsa' + +e.g. +virt-manager -c 'qemu+ssh://nathan@aney.co.uk:2020/system?keyfile=id_rsa' + diff --git a/guides/kvm-optimisation.html b/guides/kvm-optimisation.html new file mode 100644 index 0000000..4ffdb84 --- /dev/null +++ b/guides/kvm-optimisation.html @@ -0,0 +1,73 @@ + + + + + + + + + + + + KVM Optimisation + + + +
    + Jump directly to main content +

    KVM Optimisation

    + + +
    + +
    +
    + +
    +
    +

    KVM Optimisations

    + +transmit queue +virsh domiflist +# this is then the txqueuelen change below ??? +# changing to 4096 +ifconfig txqueuelen + +txqueuelen (iwbcman comment) +defaults to 1000, apparently 200 is good + +ip link set eth0 txqueuelen 200 +vim /etc/network/interfaces +add +post-up /sbin/ip link set eth0 txqueuelen 200 +to the end + +If virtual hdd is slow can try +Cache mode: none (not default!) +I/O mode: native +https://unix.stackexchange.com/a/48584 + +non caching on dirves? +https://blog.jdpfu.com/2012/07/30/improving-kvm-performance +://documentation.suse.com/smart/linux/html/concept-virtual-disk-cache-modes/concept-virtual-disk-cache-modes.html#:~:text=A%20disk%20cache%20is%20a,example%2C%20by%20setting%20its%20type. +On VM turning cache off essentially acts like accessing the drive itself. No exactly a passthrough, but decent enough + +http://www.linux-kvm.org/page/Tuning_KVM + +
    +
    + + + + + diff --git a/guides/virsh-cheatsheet.html b/guides/virsh-cheatsheet.html index 89a7e65..7a2a366 100644 --- a/guides/virsh-cheatsheet.html +++ b/guides/virsh-cheatsheet.html @@ -77,6 +77,11 @@
    virsh snapshot-delete --domain $vm --snapshotname $snapshot_name

    (TODO)Drive management

    +

    Resize virtual drives

    +

    Find the name of your drive.

    +
    virsh domblklist $vm
    +

    Resize with qemu

    +
    sudo qemu-img resize /location/drive.qcow2 +10G

    Change Memory

    In variantions of 512M, 1G, etc