How to Setup a Minecraft Server

First things first…

Ok, So you want to start a minecraft server. Well theres some stuff you need to do first to let your friends connect, if you want to run a minecraft server for just you and the people on your WiFi/house, then this tutorial isn’t for you. Secondly this tutorial will not require Hamachi.

What you need to do

Firstly, you will need a minecraft server, either bukkit or vanilla, I will be using vanilla, but you can use any minecraft server so long as it works. (first make sure that you follow any instructions that any non-vanilla installations tell you, this is most important. this includes how to make a run file)

Firstly you need to have already done these things.

    • Created a run.bat file or run.sh file (not needed for forge or vanilla)
    • Tested that you can connect to your server on your own computer ( you can do this by connecting to ‘localhost’ on your own computer, please note that trying this on any other computer will not work)
    • Have your router admin and password ready.
    • Have access to the internet. (please note this tutorial will likely not work in an office or building with multiple vlan’s and networks. ignore this if you are unsure

Now that you have those things we need to make sure everything is 100% ready, so lets start.

Getting a Minecraft server and connecting to it on your computer

Before we try to let friends connect we better check that we can.

First, start your minecraft server, if you don’t have one, you can download it here or if you are not on windows or aren’t sure, download it here. if you are not using minecraft_server.exe then you will need to make a run.bat file you can do this by making a text file called run and then saving it as run.bat with the contents below. put these in your downloads folder in a folder called minecraft server.

@echo off
java -Xmx1024M -Xms1024M -jar minecraft_server.jar
pause

Now you have that, lets make sure we can connect on our own computer. (if you are trying to connect on another computer, this step will not work)

  1. Start the minecraft server, it should look like this (if you are not seeing this, or it opens then suddenly closes, read the troubleshooting section!!! it is likely because you have not accepted the eula, change the word ‘false’ to ‘true’ in your file called eula.txt)mcserveror thismcserver32if your server does not look like this, then check the troubleshooting section at the bottom of the page
  2. DO not skip the above section, your server WILL not work without these steps
  3. Now we need to connect to our server. Connect to ‘localhost’ in your minecraft game.mcserver44and when you connect you should see this.
    mcserver9876and this
    minecraftcongratulations, you have successfully connected to your own minecraft server.
  4. Now you have done this you can move onto the next step to allow your friends to connect, if you couldn’t connect, something is wrong, check the troubleshooting section.

Who am I?

Now that you have setup your minecraft server, you need to let others connect, before you can do this you need to do a few things. Firstly you need to click this link, this will tell you your WAN IP, which you will need later. write this down or leave the tab open, it should look like this,

ip

 

 

 

 

 

 

 

 

 

keep those numbers, you will need them later (YOURS WILL be different to the one in the tutorial)

you also need your LAN IP.

  1. On your keyboard press the WIN + R keys at the same time.
  2. in the box type ‘cmd’
  3. you should have seen thesewinrafter you have the black box, you don’t need the white one, it should close automatically when you click ok.
  4. Now type ‘ipconfig’
    mcserverand press enter, you are looking for one with the words default gateway, but you will also need IPV4 address.
    ipv4you now know your default gateway and LAN IP.

After this tutorial, you should have exactly 3 numbers, all of witch you WILL need.

your LAN IP, your WAN IP and your default gateway.

they should look something like this, but may also be vary different

LAN IP : 192.168.1.3
WAN IP : 87.34.55.23
DEFAULT GATEWAY : 192.168.1.1

You need these three numbers, without them you cannot continue.

Letting friends join! (Port forwarding)

Now that we have the numbers from the previous step, lets put them to good use, open your web-browser and type in the numbers in the address bar, (do not Google the numbers, that’s not what you want silly).

now you need to login, if you dont know your login, you need to Google your make and model of your router for the default passoword, if that didn’t work, it may be that someone else changed it, ask someone in your household who set it up or check the troubleshooting section.

Once you have logged in, go to the port forwarding section on your router, if you cannot find it then google the make and model of your router followed by how to port forward. Once you have reached the port forwarding section, add your minecraft server by entering the following

 

Service Port (sometimes just called port) : 25565
IP Address (THIS IS WHERE YOU ENTER YOUR LAN IP, that we got earlier, my'n is this) : 192.168.1.3
*Internal Port (optional, may also not exist) : 25565
Protocol : ALL (or in my case TCP and UDP)
Status : Enable

then you can check that your port forwarding has worked by going here and typing 25565 as the port number (make sure your server is running or this test wont work).

you should see

Success: I can see your service on 87.34.55.23 on port (25565)
Your ISP is not blocking port 25565

Congratulations, you have successfully configured and allowed your minecraft server to be used over WAN, your friends can now connect to your minecraft server using your WAN ip, which in my case is ‘87.34.55.23’.

While you are still logged into your router, it is a good idea to statically assigning your computer’s IP address to prevent it from breaking, you can do this by going to the address reservation tab in your DHCP settings and adding your computers LAN ip to the list and selecting your computer from the connected clients.

TroubleShooting / OOPS, it broke

ProblemPossible Solution
It says ‘java.net.ConnectException: timed out: no further information:’Ok, it looks like you cannot connect you your server, here are some possible solutions

  • Make sure your minecraft server is running. Try again if not
  • Try connecting to ‘localhost’ on the machine the server is running on, did it work, if it did make sure your port forwarded correctly, see if your LAN ip has changed. see if your WAN ip has changed, this may be because you have restarted your router or computer, in which case you will need to statically assign your IP addresses to prevent this.
I don’t see the boxes in the who am I section.Ok, it looks like your run file is not working correctly, try double clicking the jar file, did that work? if not you may need to re download it.
It says Failed to bind port!Ok, it looks like youve opened your server more than once, even though you may only see one server running, double clicking the file can also run the server, if you know how to go into task manager and end the task, or if you dont, restart your pc. If none of those work, you may have something already using the port your trying to connect to.
How do I op myself.Simple, click on the server box and type, you can use commands in there.
it says ‘Error: I could not see your service on 87.34.55.23 on port (25565)’(the IP may be different) It looks like you have not configured port forwarding correctly, or your minecraft server is not running, you computer may also be blocking the port, google how to allow a mincraft server through a firewall. you may also be running on a different port, look in your server for the line Starting minecraft server on *:25565, is this correct? make sure that your port numbers are accurate.
I don’t know my router login is it the same as my WiFi password?No, but try it anyway.
I don’t know my router loginIt’s usually unchanged form the default. Look at the router, is the login information on the box? Sometimes it is a random set of letters and numbers look on the router it’s self for information. Ask family if they know or consult your ISP for help. It may also be ‘admin’ ‘admin’ or ‘admin’ ‘password’ for the login username and password. Google the make and model of your router for help. If you still cannot find it ask someone else to do it for you. Do not reset the router if you don’t know how to set it back.
It says Error: unable to access jarfile!It looks like your runfile is not configured correctly, the name of the file should be exactly the same as the name of the server.jar file. so if your file is called ‘minecraft_server1.7.10.jar’ then your run file should be ‘java -Xms2024M -Xmx2048M -jar minecraft_server.1.7.10.jar nogui’
 The server does not run! There may be a file called eula.txt, change the word ‘false’ to ‘true’. this is because minecraft has changed their eula.
My server has lots of errors!Yep, because bukkit was taken there are some now, also when starting for the first time it may have to create some files necessary to start that can cause errors, just restart and you should be good to go.

Bukkit has been given a DMCA takedown by Wesley Wolfie. what now?

Recently bukkit has been issued a DMCA takedown because of recent events and the massage below appeared on bukkit’s downloads pages.

Capture

451 Unavailable for Legal Reasons.
This content is unavailable as the direct result of a DMCA takedown request.
A copy of the notification can be found at this link.

What now?
well, we don’t know, as far as we are aware Wesley Wolfie is issuing the DMCA notice to Multiplay (who host bukkit and bukkit’s download links (reference)).

I believe that Spigot will continue to update there builds but are in the same boat as bukkit, but that it is ok for them to do so as it is not Wolfie’s Intention to stop the modding of bukkit but to protect mojang from using his code in their develpments of bukkit as he was unaware that mojang had aqquired bukkit and he was no longer working for an open source project and was now working for mojang essentially for free.

To read more, read here!

Using Hashlib to Securely store user passwords and credentials.

What is hashing?

Hashing a password means that users cannot have their passwords compromised when a database engineer is reading cleartext in user databases (to a degree, the passwords could be decoded, but hashing them makes them illegible to someone who is not doing anything extensive). And also prevents hackers from reading passwords in plain text and can be compromised by collision attacks.

Additionally when hashing a password a salt may be added to the password, this prevents a database from being attacked by dictionary attacks.

Why Hash Passwords?

Storing User credentials in Plain Text is generally as bad practice as it allows anyone who reads the file (or computer) to see the password, username or any other credential without any sort of protection, In some cases it is against the law, such as PCI SSC Data Security Standards which handles debit and other card types. The solution to this is to Obfuscation in the form of hashing. Hashing a password makes a standard password seem completely random.

How hashing works

When a user signs up for a website or any other form that requires secure credentials, such as a password, username, email address or address, that user will fill in a form that will ask these credentials, then the web server will both hash and store the hash, the server will ‘throw away’ the original password and keep the hash. In a more secure environment the user may also be given a salt, this may be unique to the user or unique to the application (The user will not know the salt, the salt is owned by the server and will be kept secret.). When hashing both the password and salt will be combined and hashed.

How to hash a string in Python

This tutorial uses Hashlib as its hashing encoder which uses the ever bug free OpenSSL…

First we need to import hashlib and encode the input, then finally we need to check for a match.

Raspberry Pi – PHP permission File Problems Solved!

I recently installed php, but when I was unable to save files, I was very stuck, and that’s why I’m posting it here, I want to tell anyone who Googles this problem to find this solution.

 

The problem was when I used an fopen and fsave within php, the file would always ‘die’ as in the open or die within php. The solution is below

Firstly I looked for the Environment user in phpinfo() in my case it was
[box type=”shadow”]www-data[/box]
and then I simply typed this
[box type=”shadow”]chmod 777 -R www-data /var/www[/box]
that, in its simplicity is the solution, but I am thankful that I have found the solution!

To create a phpinfo you need to create a file in your root and insert the following code

and save it as phpinfo.php or whatever you choose, I saved it in my root but you can save it wherever you want, then I browsed to the environments section and that gave me the necessary information for me to create the solution.

Why this works

The problem was that php did not have enough permissions to write to the folder. by giving the user www-data full permission i.e. 777 it can now read write and execute without a problem!

here is what php looks like when you do phpinfo

phpinfo() user sample on Raspberry Pi
phpinfo() user sample on Raspberry Pi

you can check a file exits and is editable with this code http://stackoverflow.com/a/13297218

Now you’ve finished you can celebrate! here is a song (this is mainly so i can test embedding :P)

Adding Hosts to Godaddy

GoDaddy is a great Domain Registrar,  I have GoDaddy as my Domain Registrar.

When using domains and Subdomains you may want to have multiple websites on the same server, here is how to add hosts to your GoDaddy account.

 

First Browse to Godaddy and Login, It may be slightly different for you as I live in the UK.

First Click on My Account, then Visit My Account… You should see this page, Expand Domains.

Godaddy Main

On the domain you would like to Add a Host to, Click Launch. You should See this Page….

Godaddy Main 2

Please note some of my sensitive information has been removed…

To add a subdomain Click Host Names (Manage) In there click Add Hostname. The Hostname will be the Subdomain Name, The IP address will be the IP address of the web server(Or Application Server). Then Click Add.

Please note that it can take up to 48 Hours for a DNS Host to update through the Internet.

To Set the Domain Record, Click DNS Zone File, Click Add Record, Select A (Host), Enter the Host that will be the Domain or Subdomain, such as www (By Default this is already configured, so click edit rather than add record.) Then Click Points to, The IP address will be the IP address of the web server(Or Application Server), Then set The Time To Live (TTL), If you are unsure what to do, leave it as default. Then Click Add.

Please note that it can take up to 48 Hours for a DNS Host to update through the Internet.

 

You have now configured a new host!

 

If you want to add another, repeat the process.

How to Configure Apache to use Virtual Hosts

Using Apache is Good, but for one website is limiting its potential you can create multiple websites, domains and sub-domains with Apache, see below.

 

 

First you need to stop your server, you can do this on lunix by entering
[box type=”shadow”] $ sudo /etc/init.d/apache2 stop [/box]

into your terminal, this allows you to make changes to files in your server without breaking it, for windows you need to stop Apache using Xammp, see below.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now Enable Mod_log_config browse here

[box type=”shadow”]xamppapacheconf[/box]

and in httpd.conf remove the # from this line

[box type=”shadow”]#LoadModule log_config_module modules/mod_log_config.so[/box]

to look like this

[box type=”shadow”]LoadModule log_config_module modules/mod_log_config.so[/box]

 

next using an FTP program or other method, go to your website’s root directory such as

[box type=”shadow”]/home/*/public_html/cgi-bin/[/box]

 

Or for windows

[box type=”shadow”]C:xampphtdocs[/box]

This is the base of your web server, and probably where your Index.html is located, create two folders, Domains and Subdomains, this is where your domains will be stored. See below

Domains, Subdomains

 

 

 

 

 

 

 

In Domains, Place the dome of your website, replacing dots with hyphens like so

Domains, if

 

 

 

(Also add any other websites that you plan to host on the server)

Then copy the data that was in your root of the server into the domain folder on the server like this

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

then paste  into your domain folder like this

 

Paste

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So your Server should now have the ‘root’ of the server in

[box type=”shadow”]WEBROOTDomainsinfinityflame-co-ukindex.html[/box]

or subsequent folders in Linux.

now you need to redirect traffic from your website to the correct folder, this is done with virtual Hosts’s, and is also how you add sub domains see below

browse to your Apache installation folder and go to httpd-vhosts.conf

[box type=”shadow”]apacheconfextrahttpd-vhosts.conf[/box]

 

and at the bottom add the following code replaceing my domain, with yours.

now test the website, start Apache and browse to your domain, you should see your site as you did before, you have now configured your website to use Virtual Hosts

now you need to add other domains and subdomains, See Here

Xampp and Apache

I recently played around with Apache and fond it incredibly educational.

I used Apache for multiple websites and sub-domains, and its a great web server. and I like Xampp’s user Interface, allowing me to edit, configure and Error check my site.

Xampp Control Panel
Xampp’s user interface, server side

 

Don’t get me wrong though, there are some downfalls when putting it through its paces using Owncloud I discovered that php supported was only allowing 2GB uploads, because it is 32Bit, I later discovered that Xampp is only 32Bit for Windows. This was a major disappointment for me, but I still found workarounds.

Apache is great and easy to use with Xampp, I recommend that anyone wanting to get into web servers and general Web hosting try it out first. I hosted it on my Windows Server, But using a server is completely unnecessary, I was also able to run it on my Laptop.

 

For a test Environment or to start out on Web Servers, I recommend Xampp. Its a trade up over usability and performance on Windows.