Setting up a dedicated NWN server on Amazon EC2
Getting to the AWS Management Console
- Sign up for an Amazon account if you don't already have one (go to Amazon, click the "Sign in" link at the top, choose "No, I am a new customer", and follow the instructions).
- Sign up for Amazon Web Services (AWS) if you haven't already done so (go to Amazon Web Services, click the "Create an AWS Account" link at the top, and follow the instructions.)
- Sign up for Amazon Elastic Compute Cloud (EC2) if you haven't already done so (go to Amazon EC2, click the "Sign Up For Amazon EC2" button, and follow the instructions.)
- Go to https://console.aws.amazon.com.
- Press the "Sign in to the AWS Console" button, then sign in using your normal Amazon user id and password.
Creating a Key Pair
- Switch to "EC2" tab in the AWS Management Console.
- Click on the "Key Pairs" link on the left.
- Press "Create a Key Pair" button.
- Enter "NWServer" for the name, then press the "Create" button.
- Copy the downloaded file, "NWServer.pem", to your "~.ssh" directory.
- Enter the following command in a terminal window:
chmod 600 ~/.ssh/NWServer.pem
Creating an EC2 Security Group
- Switch to "EC2" tab in the AWS Management Console.
- Click on the "Security Groups" link on the left.
- Press the "Create Security Group" button.
- Enter "NWServer" for "Security Group Name".
- Enter "NWN Dedicated Server" for "Description".
- Press the "Create" button.
- Go to the bottom pane in the "Connection Method" table.
- Enter "SSH" for "Connection Method", "TCP" for "Protocol", "22" for "From Port", "22" for "To Port", and "0.0.0.0/0" for "Source (IP or group)".
- Press the "Save" button
- Enter "Custom..." for "Connection Method", "UDP" for "Protocol", "5121" for "From Port", "5121" for "To Port", and "0.0.0.0/0" for "Source (IP or group)".
- Press the "Save" button.
- The display may get confused and not show the rows you just created. If this happens, press the "Refresh" button.
Creating an EC2 Instance
- Switch to "EC2" tab in the AWS Management Console.
- Click on the "AMIs" link on the left.
- Change the first "Viewing:" menu to "All Images" and wait for it to update (this could take a while).
- Enter "ami-3e02f257" in the text box and press return. Only a single match should come up. Select it.
- Press the "Launch" button.
- Optionally change the "Availability Zone", or accept the default.
- Optionally change the "Instance Type" (for example, to get a faster--and more expensive--server), or accept the default.
- Press the "Continue" button at the bottom.
- Optionally, change one or more of the Advanced Instance Options (only if you know what you're doing!).
- Press the "Continue" button at the bottom.
- Optionally create on or more tags.
- Press the "Continue" button at the bottom.
- Choose "NWServer" from the list of "Your existing key Pairs".
- Press the "Continue" button at the bottom.
- Choose "NWServer" from the list of "Security Groups".
- Press the "Continue" button at the bottom.
- Review the options to make sure you picked what you meant to.
- Press the "Launch" button at the bottom.
- Press the "View your instances on the Instances page" link.
- Wait until the "Type" column changes from "pending" to "running".
Starting and Stopping an EC2 Instance
- Switch to "EC2" tab in the AWS Management Console.
- Click on the "Instances" link on the left.
- Select the instance from the list.
- Choose "Start" from the "Instance Actions" menu to start it.
- WARNING: REMEMBER, YOU ARE PAYING A SMALL HOURLY FEE AS LONG AS THE INSTANCE IS RUNNING, SO DON'T FORGET TO STOP IT IF YOU DON'T NEED IT RUNNING AND DON'T WANT TO PAY.
- Choose "Stop" from the "Instance Actions" menu to stop it.
- WARNING: DO NOT CHOOSE "TERMINATE": THIS ERASES THE HARD DRIVE, SO YOU WILL LOSE ANYTHING YOU HAVE INSTALLED AND ANY SAVED GAMES THAT ARE STORED ON IT.
- You can choose the "Change Termination Protection" option from the "Intance "Actions" menu to prevent accidental termination. This is probably a good idea.
Getting the public address of an EC2 Instance
- Switch to "EC2" tab in the AWS Management Console.
- Click on the "Instances" link on the left.
- Select the instance from the list.
- In the pane below, select the text in the "Public DNS" section. This is the address you will need for most things. It will look like this:
ec2-50-17-76-20.compute-1.amazonaws.com
If you need an IP address, you can extract it from the name by removing the "ec2-" part in front and the part after the "." on the end. Keep only the part in the middle:
ec2-50-17-76-20.compute-1.amazonaws.com
Replace each "-" with a "." and you have the IP address:
50.17.76.20
NOTE: the address of the instance changes every time you stop and restart it, so you will have to recopy it every time you do so.
Connecting to the EC2 instance with SSH
- Switch to "EC2" tab in the AWS Management Console.
- Click on the "Instances" link on the left.
- Select the instance from the list.
- Choose "Connect" from the "Instance Actions" menu
- Copy the example line from the bottom. It will look something like this:
ssh -i NWServer.pem root@ec2-50-17-76-20.compute-1.amazonaws.com
Press the close button
NOTE: the address information in the line you just copied changes every time you stop and restart the instance, so you will have to recopy it every time you do so.
Paste the example line into a terminal window and change the "root" to "ubuntu". It will look like this:
ssh -i NWServer.pem ubuntu@ec2-50-17-76-20.compute-1.amazonaws.com
Execute the line. This will connect you to a command line running on the EC2 server.
Answer "yes" when asked "The authenticity of host... can't be established; Are you sure you want to continue connecting (yes/no)?"
Installing tools that will be needed
- Enter the following in a terminal window:
sudo nano /etc/apt/sources.list
Add "multiverse" at the first couple of lines, right after "universe", so that the file ends up like this:
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ lucid main universe multiverse
deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ lucid main universe multiverse
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ lucid-updates main universe
deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ lucid-updates main universe
deb http://security.ubuntu.com/ubuntu lucid-security main universe
deb-src http://security.ubuntu.com/ubuntu lucid-security main universe
Save the changes (press ctrl-x, enter "Y" to save changes, hit return to accept the default file name)
Enter the following in a terminal window:
sudo apt-get update
Enter the following in a terminal window, answering "Y" every time the question "After this operation, [number] MB of additional disk space will be used. Do you want to continue [Y/n]?":
sudo apt-get install p7zip
sudo apt-get install unrar
sudo apt-get install unzip
sudo apt-get install subversion
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install gperf
sudo apt-get install libmysql++-dev
sudo apt-get install zlib1g-dev
Installing NWN dedicated server for Linux:
- Run the following commands to install the necessary files:
mkdir nwn
sudo wget -O /mnt/NWNDedicatedServer1.69.zip http://files.bioware.com/neverwinternights/updates/windows/server/NWNDedicatedServer1.69.zip
unzip /mnt/NWNDedicatedServer1.69.zip -d nwn
cd nwn
rm -f override/*
rm *.exe
rm *.dll
rm nwn.ini
tar xzfv linuxdedserver169.tar.gz
rm macdedserver169.zip
chmod u+x fixinstall
./fixinstall
Edit the fixinstall file:
nano fixinstall
Add the tlk directory to the list of directories that get fixed by changing this line:
aLCDirs=(ambient data dmvault hak localvault music override portraits)
To this:
aLCDirs=(ambient data dmvault hak localvault music override portraits tlk)
Run the server for a test, and to create a default nwnplayerini:
./nwserver -module "Contest Of Champions 0492"
You should see this output:
Neverwinter Nights Server
Build:8109
Copyright BioWare Corp 1998-2004
Server: Loading...
Server: Running...
Server: Loading module "Contest Of Champions 0492"..........
Server: Module loaded
Stop the server
quit
Edit the file nwnplayer.ini:
sudo nano nwnplayer.ini
Change the settings in nwnplayer.ini to whatever you want, then save them and quit.
Testing the server:
./nwserver -module "Contest Of Champions 0492"
Connect to it with your NWN client:
Start NWN
Press the Play button
Press the Multiplayer button
Enter Player Name and Password, then press OK
Press "Join LAN Game"
Press "Direct Connect" button
Enter the IP address (see "Getting the public address of an EC2 Instance" above)
Choose your player character
When done, exit the client and "Quit" the server
Installing NWNX and plug-ins:
- Get, build, and install NWNX:
sudo svn co http://nwn.virusman.ru/svn/nwnx2-linux/trunk/ /mnt/nwnx2
sudo chown -R ubuntu:ubuntu /mnt/nwnx2
cd /mnt/nwnx2
./configure --prefix=/home/ubuntu/nwn
make install
cp nwnx2.so ~/nwn
cp plugins/funcs/nwnx_funcs.so ~/nwn
cp nwnx2.ini ~/nwn
Delete the .so files for plugins you do not want, or modify nwnx2.ini so that they are disabled (TODO: EXPLAIN HOW).
Create the script to run NWN:
cd ~/nwn
nano nwnstartup.sh
Paste the following into it and exit, saving changes:
#!/bin/sh
export LD_PRELOAD=./nwnx2.so
./nwserver "$@"
Make the script executable:
chmod u+x nwnstartup.sh
Run the script that makes sure the configuration is OK:
cd ~/nwn
./fixinstall
If desired, test the server, using this command instead of the old ./nwserver
./nwnstartup.sh -module "Contest Of Champions 0492"
Installing PRC 3.4
sudo wget -O /mnt/prc34.rar http://nwvault.ign.com/fms/Download.php?id=158561
unrar x /mnt/prc34.rar ~/nwn
cd ~/nwn
./fixinstall
If NWNX is installed, make some adjustments. First, rename the functions plugin:
#PRC uses the name "funcs" instead of "functions"
mv nwnx_functions.so nwnx_funcs.so
If NWNX is installed, edit the NWNX settings:
nano nwnx.ini
And add this to the end:
[FUNCS]
;Number_of_Skills, the amount of skills from skills.2da (last row+1)
Number_of_Skills=39
Installing CEP2, if desired
- Download and uncompress CEP 2
sudo mkdir /mnt/cep2
sudo chown ubuntu:ubuntu /mnt/cep2
wget -O /mnt/cep2/cep23.7z http://nwvault.ign.com/fms/Download.php?id=147417
cd /mnt/cep2
p7zip -d cep23.7z
Copy the files you need. For instance:
cp hak/cep2_core1.hak ~/nwn/hak
cp hak/cep2_core2.hak ~/nwn/hak
cp hak/cep2_core3.hak ~/nwn/hak
cp hak/cep2_core4.hak ~/nwn/hak
cp hak/cep2_core5.hak ~/nwn/hak
cp hak/cep2_add_tiles.hak ~/nwn/hak
cp hak/cep2_add_sb_v1.hak ~/nwn/hak
cp hak/cep2_add_phenos1.hak ~/nwn/hak
cp hak/cep2_add_phenos2.hak ~/nwn/hak
cp hak/cep2_top_v1.hak ~/nwn/hak
cd ~/nwn
./fixinstall
Installing modules, haks, etc.
- The best way is probably to install them on your Windows machine, install PRC into the modules, then copy the files to the server.
- First, get the public address of the server (see the "Getting the public address of an EC2 Instance" section above), then use it to run commands like the following in a Terminal window on your machine:
scp -r -i ~/.ssh/NWServer.pem "/Volumes/Main/NWN/modules/MODULE_NAME.mod" ubuntu@ec2-50-17-76-20.compute-1.amazonaws.com:nwn/modules/
scp -r -i ~/.ssh/NWServer.pem "/Volumes/Main/NWN/hak/HAK_NAME.hak" ubuntu@ec2-50-17-76-20.compute-1.amazonaws.com:nwn/hak/
scp -r -i ~/.ssh/NWServer.pem "/Volumes/Main/NWN/tlk/TLK_NAME.tlk" ubuntu@ec2-50-17-76-20.compute-1.amazonaws.com:nwn/tlk/
The, connect to the server (see the "Connecting to the EC2 instance with SSH" section above) and run the following commands:
cd ~/nwn
./fixinstall
Other
- To check available drive space on the server:
df -hT /