1. Set up the virtual server (eg. testserver.local) and a MySQL database. You will need at least MySQL version 5.6 or higher. Currently Debian will ship MySQL version 5.5, so you need to update MySQL. The best way is to use the official MySQL APT tool. Log in to your server as root, or any admin user you prefer.
    cd /root
    wget http://dev.mysql.com/get/mysql-apt-config_0.8.4-1_all.deb
    chmod +x mysql-apt-config_0.8.4-1_all.deb
    ./mysql-apt-config_0.8.4-1_all.deb
    Then choose MySQL version 5.6 or newer.
    apt-get update
    apt-get install mysql-community-server
  2. Install composer as root user and make it globally available:
    curl -sS https://getcomposer.org/installer | php
    mv composer.phar /usr/local/bin/composer
  3. Install PHP(5) modules required for the installation:
    apt-get install curl php5-gd php5-curl php5-intl php-soap php5-xsl
  4. Change directory to the testservers public directory and install Magento2 with composer:
    cd /home/testserver/public_html
    composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .

    You will be promted for the access credentials to your Magento account on the first time. Composer will now download all dependencies, this will take some time.
  5. As we have now everything we need, let's do the actual Magento2 installation:
    bin/magento setup:install --base-url=http://testserver.local/ \ --db-host=localhost --db-name=myDatabaseName \ --db-user=myDatabaseUser --db-password=myDatabasePassword \ --admin-firstname=Magento --admin-lastname=User --admin-email=your@email.domain \ --admin-user=admin --admin-password=myAdminPassword --language=de_DE \ --currency=EUR --timezone=Europe/Berlin --cleanup-database \ --sales-order-increment-prefix="ORD$" --session-save=db --use-rewrites=1
  6. Now Magento2 is installed. The previous command output should have been something like this:
    [SUCCESS]: Magento installation complete.
    [SUCCESS]: Magento Admin URI: /admin_1csz3x
    When you use Virtualmin to manage the hosting server, you will need to adjust some of the .htaccess files, to meet the security policy. Edit the file /home/testserver/public_html/.htaccess, /home/testserver/public_html/pub/.htaccess, /home/testserver/public_html/pub/media/.htaccess and replace:
    Options +FollowSymLinks
    with:
    Options +SymLinksIfOwnerMatch
    Additionally in the /home/testserver/public_html/pub/media.htaccess, change
    Options All -Indexes
    to
    Options -Indexes
    This way, you will not need to mess around with file permissions, as all the files will be owned by the webserver user.
  7. Now visit http://testserver.local for the Magento2 frontend, and http://testserver.local/admin_1csz3x for the backend.