Setting up a Linux System

From Open Metaverse Wiki

Opensimulator: Grid Owners: Setting up a Linux System

Setting up a Linux System for OpenSim

Ubuntu arrives with the firewall turned off, so one of the first things you should do is enable this. (I think ufw stands for Use Fire Wall). Type the following commands in the root terminal window:

   ufw allow 22
   ufw allow 80
   ufw allow 443
   ufw allow 8002
   ufw allow 8020:8200/tcp
   ufw allow 8020:8200/udp
   ufw allow 10000
   ufw enable
   ufw status verbose

22 is for SSH, 80 is for http WEB pages, 443 is for https. 10000 is for WEBmin, By default OpenSim uses 8002 externally. And is uses 8003 internally (don't export that). A bunch of other OpenSim addons use numbers in the low 8000's so I'm starting with 8020 for all the regions, some people use the 9000's for that. Regions use one TCP port and one UDP port, they can be the same number. It is recommended to run each region in a separate 'instance' (a separate copy of OpenSim.exe) and this instance will need to have a port reserved for it. However, it is common to combine many low-usage regions (like oceans) under one instance. Each of these ocean regions will also need their own port number. At first I kept a list of what ports I was using in a spreadsheet. Or using grep (a Linux search tool) to tell me what ports are used. A database search can also find them. Eventually I wrote grid management code to choose unused ports for me.

Create a Swap File

Ubuntu is usually installed with no or with a small swap file. This is used for 'virtual memory' when a program uses more than all the available memory. Most advice on the Internet says you don't need a big swap file, it should never be over 4GB. Unix Guru's will tell you if a system uses virtual memory then something is wrong. Well, something must be wrong with OpenSim because every once in a while it uses a HUGE amount of memory. If you run out of both real and swap file virtual memory while generating maps or building an OAR file, the OpenSim instance will crash or start failing in strange ways. I'm not sure how much swap space is needed, but making it as big as your memory seems to fix a lot of OpenSim crashes.

   swapoff	#if you have an old small swap file
   fallocate -l 30G /storage/swapfile
   chmod 600 /storage/swapfile
   mkswap /storage/swapfile
   swapon /storage/swapfile
   edit /etc/fstab
   	;add the swapfile to the end of /etc/fstab by adding this line:
   /storage/swapfile swap swap defaults 0 0

Test and Set Up Your Server on the WEB

Enter the IP address of your new server to a WEB Browser, you should see the Ubuntu Default page. Then try changing the WEB page. I use the editor vi to edit /var/www/html/index.html You can also edit this file with your favorite editor on your home PC by editing that file in a root SFTP window. Make a visible change to that file, for example I found the phrase "It works!" and changed it to "Something else!" Then reload the WEB page and see the changes!

Register a domain name somewhere like GoDaddy.com

Register a domain for your grid and change the DNS addresses of your new domain name to go to the IP address from your server. Most registrars have a page for setting your DNS addresses, some have a "zone management' page where you have to add DS records. GoDaddy makes you turn off their domain parking feature before you can change the DNS addresses.

Test the WEB page again

Changing a domain to a new server is supposed to take up to 48 hours, but usually takes a lot less than that. Once the Internet catches up to your change, entering your domain name in a browser will bring up the Ubuntu default WEB page again. This confirms you have your domain name working. The domain name is used for OpenSim as well as the WEB page.

Get a Security Certificate for your Domain Name

I use Let's Encrypt, it is free and only takes a minute. To install this the first time, log onto that root terminal window and type:

   apt update
   apt install snapd		;this is supposed to already be installed, but was not
   snap install core; sudo snap refresh core	;test to see if snap is installed
   apt remove certbot		;remove old certbot, if any
   snap install --classic certbot
   ln -s /snap/bin/certbot /usr/bin/certbot
   certbot --apache
   	;asks for an administrator email address and a domain name

If certbot cannot find you domain name, you may have to set up a "Domain Zone" for it. Contabo has a page for doing this in their user account system.

You should give some money to https://letsencrypt.org/donate for providing this incredible service. They are free AND their certbot does a lot of the work for you.


Next: Configuring a database for OpenSim