linux server setup: file, ftp, web, tv, and gaming
this guide is the steps i went through when i upgraded my “server” hecubus to fedora 17. hecubus serves as a file server (samba and nfs), ftp server (pure-ftp), web server (apache, mysql, and php), personal video recorder (mythtv), and game server (tdsm and minecraft). setup for fedora 17 as well as these other packages are detailed. mythtv setup includes setting up hauppage hvr 2250 and pvr 150 cards with schedulesdirect guide information.
- gnu/linux (fedora)
- file servers (samba, nfs, and pure-ftpd)
- web server (apache, mysql, php)
- personal video recorder (mythtv)
- game servers (tdsm and minecraft)
- all 5 pages
this guide uses hecubus as an example. in general, the hardware in hecubus is whatever is left over after i upgrade my main machine. it’s not a server-class machine, but it keeps up okay in the server roles i use it for because the demand on it is fairly light (five clients at most). you may need more or less hardware depending on usage. more focused requirements are listed at the beginning of each section.
a usb or cd/dvd drive and several gigabytes of hard drive space are required for installing fedora 17.
fedora install disc images are available at fedoraproject.org. i get the kde x86_64 live cd and recommend using bittorrent to get the image faster if you’re comfortable using a bittorrent client. once downloaded, use fedora’s liveusb creator to make a bootable usb installer (i need this since i don’t have room for an optical drive with all my hard drives) or simply burn the image to a cd.
make sure your machine is set to boot your usb drive or cd depending on what you did with the image, and boot up the machine. it will wait on a text menu screen for a few seconds, so you can just press enter to start fedora. you’ll be greeted with a fedora desktop, but it hasn’t been installed yet. click the install to hard drive link on the desktop to start the installer.
choose your keyboard, and storage type (probably basic), then choose fresh installation if given the choice between installing and upgrading. next i enter hecubus for the hostname since that’s my server’s name. next is time zone selection, where i find it easiest to click on the map to choose my time zone. i also leave the system clock uses utc box checked (note that some other operating systems, like windows, don’t let you do this so it may be a bad idea if your dual-booting your server). next it asks you to specify a password for the root user. since root can do anything this should be a strong password, but you will need it later so make sure you can remember it somehow. the installer will warn you if it thinks your password isn’t strong enough.
the next screen allows you to set partitioning options. choose “create custom layout.” the next screen has you select which drive(s) you want to install fedora on. it put all my hard drives in the install target devices box and showed the usb drive under data storage devices, so all there was to do was to make sure the correct drive was selected for the boot loader. this is typically the drive you’re going to put /boot on and also the first drive in the system (sda). note that the list is sorted by the model name and not identifier, so for example mine has sda third of four instead of first. you can click the identifier column header to sort by the drive order and make things easier. click next to set up partitions.
if you’re installing over an existing installation, you don’t need to create any partitions because you can use what you already have. you will need to edit each one though to tell it where to mount and whether to format. three of your partitions need to be formatted: /boot, swap, and / (root). if you don’t use /home for storage and want to start over fresh you can format that one too, but you definitely don’t want to format /files because that’s where you keep all your stuff! the other partitions when you click the edit button will tell you the original file system label, which will help you tell apart /home and /files if you have both.
if you’re starting fresh you’ll need to create all the partitions you’ll need. at the beginning of the first disk, create a standard 100-meg (at least) partition: mount point /boot, type ext4, and “force to be a primary partition.” after that, create a standard swap partition: type swap, size 2× memory (hecubus has 4 gig, so doubling it gives me 8 gig, which is 8192 meg). next, at least 10 gig for mount point /, type ext4, and primary again. i originally made mine 20 to be safe, but now that i have more space it’s the leftovers of a 150-gig drive after /boot and swap. split the rest of your space between non-primary partitions /home and /files, where /home is ext4 and /files is xfs. home is for users’ files, so that could be very small (or absorbed into /) if you don’t plan on storing files there (i use it as temp space and a staging area). put the rest into /files (note you can name /files anything that’s not normally used by linux). the other drives’ (if you have any) partitions should be given a mount point so that you don’t have to manually add them to
for protection against the drive with all my files dying, i have a pair of 3-terabyte drives that i set up in a software raid for my /files partition. to set this up, click the create button and choose “raid partition.” select one of the two drives in available drives, enter the full capacity of the drive for the size, and check “force to be a primary partition.” repeat for the second drive. now click the create button again and “raid device” will be available. create that. set the mount point to /files, file system type to xfs. raid device is fine at md0. raid level should be raid 1 for mirroring (each disk has the same data, so if one dies you can run on the other). make sure both raid partitions are selected for raid members and click ok.
clicking next will confirm that anything you set to format will have its data destroyed, so before doing that make sure you only have checkboxes for format next to the partitions you actually want formatted. again, this is always /boot, swap, and / (root), and may also include /home but doesn’t include /files unless this is your first time setting up this machine.
the next screen allows the boot loader (grub) options to be changed, but i just keep the defaults. click next again and fedora will start installing. this will likely take a long enough time that you’ll want to go do something else — you can probably count on about ten minutes, depending on the speed of your drives.
when it’s finished it will ask you to reboot, and you’ll then get the post-install setup. on the create user page, i use the advanced button to create my users and groups because i need to set the same id here and on my other linux installs so nfs works as expected. first i add my default user group with the add group button. having a group for users makes it easy for them to share files with just the group. enter whatever name you like and check the box to specify your own id and you’re good to go. remember your group id (or look it up from the groups tab) and click the add user button to add all your users. if you didn’t format /home earlier you can leave create home directory unchecked because the directory’s already there. to use the common user group, uncheck private group but do not check specify group id manually, because it will attempt to create the group (and fail). check the box for user id and enter what you need for this user. if you’re creating a user who shouldn’t have terminal access, change login shell to
/sbin/nologin. once the user is created, you need to double-click it in the list and go to the groups tab to add it to your common users group. also be sure to change the primary group from users to your common group. repeat to create all the users you need. i create accounts for people plus one to own the files, all in that common group.
on the date and time screen, check synchronize date and time over the network. this means you won’t have to worry about your system time being off (nice for recording tv). it may show the wrong time here but provided you chose the correct time zone will fix itself anyway. next it will ask your permission to send your hardware profile to fedora, which may actually help them better support your hardware. select “send profile” if you want to send it, then click finish and you’ll be brought to the fedora login screen.
log in and disable selinux. if you’re upgrading and keeping an old /home partition, you’ll need to log in as root (you shouldn’t normally do this!) because selinux is blocking your access to /home. you also need to disable it for mythtv’s sake (probably). selinux is disabled by editing /etc/selinux/config and changing SELINUX=enforcing to SELINUX=disabled. reboot so you will be allowed to log in using kde as a normal user. there’s probably a command to stop selinux without rebooting but i didn’t look for it. later on if you need to do something as root, log in as a normal user first. both
su - will ask you for the root password and then let you become root, but
su - also gives you root’s context (this means you don’t have to specify the path for administrator commands). you should not log in as root directly. in the rest of this guide, lines starting with $ can be run by a normal user, but lines starting with # must be run as root.
once you’re running with selinux off and logged in as a normal user, open up ssh since most interaction with the server will be done via a remote terminal. start it and make it run at startup:
# systemctl start sshd.service # sytemctl enable sshd.service
now allow it through the firewall. i only do this for my local subnet (don’t want to accidentally let someone in from the internet), so add the following line to /etc/sysconfig/iptables, just before the first line with -j REJECT:
-A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.3.0/24 --dport 22 -j ACCEPT
most routers default to 192.168.1.* for lan ip addresses — change the 192.168.1.0/24 accordingly if yours is different. after the file has been changed, restart the firewall to apply the changes:
systemctl restart iptables.service
now make sure everything that just got installed is up to date (this requires an internet connection):
# yum -y update
it’s a good idea to run that command every so often (weekly or at least monthly) to keep everything up to date.
file servers (samba, nfs, and pure-ftpd)
samba server allows a linux machine to share some of its directories with windows machines. nfs allows a linux machine to share some of its directories with other linux machines. i set up both of these to be accessible only to my subnet. pure-ftpd is an ftp server, which makes files available over the internet, so limiting it to only my subnet defeats the purpose.
the requirements for running a file server are hard drive space (the more the better — i have 3550 gig total in my server) and a network adapter.
install samba using yum:
# yum -y install samba
edit (as root) the file
/etc/samba/smb.conf to set your samba server options. for the most part, you can follow the examples in the file to set up shared directories.
create samba users with
smbpasswd -a username (omit the -a to change password of existing user). allow smb connections from the lan by adding the following lines to
-A INPUT -p udp -m udp -s 192.168.1.0/24 --dport 137 -j ACCEPT -A INPUT -p udp -m udp -s 192.168.1.0/24 --dport 138 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.1.0/24 --dport 139 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.1.0/24 --dport 445 -j ACCEPT
remember to change the 192.168.1.0/24 accordingly if your subnet is different. after the file has been changed, restart the firewall to apply the changes, start the samba service, then make it autostart:
# systemctl restart iptables.service # systemctl start smb.service # systemctl start nmb.service # systemctl enable smb.service # systemctl enable nmb.service
i’m also setting the nmb service to autostart so that the linux server’s hostname actually means something to the windows machines on the network.
nfs is already installed but needs to be configured. edit
/etc/exports and add one line per directory to share, in the following format:
again, the 192.168.1.0/24 may need to change. run
exportfs -ra to apply the changes made in
/etc/exports. parts of nfs use ports that change when restarted, so the following changes can make force them to use a static port. this is necessary so we can tell iptables to allow nfs traffic. edit
/etc/sysconfig/nfs and add / modify the following lines (note some of these may only need to be uncommented):
RPCRQUOTADOPTS="-p 875" LOCKD_TCPPORT=32803 LOCKD_UDPPORT=32769 RPCMOUNTDOPTS="-p 892" STATDARG="-p 662"
now allow those ports through the firewall with the following in
-A INPUT -m state --state NEW -p tcp -s 192.168.1.0/24 -m multiport --dports 111,662,875,892,2049,32803 -j ACCEPT -A INPUT -m state --state NEW -p udp -s 192.168.1.0/24 -m multiport --dports 111,662,875,892,2049,32769 -j ACCEPT
portmap runs on port 111, and nfsd uses 2049 by default, so that's where those ports come from (the others are from the port settings). apply the new firewall rules, start nfs, and make it autostart:
# systemctl restart iptables.service # systemctl start nfs-server.service # systemctl enable nfs-server.service
# yum -y install pure-ftpd
this puts a config file in
/etc/pure-ftpd/pure-ftpd.conf, so edit that as root. most of the options i set are commented out by default (prefixed with a #), so be sure to uncomment them if so. find the following lines and make them look like this:
NoAnonymous yes # PAMAuthentication yes UnixAuthentication yes PassivePortRange 50000 50100 ForcePassiveIP #.#.#.# Bind ,## MinUID ####
PAMAuthentication should actually be commented out in favor of
UnixAuthentication. since i don’t get much ftp activity (it’s mostly just for me), i don’t need the default range of 20000 passive ports so set it to a smaller range of 100. be sure to put your internet ip or a name that resolves to your internet ip (i have used dyndns for this in the past) in place of the #.#.#.# for ForcePassiveIP. the
Bind line lets you listen on a port other than 21, so put your desired port in place of the ## (be sure to leave the comma in front), or leave the line commented out if you want to keep the standard port.
MinUID by default filters out system accounts, but i set the value higher to exclude the user i create to own almost everything in /files.
open port ## (set above on the bind line) and ports 50000:50100 (also set above) by adding these lines to
-A INPUT -m state --state NEW -m tcp -p tcp --dport ## -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 50000:50100 -j ACCEPT
since my server is behind a router i also need to forward ports ## and 50000:50100 in my router configuration to my server. this is probably different for different routers, but for many the first step is to load up http://192.168.1.1/ in a browser.
now restart the firewall, then start and auto-start the ftp service:
# systemctl restart iptables.service # systemctl start pure-ftpd.service # systemctl enable pure-ftpd.service
web server (apache, mysql, php)
i do web development as a hobby, using apache httpd, php, and mysql. hecubus is my test web server, so it needs to be set up to be able to run php / mysql through apache.
requirements for running a web server are a moderate amount of disk space (a few hundred megabytes should do it) and a network card.
if you are also going to be installing mythtv, that’s going to require apache httpd, php, and mysql from yum and not from source, so this guide does it that way even though i’ve installed them from source in the past. install all three from yum, start them, and set them to startup automatically with the following commands:
# yum -y install httpd php mysql mysql-server php-mysql php-mbstring php-gd php-mcrypt # systemctl start httpd.service # systemctl start mysqld.service # systemctl enable httpd.service # systemctl enable mysqld.service
if you need any special configuration, edit the config file at
/etc/httpd/conf/httpd.conf. i run multiple test sites under multiple ports so i need to do this, but it’s not always necessary. the default website path for a yum install is
since i need to be able to edit the files on my test web sites, i actually tell apache in httpd.conf to use the group that my users are in. this conflicts with the permissions on the php session directory, which is owned by root and the apache group. i switch it to my group with this:
# chgrp people /var/lib/php/session
if necessary, you can change settings for php in
/etc/php.ini. restart apache with
systemctl restart httpd.service for changes to httpd.conf / php.ini to take effect.
next open port(s) through the firewall. i limit port 80 to my lan but serve my other ports to the internet:
-A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.1.0/24 --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80##:80## -j ACCEPT
restart iptables for the change to take effect:
# service iptables restart
for mysql, run the following to set a root password and block anonymous access (make sure to set your own password instead of rootuserpassword):
$ mysql -u root > update mysql.user set password=password('rootuserpassword') where user='root'; > delete from mysql.user where user=''; > flush privileges; > exit
to enter mysql again (to create accounts for web sites, create databases) use
mysql -u root -p and exit with
exit. for example, creating a database as well as a new user who can use that database would go something like this (enter your own dbname, dbuser, and dbpassword of course):
$ mysql -u root -p > create database dbname character set utf8; > grant all on dbname.* to 'dbuser'@'localhost' identified by 'dbpassword'; > exit
to run the same code on my test server as i do on live websites, i redirect the mysql hostnames to 127.0.0.1 to use the test mysql databases. you don’t need to do this if your live websites connect to localhost for the database, but if they use a hostname put a line like this in
/etc/hosts for each server:
i use phpmyadmin to manage mysql through a browser. download the latest .tar.bz2 from phpmyadmin.net (i use the english version since i don’t need any other languages), go to /opt/ and install it:
# tar xjvf /path/to/phpmyadmin.tar.bz2 # ln -s phpMyAdmin-18.104.22.168-english/ phpmyadmin
the second line makes upgrading easier — just extract a new phpmyadmin version, re-do the symlink, copy config.inc.php and you’re good to go. for the inital setup, copy config.sample.inc.php to config.inc.php and edit it. the only change i make is to change auth_type from cookie to http. next add an alias in /etc/httpd/conf/httpd.conf so you can access phpmyadmin from any site on your server at /phpmyadmin:
Alias /phpmyadmin /opt/phpmyadmin
personal video recorder (mythtv)
recording tv to files on a hard drive is in many ways better than recording to vhs tape. i have mythtv record the shows i want to watch on my hauppage hvr 2250 and pvr 150 cards, then i play them on my htpc using a little program i wrote.
requirements for mythtv as a personal video recorder are some sort of linux gui (kde works well, which is why i install from the kde live cd image), a tv tuner card (this guide is for ivtv cards, which encompasses most analog hauppage cards, plus saa7164 cards, which is a newer digital tuner), and a good deal of hard drive space to hold the shows and / or movies you want to record. for reference, a half-hour hd surround show is 1.1 gigabytes in mpeg2 format. note that i always install and configure apache, php, and mysql before setting up mythtv. i suspect the mythtv installation will pull them in for you if you didn’t install them first, but if not then see the web server page of this guide.
to start, add the atrpms repository to yum:
# cd /etc/yum.repos.d/ # yum -y install wget # wget http://wilsonet.com/mythtv/atrpms.repo # rpm --import http://atrpms.net/RPM-GPG-KEY.atrpms
edit atrpms.repo and change 2 places to fedora 7 version (which also works for fedora 8 through 17 — they changed the name from “fedora core” to just “fedora” in version 7, so fc became just f), then install mythtv from yum (note the suite has a lot of pieces so this will take a while):
# yum -y install mythtv-suite
for the hvr 2250 card i need to install the saa7164 firmware. in a scratch directory (such as /tmp/), execute the following commands to download and install saa7164:
$ mkdir hvr22xx $ cd hvr22xx $ wget http://www.steventoth.net/linux/hvr22xx/22xxdrv_27086.zip $ wget http://www.steventoth.net/linux/hvr22xx/HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip $ wget http://www.steventoth.net/linux/hvr22xx/firmwares/4019072/NXP7164-2010-03-10.1.fw $ wget http://www.steventoth.net/linux/hvr22xx/extract.sh $ sh extract.sh # cp *fw /lib/firmware
you can now remove the hvr22xx directory that was created. the saa7164 driver that was already installed didn’t work correctly without the firmware, so reload it:
# modprobe -r saa7164 # modprobe saa7164
mysql should already be set up with a password set for the root user and also running as a service. set up the default mysql databases using the provided sql file:
$ mysql -u root -p < /usr/share/doc/mythtv-docs-0.25.2/database/mc.sql
log into the server in a kde session, and run mythtv setup from applications → multimedia in the menu. choose your country and language, then go through the options in order.
under general on the second screen locale settings, set channel frequency table to us-cable and local timezone to auto. the default settings are fine again for the rest of this section.
under capture cards, choose new capture card to set up your tuner card. first the hvr 2250 with two digital tuners needs to be added twice. set card type to dvb dtv capture card (v3.x). there should be two options under dvb device number — one for each tuner. leave it at the default. under recording options, set max recordings to 1. now add another card the same way. the second one will choose the other dvb device number for you.
now add the pvr 150. change card type to "mpeg-2 encoder card" and everything else defaults correctly.
under video sources, choose new video source. give it whatever name you like (for example, “xyz cable”). in the us or canada, schedulesdirect can hook you up with tv listings for $20/year after a free 7-day trial. unfortunately i don’t know of any free services. sign up for an account at schedulesdirect.org if you don’t already have one, and set up your channels on their site. i add a local broadcast listing for my digital cable channels and the regular cable listing for analog cable channels. back in mythtv, enter your user id and password, then click retrieve lineups. your lineups should come into data direct lineup. set up one video source for each lineup, even though i’m going to use the digital lineup twice.
under input connections, you connect your tuners to the listings. find your tuner in the list. enter a display name if you like (it’s nice to be able to tell which tuner is being used by this name). choose the appropriate video source you created earlier. for the first digital tuner choose scan for channels to get the channels tuned in. i do a full scan on cable frequency table with qam-256 modulation to pick mine up (it takes about 10 minutes). for analog tuners, click fetch channels from listings source to get the channels from schedulesdirect. on the second page, set priority for that tuner if desired. higher priority tuner will be preferred.
under channel editor, i edit each channel and change its name to the network it shows (i’d rather see nbc than wxxx). use icon download to get icons for all channels with download all icons, or you can enter them while editing the channels if you already have them somewhere. for digital channels you will also need to fill in the xmltv id according to what you see in schedulesdirect (it's a tooltip when you edit the listing) to have the listings match up. my digital scan found channels i didn’t want, so i deleted those by arrowing to each one and pressing D. i also mark the analog channels that are also available digitally as not visible so i don’t accidentally record the analg version of a show when i could have recorded the digital.
under storage directories, choose default, then add new directory. enter the directory you want mythtv to store recordings in and click ok. this directory should be shared through samba for easy playback on windows machines.
from a shell, get your tv listings into the database, then start and autostart the mythtv server:
$ mythfilldatabase # systemctl start mythbackend.service # chkconfig mythbackend on
run mythtv setup from applications → multimedia in the menu for some additional configuration. go to setup. under video, general you can set defaults for recording schedules. i turn off auto expire default because i have enough space i can delete shows manually. under advanced i set time to record before start to 120 (2 minutes) and past end to 300 (5 minutes) to help catch the entire show if the channel is running a little early or late. i also set category of sports event to record 30 minutes past the end.
since i don't plan on logging into my server for x sessions, i use mythweb (installed to
/var/www/html/mythweb/ in case you need to point apache to it) to schedule recordings. access it from http://yourserver/mythweb/. to record something, first find the show either through browsing the listings from the link in the upper left, or using the search box in the upper right. click on the link for the show and choose whichever schedule option works best for you. click update recording settings and your show will be scheduled to record.
since i’m also running other sites, i change the DocumentRoot away from /var/www/html. to get mythweb to still be accessible, i set up an alias for /mythweb to /var/www/html/mythweb. this breaks mythweb, so edit /etc/httpd/conf.d/mythweb.conf and add “RewriteBase /mythweb” after “RewriteEngine on” to get it working again (you will need to restart the httpd service for this to take effect).
i also make mythweb available via the internet so I can schedule recordings even if i’m not home. to do this, set up a directory /var/www/html/mythweb-inet/ and point an apache virtualhost to it. it needs the same mythweb alias but also should use basic auth so only i can access my mythweb from the internet. here’s a sample virtualhost section you could modify and put in httpd.conf:
<VirtualHost *:80xx> DocumentRoot /var/www/html/mythweb-inet Alias /mythweb /var/www/html/mythweb <Directory /var/www/html/mythweb> AuthType Basic AuthName "MythTV on hecubus" AuthUserFile /etc/httpd/.htpasswd/mythweb Require valid-user </Directory> </VirtualHost>
make sure to set whichever port you intend to use in place of 80xx, and add a Listen 80xx to match. to handle the auth, create the directory and then the file with its first user. i also included the command for adding another user since it’s slightly different:
# mkdir /etc/httpd/.htpasswd # htpasswd -c /etc/httpd/.htpasswd/mythweb someuser # htpasswd /etc/httpd/.htpasswd/mythweb anotheruser
both of the htpasswd commands will prompt for the user’s password. now we need that mythweb-inet directory and something to kick it into the mythweb alias directory. create /var/www/html/mythweb-inet as root, then also as root create a file index.php inside it with the following contents:
<?php header('Location: http://' . $_SERVER['HTTP_HOST'] . '/mythweb/'); ?>
you’ll need to restart apache for the httpd.conf modifications, as well as opening the port to the internet in iptables and restarting that. then visit your server on that port and you’ll get bumped to /mythweb/ and asked for a password.
sadly it still doesn’t work because php removed support for some bad coding that mythweb was using. to fix it, edit
/usr/share/mythtv/bindings/php/MythBase.php as root, go to line 50 and remove the & in front of $this so it looks this way:
Cache::setObject($this->cacheKey, $this, $this->cacheLifetime);
/var/www/html/mythweb/includes/sorting.php go to line 122 and remove the & from $a and $b to get this:
$response = $function($a, $b);
/var/www/html/mythweb/modules/tv/tmpl/default/schedules.php go to line 88 and insert the following line:
add that same line to
/var/www/html/mythweb/modules/tv/schedules.php before line 50.
now that mythtv is recording to a directory shared through samba and mythweb is working, you can install mythtv recorded programs on any windows machines where you’d like to watch recordings from mythtv.
game servers (tdsm and minecraft)
terraria and minecraft are games that can benefit from running a server so friends can drop in and out. while minecraft’s official server is supported on linux terraria’s isn’t, which is why i use tdsm (terraria dedicated server mod). while i’m sure it’s possible to configure the game servers to start up with fedora, i haven’t actually done that so need to start them manually.
the tdsm website is unfortunately not well organized, and parts of it are frequently broken (currently the wiki only shows a database error and the bug reporting site doesn’t load at all). thankfully the program itself works fairly well, though it won’t give back armor that’s been placed on mannequins, forcing me to “cheat” to get my lost items back. find and download the latest version, which will be named
Terraria_Server.exe. put it in its own directory, such as
~/tdsm/, since it’s going to create a bunch of files and directories around itself. also make sure that the user that’s going to run tdsm can write to the directory you put it in.
tdsm is written in .net, so needs mono to run on linux. since it’s designed as a console application rather than a server, it’s helpful to use screen to keep it running after disconnecting your session. install them both:
# yum -y install mono-core screen
now you can run it for the first time. go to the directory you created and put Terraria_Server.exe in, then run it with mono:
$ mono Terraria_Server.exe
it will show some text output and ask if you want to exit for editing, so say yes. the file to edit is
server.properties, which it just created.
there are just a few settings you should change regardless of whether tdsm is going to generate a world for you or if you’re going to use an existing one.
greeting is the message that displays when someone connects. it’s a good idea to customize this; i ask players to join the green team because it will show the direction and distance of other players on the same team.
hackeddata is backward from how it sounds — false means allow hacked health and mana while true means try to detect and block it.
maxplayers might need to go up if you have more than 7 friends.
if you’re having tdsm generate a world, you can customize a lot about how it does that.
always-generate-snow will ensure that the world it generates will include snow if set to true.
opt-numdungeons can be set to 2 if you want an extra dungeon (i wouldn’t recommend more than 2). similarly,
opt-num-floating-islands can set a specific number of floating islands instead of the usual random range determined by the world size. be sure that
opt-custom-worldgen is true for these settings to have any effect.
opt-mapsize sets which size map is generated. you may want medium or large so everyone has room to build their own thing. set
worldpath to the full path and filename where you want it to create a world file. you can simplay change the world1 part to name the world like this:
worldpath=/home/username/tdsm/Worlds/world name here.wld
if you already have a world file (maybe one you created in the game), you can just set
worldpath to point to it.
start tdsm using screen so that you can close your terminal and keep it running:
screen -dm -S tdsm mono Terraria_Server.exe
i put that into a file and give it execute permissions so i don’t have to remember it each time. the -dm makes it run in detached mode, so you won’t see any output until you attach to it. -S tdsm sets the name of the screen to tdsm. you can name it something else if you want. you can attach to the screen with this:
screen -r tdsm
again, tdsm is the name so make sure the -r value here matches the -S value when it was started. from here you can either press ctrl+a then d (don’t hold ctrl when you press d) to detach again, or type exit to shut down tdsm and take screen with it.
to allow connections you’ll need to allow the port (default 7777) through the firewall. also if you want to let friends connect over the internet be sure to forward that port to your server from your router. here’s the line to add to
/etc/sysconfig/iptables (don’t forget to restart iptables to have it take effect):
-A INPUT -m state --state NEW -m tcp -p tcp --dport 7777 -j ACCEPT
for minecraft, download minecraft_server.jar from minecraft.net and place it in a directory such as
~/minecraft/. like tdsm, it’s going to create other files and directories so should be by itself in a directory the account that’s going to run it has full access to. minecraft is written in java, so install openjdk (and also screen if you skipped the tdsm section):
yum -y install java
now start the minecraft server for the first time (make sure you’re in the directory where you put minecraft_server.jar):
java -jar minecraft_server.jar nogui
once it’s finished initializing, enter /stop to exit. it’s generated a bunch of files, and we’ll modify server.properties. enter the name of your world for
level-name. i like to use a texture pack (sphax purebdcraft), so set the path to that zip file in
texture-pack. i create a textures/ subdirectory in my minecraft directory and place the zip file there. note that clients need to be patched to accept high-res textures. set
pvp to false to not need to worry about injuring your friends. if you like to die more, or not to have monsters at all, you can change
difficulty to 0 for no monsters or 2 or 3 for normal or hard (the default is 1 for easy). use
motd (which means message of the day) to provide a welcome message to connecting players. keep it short though because it displays in the server list without much room.
also edit ops.txt (it will be blank to start with) and enter your minecraft account name to make yourself an operator.
assuming you changed the name to something other than world, you can now delete the world directory it created the first time it ran:
rm -rf world/
you can serve a world created in single player by copying its directory from saves to the minecraft server directory (where world/ was) and setting its name in server.properties.
the default minecraft server port is 25565, so it needs to be forwarded from your router and allowed through iptables. here’s the line for iptables:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25565 -j ACCEPT
start minecraft server through screen to keep it running with this command (run from the minecraft server directory):
screen -dm -S minecraft java -jar minecraft_server.jar nogui
i put that into a file and give it execute permissions so i don’t have to remember it each time. the -dm makes it run in detached mode, so you won’t see any output until you attach to it. -S minecraft sets the name of the screen to minecraft. you can name it something else if you want. you can attach to the screen with this:
screen -r minecraft
again, minecraft is the name so make sure the -r value here matches the -S value when it was started. from here you can either press ctrl+a then d (don’t hold ctrl when you press d) to detach again, or type /stop to shut down the minecraft server and take screen with it.
- gnu/linux (fedora)
- file servers (samba, nfs, and pure-ftpd)
- web server (apache, mysql, php)
- personal video recorder (mythtv)
- game servers (tdsm and minecraft)
- all 5 pages
how was it?