Quantcast
Channel: Tutorials – Official Blog – Contabo.com
Viewing all 66 articles
Browse latest View live

Debian & Ubuntu Upgrade

$
0
0

At Contabo, we always offer you the latest version of many popular Linux operating systems. This tutorial shows you how to upgrade from an old version to the latest Debian (stable) or Ubuntu LTS.

Important:
Before proceeding make sure to have a local backup of all important files, the upgrade might fail and your server becomes inoperable!
In case you are upgrading a VPS with 100% SSD, creating a prior snapshot will be sufficient for backup.
The upgrade really depends on the customization performed on the system and the amount of software installed. The higher the amount of additional software, the higher the risk of package-conflicts which need to be solved manually.

1. Preparation

The system needs to get all pending updates for your software packages, prior to proceeding. If you have not installed updates recently this might take some time.
Packages which were installed due to dependencies and are not needed anymore should be deleted as well.

:~#apt-get update && apt-get upgrade -y
:~#apt-get autoremove

2. Adjusting the apt.conf (Debian)

The following commands will replace "stretch" with "buster" in any repository entry.
In case you manually added additional repositories they might fail, you will have to manually investigate or disable those package sources.

:~#sed -i 's/stretch/buster/g' /etc/apt/sources.list
:~#sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/*

Usually there should be no additional package sources configured and your sources list will have the following configuration:

:~# cat /etc/apt/sources.list
deb http://asi-fs-n.contabo.net/debian buster main non-free contrib
deb http://security.debian.org/debian-security buster/updates main contrib non-free
deb-src http://security.debian.org/debian-security buster/updates main contrib non-free
deb http://asi-fs-n.contabo.net/debian buster-updates main contrib non-free

3. a) Start upgrade (Debian)

The following commands will start the upgrade and will also update the packages.

:~#apt clean && apt update
:~# apt upgrade -y
:~# apt dist-upgrade -y
:~# apt autoremove
:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

3. b) Start upgrade (Ubuntu)

Ubuntu has got a Tool/command for this purpose: "do-release-upgrade" it will update to next available LTS version, so 14.04 LTS to 16.04 or 16.04 LTS to 18.04 LTS.
In case the command was not found and the tool is missing, it can be installed with following command:

:~# apt-get install update-manager-core

4. Restart server

In order to use the recently installed kernel, you will have to reboot your server. After rebooting you are running the latest version of Debian (stable)/ Ubuntu LTS.

In case of any issues or inquiries, our customer support team is available to assist you.


Installation of a graphical user interface for Linux

$
0
0

All Linux-Server operating systems are installed by default without a graphical user interface (GUI). A GUI on a dedicated server can only be accessed if a KVM is connected.
This tutorial will guide you through an easy installation process of the two most common GUIs for Ubuntu, Debian and CentOS.
Please note that you will always have to create an additional user for your GUI login, since a login as root is not possible.
In order to access your GUI, you need to use your VPS VNC connection, or access your dedicated server via KVM. KVM access has to be ordered additionally for our dedicated servers, it is not included by default.

Ubuntu 16.04 / 18.04

Please connect to your server as root via SSH.
Create a new user for your GUI login and set a password:

useradd -m NewUserName && passwd NewUserName

Now you can install the Ubuntu-Dekstop GUI with the following command (the server will fetch updates, install the GUI, and reboot automatically):

apt update && apt upgrade -y && apt install ubuntu-desktop -y && init 6

Alternatively, the following command installs the Kubuntu-Desktop (the server will fetch updates, install the GUI, and reboot automatically):

apt update && apt upgrade -y && apt install kubuntu-desktop -y && init 6

You can connect to your VPS via VNC and login to your new GUI, or via KVM if you have a dedicated server.

Ubuntu 18.10 and later versions

Please connect to your server as root via SSH.
Create a new user for your GUI login and set a password:

useradd -m NewUserName && passwd NewUserName

You can choose from a variety of GUIs, which will automatically be installed with the "tasksel" tool:

apt update && apt upgrade -y && tasksel

Choose a desktop of your liking and confirm, please do not install multiple desktop environments at the same time. Reboot your server to make your GUI accessible via your VPS VNC access or KVM in case of a dedicated server.

CentOS 6

Please connect to your server as root via SSH.
Create a new user for your GUI login and set a password:

useradd -m NewUserName && passwd NewUserName

Now you will need to edit your "/etc/inittab" to boot to runlevel 5 so that you will be able to use the GUI after (re)boot:

nano /etc/inittab

Please change the following line:

id:3:initdefault: -> id:5:initdefault:

Save your changes and close the editor by pressing strg+o, enter, strg+x.

The following command will update your server and install the GNOME GUI and required software (the server will be rebooted automatically):

yum update -y && yum -y groupinstall "Desktop" "X Window System" "Fonts" && init 6

Now you can access your GUI via your VPS VNC access or KVM in case of a dedicated server.

In order to install the KDE GUI, please use the following command. Your server will also be updated and rebooted:

yum update -y && yum -y groupinstall "KDE desktop" "X Window System" "Fonts" && init 6

Now you can access your GUI via your VPS VNC access or KVM in case of a dedicated server.

CentOS 7

Please connect to your server as root via SSH.
Create a new user for your GUI login and set a password:

useradd -m NewUserName && passwd NewUserName

Now you can install the KDE GUI with the following command (the server will fetch updates, install the GUI, and reboot automatically):

yum update -y && yum -y groupinstall "KDE Plasma Workspaces" && ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target && init 6

As alternative the following command for an installation of the GNOME GUI (the server will update and reboot automatically):

yum update -y && yum -y groupinstall "GNOME Desktop" "Graphical Administration Tools" && ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target && init 6

You can connect to your VPS via VNC or KVM in case of a dedicated server and login to your new GUI.

Debian 8 and later versions

Please connect to your server as root via SSH.
Create a new user for your GUI login and set a password:

useradd -m NewUserName && passwd NewUserName

Now you can install the GNOME GUI with the following command (the server will fetch updates, install the GUI, and reboot automatically):

apt update && apt upgrade -y && apt install gnome -y && init 6

As an alternative the following command for an installation of the KDE GUI (the server will update and reboot automatically):

apt update && apt upgrade -y && apt install kde-standard -y && init 6

Now you can connect to your VPS via VNC or KVM in case of a dedicated server and login to your new GUI.

Webspace: Creating a Blog in Minutes

$
0
0

This tutorial will show you how to create a blog and publish it world wide in just a couple of minutes.

The requirement for the Softaculous automatic WordPress installation is a Webspace package L or higher.
Alternatively, WordPress can be installed manually by uploading files via FTP.

1. Login to your cPanel account after receiving the e-mail containing the login information.

2. Within "Softaculous Apps Installer" click on "WordPress" to open the following site:

3. This site shows all existing WordPress installations, as we are setting up WordPress for the first time we will hit "Install Now" in order to install our first WordPress site.

In case you want the WordPress site to be hosted on a subdomain or alternate directory you will be able to adjust the configuration to meet your requirements. We are going to use the main domain the Webhosting package was set up with, in this case we will have to remove the "wp" within the "in directory" option.

Set a secure password, adjust the remaining configuration options and hit "start installation".

That's it!
The Blog is installed, you are ready to upload content and share it world wide.

We recommend enabling automatic updates or at least perform manually updates often.
WordPress is a very common software used for websites, especially for blogs. As a very high amount of websites run WordPress, hackers always work on finding new security holes in order to hijack or even infect the website with malware.
WordPress updates are very important in order to run a safe website.
You should make sure to not run any outdated software on a website, even WordPress plugins need to be updated as well.

In case you want to reinstall the blog, use another software or the Contabo Website Builder instead, you are able to remove WordPress at any time using the Softaculous App Installer WordPress site within your cPanel login.

LEMP: Debian, NGINX + Certbot, MariaDB, PHP

$
0
0

This tutorial shows you how to prepare your Debian VPS for hosting your website.
We are not going to perform any fine-tuning or optimization on the default configuration files. So neither NGINX, MySQL or PHP (LEMP) will get any other than the necessary configuration changes in order to run a website properly.

1. Install the Software

NGINX, Certbot, PHP installation:

:~# apt install nginx python3-certbot-nginx php-fpm php-mysql zip unzip pwgen

MariaDB can be installed as follows:

:~# apt install mariadb-server

Installing MariaDB by using the default-package repositories might not install the latest version of MariaDB. For the latest MariaDB version visit Official MariaDB Repo and follow the instructions.

2. Configure the Software

You should secure your MariaDB installation first:

:~# mysql_secure_installation && mysql_upgrade
:~# mysql

 Welcome to the MariaDB monitor.  Commands end with ; or \g.
 Your MariaDB connection id is 55
 Server version: 10.4.6-MariaDB-1:10.4.6+maria~buster mariadb.org binary distribution
 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 

We will now run Certbot for our default vmXXXX.contaboserver.net hostname, you could also simply add any other website.

Important:
In case you want to secure multiple domains you can simply add them with another "-d" option behind the command, e.g.:

:~# certbot --nginx -d $(hostname) -d vmXXXX.contaboserver.net

Certbot will also create a default configuration for your website within /etc/nginx/sites-enabled/

Let's configure PHP, so NGINX knows where to send PHP-Files for interpreting. Check where PHP-FPM listens to:

:~# grep "listen =" /etc/php/7.3/fpm/pool.d/www.conf
listen = /run/php/php7.3-fpm.sock

The pool configuration file got a lot of parameters which can be adjusted according to the hardware your server is running and the type of scripts hosted on your website.
Open /etc/nginx/sites-enabled/default and you will see a PHP section which is commented out, you could install multiple PHP-Versions, add a server or VPS for PHP interpreting only and much more.
We will add the following lines to any "server {}" configuration we want PHP to be available on:

location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}

You also need to expand the "index" line with "index.php" :

 index index.php index.html index.htm; 

:~# systemctl restart nginx

We will now download and install phpMyAdmin and make it available. On Debian 10 phpMyAdmin is not available via "apt install phpmyadmin" command, they are probably going to add the package once the Alpha got stable.
For downloads visit Official phpMyAdmin Website . As we are using PHP 7.3 we need to download the Alpha Version, which is still in testing phase.

:~# mkdir /var/www/phpmyadmin
:~# cd /var/www/phpmyadmin/
:~# wget https://files.phpmyadmin.net/phpMyAdmin/5.0.0-alpha1/phpMyAdmin-5.0.0-alpha1-all-languages.zip
&& unzip phpMyAdmin-5.0.0-alpha1-all-languages.zip
:~# mv phpMyAdmin-5.0.0-alpha1-all-languages/* .

Create a database user and import the database; run "pwgen" to generate random passwords.

:~# mysql < sql/create_tables.sql
:~# mysql

CREATE USER 'phpmyadminuser'@'localhost'  IDENTIFIED BY 'USE ONLY SECURE PASSWORDS !!';
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'phpmyadminuser'@'localhost'
IDENTIFIED BY 'USE ONLY SECURE PASSWORDS !!'; FLUSH PRIVILEGES;

Let's configure phpMyAdmin to use the database. Uncomment the following lines in config.inc.php:

/* User used to manipulate with storage */
  $cfg['Servers'][$i]['controlhost'] = 'localhost';
  $cfg['Servers'][$i]['controlport'] = '3306';
  $cfg['Servers'][$i]['controluser'] = 'phpmyadminuser';

:~# cp -p config.sample.inc.php config.inc.php
:~# pwgen 32 1 #Copy the password for blowfish secret
:~# chown www-data: /var/www/phpmyadmin -R

Last but not least, configure the webserver to make the content available.
Add the following section to the domain you want to expose it on:

    location /phpmyadmin {
           root /var/www/phpmyadmin/;
           index index.php index.html index.htm;
           location ~ ^/phpmyadmin/(.+\.php)$ {
                   try_files $uri =404;
                   root /var/www/phpmyadmin/;
                   fastcgi_pass unix:/run/php/php7.3-fpm.sock;
                   fastcgi_index index.php;
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           }
           location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                   root /var/www/phpmyadmin/;
           }
    }

Webspace: How to run Auto-SSL manually

$
0
0

A free SSL certificate for your domain can be installed at any time within cPanel. Your website will receive automatically a free SSL certificate after 12-24 hours, however requesting the certificate manually will install it immediately.

In case your browser shows the following warning when accessing your website via https:// the SSL certificate might not be installed yet.

In order to request the certificate manually you need to login to your cPanel account, the login information was sent to you via E-Mail before.

Once logged in you need to navigate to "SSL/TLS Status".
Afterwards select the checkbox of the domain you would like to secure and hit "Run AutoSSL".

Important: In case of an error you further need to investigate the reason. A certain amount of failed SSL requests will get your domain suspended from Let's Encrypt Auto-SSL, the suspension might last several days or even weeks.
The following request failed as the DNS was not updated yet. It might take up to 24-48 hours in case your domain is being transferred. Recently (newly) created domains might take several hours to work properly.

In our case the subdomain was missing in DNS-Management, we added a corresponding entry and waited a couple of minutes (one cup of coffee).

We rescheduled AutoSSL to run immediately and it properly installed the certificate:

The website is accessible via https:// and no browser warning will be displayed.

In order to redirect any non secured "http://" to secured/encrypted "https://" traffic you might want to add a corresponding .htaccess redirect rule or alternatively add a rule within cPanels "Redirect" menu:

A common issue after securing your website is the so called "mixed content", in case you are using static .html files you need to update any http:// reference to https:// manually.
The browser's "lock" icon will appear green afterwards.

In case you have any issues with Auto-SSL feel free to contact our customer support via E-Mail. Please make sure to wait at least 24 hours, in case your domain is still being transferred.

Scheduled backups in cPanel and Plesk

$
0
0

Creating backups is a very important task for every server administrator. A loss of data often occurs suddenly without a warning. It is possible to create backups manually, but we would recommend to configure automatic backups. The steps below were tested by us, but you should always check yourself if the backups are still running from time to time and if it is possible to restore the required data from it! A backup should be stored outside of the system. In the examples below we are using the Contabo Backup Space. You can order it additionally to your server.

Scheduled backups in cPanel

To configure automatic backups in cPanel, please go to WHM > Backup > Backup configuration. At first you have to set the tick at "Enable Backups". Then we would recommend to set the backup to "compressed". With incremental backups, you can not save to FTP in cPanel. The other global settings should be left the way they are.

In the section "Scheduling and Retention", it is useful in most cases to select every day of the week except Sunday and to keep six of those daily backups. Furthermore you should enable weekly backups and keep four of them, just in case a problem is noticed later or with some delay. Please create the weekly backups on Sunday, the day we left out in the section for the daily backups.

If you are not sure what you should backup in the next section, you can just select everything as shown in the image below. If you need to save backup space, you can unselect the system files and change the database backups from "Per account and entire MySQL Directory" to "Per account only". Normally the files and databases of the accounts will contain the most important data and the other parts contain settings that can be reconfigured after reinstalling the server in case of a full loss of data.

The next settings should be left the way they are. Especially the option "Mount Backup Drive as Needed" should be left without a tick, as this will cause problems if /backup is no mount point for a separate partition or drive:

Then please click on "Additional Destinations" at the top of the site. There you can configure the remote storage for your backup. You will find the correct settings for the Contabo Backup Space below. Unfortunately cPanel does not support ftps, so you should leave the tick for "Transfer System Backups to the Destination" unselected. Please confirm and save your data with the option "Save and Validate Option".

Backups can be restored in WHM > Backup > Backup Restoration. There you can select "Restore by Date" and you will see all available backups in the calendar. Please select the date with the last known good state and move the users you want to restore into the restoration queue. With "Restore", you will restore all the listed accounts.

Scheduled backups in Plesk

To configure automatic backups in Plesk, please go to Tools & Settings > Tools & Resources > Backup Manager > Schedule .
On the site, please put a tick at "Activate this backup task". Then select a reasonable time for your backups. As backups require a lot of resources and might slow down your system, you should perform your backups in the night, for example at 2:00 am. In the most use cases it is a good idea to configure daily incremental backups and to perform a full backup once a week. Incremental backups will just store the changes, so it is possible to restore your data from every available day. But the required backup storage is less than with a daily full backup. In the section "Backup settings", you can add a remote ftp backup storage. This makes sense, as the backup is then stored independently from your system. Please fill in your credentials in the form that opens and enable passive mode and FTPS as shown in the image below:

After the remote backup storage got added, please select that you want to store the backups locally and on the remote FTP storage you just added. Also it makes sense to add an e-mail address where the server can inform you in case something goes wrong during your backup task. Please check your settings with the help of the image below and click on apply.

After the the first backup is done, you should see a list of the available backups listed by day and time in Tools & Settings > Tools & Resources > Backup Manager. To download or restore a backup, please klick on the required backup. In the section "Backup content", you can choose between restoring "Selected objects" and "All objects". In Selected Objects, you will have several options to only restore specific content like e-mail accounts from a selected domain. You have to move all units you want to restore from the left window to the right and confirm with "Restore".

Viewing all 66 articles
Browse latest View live