System & Automation Architect
Two years ago, someone asked me to write a tutorial about how to setup a teamspeak server on Ubuntu 15.04. That turorial had been seen so many times, with alot of comments, I thought a new update could be usefull. If you want to see the other tutorial, check https://www.digitalocean.com/community/questions/setup-teamspeak-server-ubuntu-15-04
If you got any problems after using this tutorial, please make a comment. I made this tutorial in a way I think is the best, if you got any improvements or want to use something else please tell me.
First we need to connect to the droplet we created. Once the droplet is created, you will get an email with all the credentials in it. Open PuTTY and use these credentials to login; the first time you login you need to change the password. To make this server secure, I always like to use a RSA key. So I always install my droplet with an SSH key.
MariaDB is a replacement for MySQL with a better performance. The database will hold all users/settings etc. of the Teamspeak server instead of SQLlite. If you already have a SQL database running, skip the first few steps and continue on making a new user for the teamspeak server. Before we can install MariaDB, we need to update & upgrade the packages. So run the following:
apt-get update && apt-get upgrade
Now thats done, we can install MariaDB:
apt-get install mariadb-client mariadb-server
Hit Y when they want you to confirm
Once the install process is finished, you have to setup your MariaDB install with new root password (default is blank). Issue this command:
/usr/bin/mysql_secure_installation
Enter current password for root (enter for none): Enter
Set root password? [Y/n] y
New password: PassWordGoesHere
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Now the MariaDB service should be running with a new root password.
Lets configure the database now. We will create a new user and database for the Teamspeak server. Create the database with your own password:
mysql -u root -p
Enter the root user password
create database teamspeak3;
GRANT ALL PRIVILEGES ON teamspeak3.* TO 'teamspeak3'@'localhost' IDENTIFIED BY 'TeamspeakUserPasswordGoesHere';
Change TeamspeakUserPasswordGoesHere with a secure password
flush privileges;
quit
First we will create a new user with its own directory in /opt/. Then we will download the latest teamspeak server and unpack it.
useradd -d /opt/teamspeak3-server -m teamspeak3-user
Now go to the temp dir, there we will download the Teamspeak server
cd /tmp
To find the latest download link, go to https://www.teamspeak.com/en/downloads.html#server and click on the Copy button next to the Server 64-bit. Then we can download the Teamspeak server:
wget http://dl.4players.de/ts/releases/3.0.13.8/teamspeak3-server_linux_amd64-3.0.13.8.tar.bz2
Then exctract the files of the tarbal:
tar -vxjf teamspeak3-server_linux_amd64-3.0.13.8.tar.bz2
You can easily find the proper name of the tarbal, by typing the first 2-3 characters of the name and then hitting TAB. Debian will search the rest for you.
Now lets move the files to the opt directory, change the permissions of the teamspeak server files and remove all the downloaded files:
mv teamspeak3-server_linux_amd64/* /opt/teamspeak3-server/
chown teamspeak3-user:teamspeak3-user /opt/teamspeak3-server -R
rm -rf teamspeak3-server_linux_amd64-3.0.13.8.tar.bz2 teamspeak3-server_linux_amd64/
Then symlink the libmariadb.so.2 library from /redist folder to TeamSpeak3 server directory.
ln -s /opt/teamspeak3-server/redist/libmariadb.so.2 /opt/teamspeak3-server/libmariadb.so.2
Run ldd to prints the shared libraries required by TeamSpeak3 server.
ldd /opt/teamspeak3-server/libts3db_mariadb.so
If libmariadb.so.2 ==> not found shows, use the following command:
apt-get install libmariadb2
We are going to configure TeamSpeak3 server with the MySQL-MariaDB database, We have to manually create configfiles:
Create the blacklist configfile.
touch /opt/teamspeak3-server/query_ip_blacklist.txt
Create the whitelist configfile.
cat << EOT > /opt/teamspeak3-server/query_ip_whitelist.txt
127.0.0.1
EOT
Create the configfile with MySQL-MariaDB database option.
nano /opt/teamspeak3-server/ts3server.ini
With the following inside of it:
machine_id=
default_voice_port=9987
voice_ip=0.0.0.0
licensepath=
filetransfer_port=30033
filetransfer_ip=0.0.0.0
query_port=10011
query_ip=0.0.0.0
query_ip_whitelist=query_ip_whitelist.txt
query_ip_blacklist=query_ip_blacklist.txt
dbsqlpath=sql/
dbplugin=ts3db_mariadb
dbsqlcreatepath=create_mariadb/
dbpluginparameter=ts3db_mariadb.ini
dbconnections=10
logpath=logs
logquerycommands=0
dbclientkeepdays=30
logappend=0
query_skipbruteforcecheck=0
To save: Hit CTRL + X --> Y
Create the configfile for the database for the TeamSpeak3 server. Change PASSWORD the same password you have created configuring the MySQL database.
nano /opt/teamspeak3-server/ts3db_mariadb.ini
Input:
[config]
host=127.0.0.1
port=3306
username=teamspeak3
password=PASSWORD
database=teamspeak3
socket=
Now you need to change permissions of the new config files:
sudo chown teamspeak3-user:teamspeak3-user /opt/teamspeak3-server -R
Now the configuration is done.
With the autoscript you don’t have to worry about exiting the teamspeak server when you leave the SSH connection. The script will take care of running the server.
Create the script:
nano /etc/init.d/ts3
With:
#! /bin/sh
### BEGIN INIT INFO
# Provides: ts3
# Required-Start: $network mysql
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: TeamSpeak3 Server Daemon
# Description: Starts/Stops/Restarts the TeamSpeak Server Daemon
### END INIT INFO
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="TeamSpeak3 Server"
NAME=teamspeak3-server
USER=teamspeak3-user
DIR=/opt/teamspeak3-server
OPTIONS=inifile=ts3server.ini
DAEMON=$DIR/ts3server_startscript.sh
#PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
sleep 2
sudo -u $USER $DAEMON $1 $OPTIONS
Now change permissions for the scripts:
chmod a+x /etc/init.d/ts3
chmod a+x /opt/teamspeak3-server/ts3server_startscript.sh
chmod a+x /opt/teamspeak3-server/ts3server_minimal_runscript.sh
update-rc.d ts3 defaults
Now everything should be done, and ready to go. Lets start the Teamspeak3 server for the first time:
sudo /etc/init.d/ts3 start
For the token key to become a superadmin on the server, you can check the logs. Make sure you copy this and use it the first time you enter. The logs you can find in this directory:
/opt/teamspeak3-server/logs
The file will look something like this
ts3server_2017-12-29__12_01_21.906198_1.log
You can now connect to the teamspeak server, using the IP of the Droplet.
Hope this tutorial will help you! If you have got any questions, don’t hesitate to ask me in the comments.
Upgrading
When a new version comes out, you can easily upgrade the Teamspeak server. The steps that are needed:
1 Shutdown the server:
/etc/init.d/ts3 stop
2 Download the latest version (which you can find on their website), extract it, move it and change the permissions:
cd /tmp
wget http://dl.4players.de/ts/releases/3.0.13.8/teamspeak3-server_linux_amd64-3.0.13.8.tar.bz2
Then exctract the files of the tarbal:
tar -vxjf teamspeak3-server_linux_amd64-3.0.13.8.tar.bz2
You can easily find the proper name of the tarbal, by typing the first 2-3 characters of the name and then hitting TAB. Debian will search the rest for you.
Now lets move the files to the opt directory, change the permissions of the teamspeak server files and remove all the downloaded files:
mv teamspeak3-server_linux_amd64/* /opt/teamspeak3-server/
chown teamspeak3-user:teamspeak3-user /opt/teamspeak3-server -R
rm -rf teamspeak3-server_linux_amd64-3.0.13.8.tar.bz2 teamspeak3-server_linux_amd64/
3 Start the server again:
/etc/init.d/ts3 start
Using an external database
I do not recommend using an external database. It only slows down writing the data and settings and it is not really needed. Instead, use the SQLite database. This is also working the same as the MariaDB database, except you can’t get inside the records. For that, don’t use the ts3db_mariadb.ini and use the following ts3server.ini file:
machine_id=
default_voice_port=9987
voice_ip=0.0.0.0
licensepath=
filetransfer_port=30033
filetransfer_ip=0.0.0.0
query_port=10011
query_ip=0.0.0.0
query_ip_whitelist=query_ip_whitelist.txt
query_ip_blacklist=query_ip_blacklist.txt
dbsqlpath=sql/
dbplugin=ts3db_sqlite3
dbsqlcreatepath=create_sqlite/
dbpluginparameter=
dbconnections=10
logpath=logs
logquerycommands=0
dbclientkeepdays=30
logappend=0
query_skipbruteforcecheck=0
If you really want to use an external MariaDB database tho, make sure the following is correct:
You can’t get into the logs directory or edit the log file
This can happen when you aren’t logged in as root, because we changed the permissions of the teamspeak-server directory so only the teamspeak user has access. Things you can do to still open the files:
To change to root, you need to know the password of the root account OR have sudo permissions. First try with sudo permissions:
sudo su
If you don’t have sudo permissions, you need to give the teampseak3-user a password and change to that user. To change the password, run the following:
passwd teamspeak3-user
After changing the password, you can change user and check the logs:
su teamspeak3-user
cd /opt/teamspeak3-server/logs
Server() unable to initialize database
If you get the above error, there might be something wrong with the MariaDB / Teamspeak configuration. To debug this issue, try one of the following
ts3db_mariadb.ini configuration. Is everything correct? Is the password the same as the MariaDB user password?socket= inside the ts3db_mariadb.ini configuration. This helps sometimes.This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
For all that want a auto-restart script using systemd
To create a script that auto-restarts, you could setup a systemd script. systemd is a system and service manager for Linux which has become the de facto initialization daemon for most new Linux distributions. First implemented in Fedora, systemd now comes with RHEL 7 and its derivatives like CentOS 7. Ubuntu 15.04 ships with native systemd as well. Other distributions have either incorporated systemd, or announced they will soon.
Follow the next steps to creat this script:
Create the new script:
cat > /etc/systemd/system/teamspeak3.service << EOF
[Unit]
Description=TeamSpeak3 Server
Wants=network-online.target
After=syslog.target network.target
[Service]
WorkingDirectory=/opt/teamspeak3-server
User=teamspeak3-user
Type=forking
Restart=always
ExecStart=/opt/teamspeak3-server/ts3server_startscript.sh start initfile=ts3server.ini
ExecStop=/opt/teamspeak3-server/ts3server_startscript.sh stop
ExecReload=/opt/teamspeak3-server/ts3server_startscript.sh reload
PIDFile=/opt/teamspeak3-server/ts3server.pid
[Install]
WantedBy=multi-user.target
EOF
Hit enter
Now stop the current server and disable the init.d script:
/etc/init.d/ts3 stop
update-rc.d ts3 disable
Enable the new systemd script, and start it.
systemctl enable teamspeak3
systemctl start teamspeak3
Troubleshooting teamspeak server won’t start It is possible your server won’t start, when you got one of the following errors:
failed to update local accounting service
Server() error while starting servermanager, error: instance check error
This error happens when you don’t have a license and the teamspeak service doesn’t have the ability to check the Debian server for other teamspeak servers running. Check the following:
Quote Originally Posted by Server_quickstart.txt In some cases, the server process terminates on startup and the error message reads “Server() error while starting servermanager, error: instance check error”. As long as you don’t have a license key embededded we make sure you only run exactly one instance of the TS3 server free unregistered version. We use shared memory to facilitate the communication to detect other running instances, which requires tmpfs to be mounted at /dev/shm. If you (for whatever reason) do not have this mounted, the above error will occur.
To fix this problem, the following commands or file edits need to be done as root user (or using something like sudo). This is a temporary fix until your next reboot.
mount -t tmpfs tmpfs /dev/shm
Now, to make sure this mount is done automatically upon reboot edit the file /etc/fstab and add the line:
tmpfs /dev/shm tmpfs defaults 0 0
Works great. A note for those on the latest version of teamspeak you need to accept the license agreement with a global environment variable or with a file. Easy to implement:
[sudo touch /opt/teamspeak3-server/.ts3server_license_accepted]
Hope that helps anyone with a server that won’t start.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.