Anleitung für eine volle Installation des Teamspeak Interface, inklusive Apache, MySQL, PHP, ionCube und TeamSpeak 3


Author: BriannaJoyy
1.  Create Digital Ocean Droplet

Digital Ocean is a super easy virtual server platform.  They make it extremely easy to spin up new servers for testing or production, and also provide an incredible amount of documented resources and help to get you going.  If you have not signed up for Digital Ocean, but find that this guide has been helpful, please click on the Digital Ocean logo below – this is my referral link, and will get you $10.00 worth of credit towards your virtual servers.


2.  Log into Droplet with SSH

Log into Digital Ocean and create a new droplet.  Go with Ubuntu 16.04.2 x64 and then pick your size (the $5.00/month tier is fine, but I recommend the $10.00/month tier for teamspeak).  Next choose a datacenter region closest to you and change the hostname to something friendly. (ts.yourdomainname.com)

Click Create and your droplet will be created.  You will now receive an email that contains your IP address and temporary root password – copy that root password from the email and open PuTTY.  Enter in the IP Address for your Digital Ocean droplet and press Enter to connect.  Click YES when asked about authentication, and then login with root as the username.  When prompted for the password, use SHIFT+INS to paste the password you copied from email.

You are first prompted to change your root password.  Click SHIFT+INS again to paste the copied ‘current’ password one more time, and then enter in a new password twice to set a new root password.  This password should be a significantly strong password, and follow best practices for password creation.

3.  Update Ubuntu

The following command will update and upgrade all packages for Ubuntu
sudo apt-get update && sudo apt-get -y upgrade
4.  Create a New User

When I create a Droplet that is going to be exposed to the open Internet, I like to ensure that there are multiple layers of security to prevent intrusion.  One of the first layers of security includes disabling the ability for root to log onto the server.  To do this, we first need to create a new user.  From SSH, type the following:
adduser teamspeak
In my case, my username was teamspeak so I typed ‘adduser teamspeak’ in PuTTY.
You will be prompted to enter a password twice, and then prompted for additional information (which you can skip through).  Once you get to the confirmation, press Y to confirm, and your new user is created.
Now we need to allow our new user to use sudo to run root commands on the server.  Type the following:
gpass -a teamspeak sudo
This adds your newly created username to the sudo group.

5.  Change SSH to a Non-Standard Port and Disable root Login Access

Another security measure is to change SSH from port 22 to something that is not as easy to guess.  In my case, I use 2222, but you can use whatever port you like.  Type the following to edit the SSH configuration file:

nano /etc/ssh/sshd_config

Find the line that says:

port 22

and change it to your desired port – in my case, I set it to:

port 2222

Then, find the line that says:

PermitRootLogin yes

and change it to:

PermitRootLogin no

Hit CTRL+X followed by Y to save and exit the file.  Restart SSH by running:

service sshd restart

Once SSH has been restarted, close PuTTY and then re-launch it.  This time, when you enter in your Droplet’s IP address, make sure you also change your port number to the SSH port you changed in the SSH config file.  When prompted with ‘Login as:’ also remember to use the username you created instead of root – since root no longer has access to log in via SSH.

Once logged back in, you can do:

su root

and then enter your root password to become root again and finish off your configuration.

6.  Set up Firewall

Next, we want to block any ports that we aren’t going to use – or in other words, we want to specifically allow only ports that we want to allow.  Run the following commands:
sudo ufw allow 9987/upd
sudo ufw allow 10111/tcp
sudo ufw allow 3033/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 2222/tcp

This opens up all of the necessary Teamspeak default ports.  When you’re ready to actually commit these rules, you can double-check that all of your ports were entered correctly by typing (remember for each virtual server port you add, you will need to add the new port to the firewall rules as well):

sudo ufw show added
Once you’re happy, run:
sudo ufw enable
This turns on the firewall, and you’re good to go.  If you did anything wrong, it is entirely possible that you just locked yourself out of your own Droplet…but no worries!  Just go back to your Digital Ocean dashboard, destroy your droplet, and start over. Remember that you need to update UFW for each new instance of Teamspeak.


7.  Configure Time Zone

Set up your Time Zone by running:
sudo dpkg-reconfigure tzdata
A pink bordered window will appear – select your geographic area (use America for United States) and then select your city/time zone from the list.  You can press TAB, arrow keys, and SPACE to move around these screens and make selections.
Once your time zone has been selected, press OK, and you’re done with Step 6.
8.  Configure NTP

Set up NTP (Network Time Protocol) by running:
sudo apt-get update
sudo apt-get install ntp
This sets up your time server and syncs the clock.  You can check NTP status by running:
service ntp status
Your local time should be set correctly (in 24-hour format).

9. Set Up a Swap File

Run the following commands to create and use a swap file.
sudo fallocate -l 4G /swapfile
This allocates 4GB as a swapfile in the /swapfile directory.
sudo chmod 600 /swapfile
Sets permissions on the swap file directory.
sudo mkswap /swapfile
Formats the swap file directory for use as a swap file.
sudo swapon /swapfile
Tells the server to use that directory as a swap file.
Finally, we need to make sure that the swap file turns on every time we reboot the server.  Run the following command to add the swap file information to the /etc/fstab file:
sudo sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'
To verify that the command worked, type:
nano /etc/fstab
and look for a line that says:
$ /swapfile non swap sw 0 0
If that line exists in the /etc/fstab file, you’re all good.

10.  Upgrade Linux Kernel

*** EDIT 10/26/2017 – This step is probably no longer necessary.  I just did a new DO Droplet today, and it is now 4.4.0-97-generic by default.  That being said though, there probably no harm in simply running the sudo apt-get-install linux-image-generic command anyway.
There is a problem with the default Linux kernel that you get when you fire up the Ubuntu Droplet.  If you type:
uname -r
You should see the following:
$ 4.4.0-81-genderic
This version needs to be on -83 instead of -81 for Teamspeak to function correctly.  Run the following commands to update the Linux kernel:
sudo apt-get isntall linux-image-generic
This will take a minute or two to run – once done type:
reboot
to reboot the Droplet.  You will be disconnected from PuTTY – wait about 60 seconds, and then log back in via SSH.
Now, if you run:
uname -r 
You should see:
$ 4.4.0-83-generic
All set!


11.  Download and Extract Teamspeak
The next task will be to download the latest Teamspeak 3 Server software for linux. You may utilize the wget command to download the setup file directly to the
wget http://dl.4players.de/ts/releases/3.1.2/teamspeak3-server_linux_amd64-3.1.2.tar.bz2
Once it finishes, we will need to extract the archive:
tar xvf teamspeak3-server_linux_amd64-3.1.2.tar.bz2
 All the contents will appear in the teamspeak3-server_linux_amd64 directory. The next step will be to move everything to /home/teamspeak.
cd teamspeak3-server_linux_amd64 && mv * /home/teamspeak && cd .. && rm -rf teamspeak3-server_linux_amd64-3.1.2.tar.bz2

Execute the ls command and you should see a similar screen if everything was done correctly:

12.  Accept the Teamspeak 3 license agreement

Since the release of Teamspeak 3 server version 3.1.0, it is mandatory to accept a license agreement. The quickest way to do this is by typing the following command:
touch /home/teamspeak/.ts3server_license_accepted
This will create a new empty file called .ts3server_license_accepted, which will act as the license agreement.


13. Start the Teamspeak 3 server on boot

Now it's time to configure the Teamspeak 3 server to start on server boot. To do this we need to create a file called teamspeak.service in /lib/systemd/systemdirectory. The following command will do the trick:
sudo nano /lib/systemd/system/teamspeak.service
The file should consist of the following, you can paste this:
[Unit]
Description=TeamSpeak 3
ServerAfter=network.target
[Service]
WorkingDirectory=/home/teamspeak/
User=teamspeak
Group=teamspeak
Type=forking
ExecStart=/home/teamspeak/ts3server_startscript.sh start
ExecStop=/home/teamspeak/ts3server_startscript.sh stop
PIDFile=/home/teamspeak/ts3server.pid
RestartSec=15
Restart=always
[Install]
WantedBy=multi-user.target
Make sure to save it with CRTL+X, Next we'll have to activate the script and make it start on server boot.
systemctl enable teamspeak.servicesystemctl start teamspeak.service
Double check it was added with:
systemctl | grep teamspeak.service
If the Teamspeak 3 Server is running correctly, you will see the following result:
You may also check a detailed Teamspeak 3 Server status by executing:
service teamspeak status

14. Retrieve the privileged key

Since Teamspeak 3 Server is now running, let's get the last piece of the puzzle - the privileged key. You'll need to paste it when connecting to the server for the first time. You can view it with the following command:

cat /home/teamspeak/logs/ts3server_*

Congrats now you are ready to connect to your new Teamspeak 3 Server on Ubuntu!!

15. Installing the Teamspeak Interface

First we must install Apache 2.4 from the Ubuntu repository:
sudo apt-get install apache2


16. Install and Configure MySQL

Now we need to install MySQL, enter the following command:
sudo apt-get isntall mysql-server
A. Login to MySQL:
mysql -u root -p
Enter the MySQL's root password, and you'll be presented with a MySQL prompt

B. If no password was entered in the previous section, or if you want to change the root password, enter the following command. Replace [password] with a new root password
ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY 'password';
C. Create a Database and User with permissions for it. In this case, the database is called [tsi], the user [tsiuser], and password [password]
CREATE DATABASE tsi;
GRANT ALL ON tsi.* TO 'tsiuser' IDENTIFIED BY 'password';
D. Exit MySQL
quit

17. Install PHP 7.2

Install PHP, the PHP Extensions and Application Repository, Apache support, MySQL support and all TSI requirements
sudo apt-get isntall php7.2 libapache2-mod-php7.2 php7.2-mysql php7.2-curl php7.2-mbstring php7.2-xml php7.2-zlib php7.2-bcmath php7.2-zip
Next we need to add IonCube Loader, first we need to navigate to the /tmp directory.
cd /tmp
Then we need to download IonCube Loader using the wget command:
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
We now need to unzip the downloaded file using the tar command and move the decompressed folder. Then run the ls command to list the numerous ioncube loader files for different PHP versions

tar -xvf ioncube_loaders_lin_x86*
cd ioncube/
ls -l

We already know we need the ioncube loader for PHP 7.2 as that is what we just installed so let's move that file to proper directory.

php -i | grep extension_dir
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules
Next we need to copy the ioncube loader for our PHP 7.2 version to the extension directory /usr/lib64/php/modules
cp /tmp/ioncube/ioncube_loader_lin_7.2.so /usr/lib64/php/modules
Now all we need to do is configure the php.ini file
nano /etc/php.ini
Then add the below line as the first line in the php.ini file
zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_7.2.so

We also need to make a couple changes to the php.ini to make TSI work properly:
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 60

; Maximum amount of time each script may spend parsing request data. It's a good ; idea to limit this time on productions servers in order to eliminate unexpectedly ; long running scripts. ; Note: This directive is hardcoded to -1 for the CLI SAPI ; Default Value: -1 (Unlimited) ; Development Value: 60 (60 seconds) ; Production Value: 60 (60 seconds) ; http://php.net/max-input-time max_input_time = 120

;;;;;;;;;;;;;;;;; ; Data Handling ; ;;;;;;;;;;;;;;;;;
; Maximum size of POST data that PHP will accept. ; Its value may be 0 to disable the limit. It is ignored if POST data reading ; is disabled through enable_post_data_reading. ; http://php.net/post-max-size post_max_size = 16M


;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. ; http://php.net/file-uploads file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ; http://php.net/upload-tmp-dir ;upload_tmp_dir = ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize upload_max_filesize = 32M ; Maximum number of files that can be uploaded via a single request max_file_uploads = 20
Save and exit the file by using CRTL+X Now we need to restart Apache server for the Ioncube loaders to come into effect.
systemctl restart httpd
To test if ionCube loader is now installed we need to issue the following command:
 php -v
18. Running the TSI installer

Now all we need to do is navigate to your webspace where you TeamSpeak Interface is located (yourdomain.com/install/index.php). Once done quickly run through the few steps on the installer.