TYPO3

TYPO3 is a PHP web framework available on different platforms. It provides a backend interface for users and administrators.

Installation

This script installs Typo3 with composer with two different methods. After online installation from Packagist repository it creates a local repository and installs typo agein for comparison. The installation can be reviewed with the link.

#!/bin/sh
# This installs TYPO3 Content Management System
# https://docs.typo3.org/typo3cms/InstallationGuide/In-depth/ThePackageInDetail/Index.html

# TYPO3 8.7
# This version of TYPO3 CMS is suited for PHP 7.0

# TYPO3 9.5
# This version of TYPO3 CMS requires PHP 7.2 or above
# Fluid templates are not required in a minimal install
# "typo3/cms-tstemplate": "9.5.*@dev",
# "typo3/cms-fluid-styled-content": "9.5.*@dev"
exec bash -ex \
0<<-'BASH' \
5<<-'MYREPO' \
6<<-'CMS8' \
7<<-'CMS9' \

        # composer
        mysql --version ||
        apt-get --yes install mariadb-server jq moreutils

        composer --version --no-ansi ||
        DEBIAN_FRONTEND=noninteractive apt install \
                -t stable \
                --quiet \
                --assume-yes \
                --option='Acquire::http::AllowRedirect=true' \
                --option='APT::Get::Download-Only=false' \
        composer php-xml libapache2-mod-php \
        php-gd php-zip php-mysql php-intl php-sqlite3

        sed -f - -i /etc/apache2/sites-available/000-default.conf <<-'EOF'
                /DocumentRoot/s%/var/www.*%/var/www%
        EOF

        cat > /etc/apache2/conf-available/satis.conf <<-'EOF'
                RedirectMatch ^/satis$ /satis/
                Alias /satis/ /var/www/satis/
                Alias /dist/ /var/www/satis/dist/
                <Directory /var/www/satis>
                        DirectoryIndex index.html
                        Options Indexes FollowSymLinks
                        AllowOverride None
                        Require all granted
                </Directory>
        EOF
        cat > /etc/apache2/conf-available/cms.conf <<-'EOF'
                RedirectMatch ^/cms$ /cms/
                Alias /cms/ /var/www/cms/
                <Directory /var/www/cms>
                        DirectoryIndex index.php
                        Options Indexes FollowSymLinks
                        AllowOverride None
                        Require all granted
                </Directory>
        EOF

        a2enconf satis
        a2enconf cms

        xargs -I@ service @ restart \
        <<-'SERVICE'
                apache2
                mysql
        SERVICE

        # www-data
        usermod www-data --shell=
        getent passwd www-data |
        cut -d: -f6 |
        xargs chown www-data -R
        su www-data -c bash\ -ex <<-'WWW-DATA'
                cd && rm -rf cms satis php typo3 || exit 1

                # composer create-project typo3/cms-base-distribution . 8.7.2
                [ -d typo3 ] || bash -ex <<-'TYPO3'
                        mkdir typo3 || exit 2
                        git clone https://github.com/TYPO3/minimal --branch 8.0 typo3
                        composer update --prefer-dist --no-ansi --working-dir=typo3
                TYPO3
                [ -d php ] || bash -ex <<-'SATIS'
                        mkdir php || exit 3
                        git clone https://github.com/composer/satis php
                        jq 'del(.["require-dev"])' \
                        < php/composer.json |
                        sponge php/composer.json
                        composer update \
                                --prefer-dist \
                                --no-ansi \
                                --no-dev \
                                --working-dir=php
                SATIS
                [ -d satis ] || bash -ex <<-'HTML'
                        mkdir satis || exit 4
                        cat > satis/satis.json <&5
                        php php/bin/satis build satis/satis.json satis --no-ansi
                HTML
                [ -d cms ] || bash -ex <<-'TYPO3'
                        mkdir cms || exit 6

                        # local satis repo requires version field
                        <&6 \
                        sed s/\\\^8.7.9/8.7.24/ |
                        3<<-'FILTER' \
                        4<<-'JSON' \
                        jq --slurp --from-file /dev/fd/3 /dev/fd/4 - \
                        > cms/composer.json
                                .[1] * .[0]
                        FILTER
                                {
                                  "version": "8",
                                  "repositories": [
                                        {
                                          "packagist": false
                                        },
                                        {
                                          "type": "composer",
                                          "url": "http://127.0.0.1:8001/satis"
                                        }
                                  ],
                                  "config": {
                                        "secure-http": false
                                  }
                                }
                        JSON
                        composer install \
                                --prefer-dist \
                                --no-ansi \
                                --verbose \
                                --working-dir=cms

                TYPO3
        WWW-DATA
BASH
        {
          "name": "lippydanger/jumpingcrab",
          "homepage": "http://127.0.0.1:8001",
          "repositories": [
                {
                  "packagist": false
                },
                {
                  "type": "composer",
                  "url": "https://packagist.org/"
                }
          ],
          "archive": {
                "directory": "dist",
                "format": "zip",
                "skip-dev": true
          },
          "require-all": false,
          "require-dependencies": true,
          "require-dev-dependencies": false,
  "require": {
                        "typo3/cms-backend": "8.7.24",
                        "typo3/cms-core": "8.7.24",
                        "typo3/cms-cshmanual": "8.7.24",
                        "typo3/cms-extbase": "8.7.24",
                        "typo3/cms-extensionmanager": "8.7.24",
                        "typo3/cms-filelist": "8.7.24",
                        "typo3/cms-fluid": "8.7.24",
                        "typo3/cms-frontend": "8.7.24",
                        "typo3/cms-install": "8.7.24",
                        "typo3/cms-lang": "8.7.24",
                        "typo3/cms-recordlist": "8.7.24",
                        "typo3/cms-saltedpasswords": "8.7.24",
                        "typo3/cms-sv": "8.7.24"
  }
        }
MYREPO
        {
                "name": "typo3/minimal",
                "type": "metapackage",
                "description": "Minimal required set of TYPO3 extensions",
                "license": "GPL-2.0-or-later",
                "authors": [
                        {
                                "name": "TYPO3 CMS Core Team",
                                "role": "Developer",
                                "homepage": "https://forge.typo3.org/projects/typo3cms-core"
                        },
                        {
                                "name": "The TYPO3 Community",
                                "role": "Contributor",
                                "homepage": "https://typo3.org/community/"
                        }
                ],
                "support": {
                        "general": "https://typo3.org/support/",
                        "issues": "https://forge.typo3.org",
                        "irc": "irc://irc.freenode.net/#typo3-cms",
                        "news": "nntp://lists.typo3.org"
                },
                "require": {
                        "typo3/cms-backend": "^8.7.9",
                        "typo3/cms-core": "^8.7.9",
                        "typo3/cms-cshmanual": "^8.7.9",
                        "typo3/cms-extbase": "^8.7.9",
                        "typo3/cms-extensionmanager": "^8.7.9",
                        "typo3/cms-filelist": "^8.7.9",
                        "typo3/cms-fluid": "^8.7.9",
                        "typo3/cms-frontend": "^8.7.9",
                        "typo3/cms-install": "^8.7.9",
                        "typo3/cms-lang": "^8.7.9",
                        "typo3/cms-recordlist": "^8.7.9",
                        "typo3/cms-saltedpasswords": "^8.7.9",
                        "typo3/cms-sv": "^8.7.9"
                }
        }
CMS8
        {
                "name": "typo3/minimal",
                "type": "metapackage",
                "description": "Minimal required set of TYPO3 extensions",
                "license": "GPL-2.0-or-later",
                "authors": [
                        {
                                "name": "TYPO3 CMS Core Team",
                                "role": "Developer",
                                "homepage": "https://forge.typo3.org/projects/typo3cms-core"
                        },
                        {
                                "name": "The TYPO3 Community",
                                "role": "Contributor",
                                "homepage": "https://typo3.org/community/"
                        }
                ],
                "support": {
                        "general": "https://typo3.org/support/",
                        "issues": "https://forge.typo3.org",
                        "irc": "irc://irc.freenode.net/#typo3-cms",
                        "news": "nntp://lists.typo3.org"
                },
                "require": {
                        "typo3/cms-backend": "9.5.*@dev",
                        "typo3/cms-core": "9.5.*@dev",
                        "typo3/cms-extbase": "9.5.*@dev",
                        "typo3/cms-extensionmanager": "9.5.*@dev",
                        "typo3/cms-filelist": "9.5.*@dev",
                        "typo3/cms-fluid": "9.5.*@dev",
                        "typo3/cms-frontend": "9.5.*@dev",
                        "typo3/cms-install": "9.5.*@dev",
                        "typo3/cms-recordlist": "9.5.*@dev"
                }
        }
CMS9

HTML

This typo3 configuration uses backend interface and config files.

  1. Touch FIRST_INSTALL in web

  2. Copy files to public/typo3conf/ext

  3. Start typo3 backend in browser

  4. Open List module menu

  5. Add Home template page with little plus icon

  6. Include template file in setup

  7. Add more template pages inside home

  8. Define page constants

TypoScript
# Constant definition
src="https://lippydanger.jumpingcrab.com/cgi-bin/typo3"

# Include TypoScript in setup
# https://stackoverflow.com/questions/43592397/include-external-setup-files-in-setup-txt-typo3
<INCLUDE_TYPOSCRIPT: source="FILE:typo3conf/ext/menu.txt">

Fluid Templating

Fluid Template have additional variables "{data.title}" for example. This can be used to generate more dynamic templates.

Fluid
page.1 = FLUIDTEMPLATE
page.1 {
   templateName = ForLayouts
   templateRootPaths.1 = typo3conf/ext
   layoutRootPath = typo3conf/ext
   variables {
          contentNormal < styles.content.get
   }
}

Backup

A backup requires the config files and the database.

Backup
#!/bin/sh
# Import Database, TYPO3 Templates and AdditionalConfiguration.php

service mysql stop
service apache2 stop

# AdditionalConfguration.php from stash
usermod www-data --shell=/bin/sh --home=/var/www &&
su - www-data <<-'SH'
        # <?php
        # $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '...';
        # ?>
        git --git-dir=cms/.git show 30f47db5 \
        1>cms/typo3conf/AdditionalConfiguration.php
SH

# Initialize database
: <<-'COMMENT'
        mysql_install_db \
                --skip-auth-anonymous-user \
                --auth-root-authentication-method=socket \
                --rpm \
                --cross-bootstrap \
                --user=mysql \
                --disable-log-bin
COMMENT

# This commands are copied from debian mariadb-server package
usermod mysql --shell=/bin/sh --home=/var/lib/mysql &&
su - mysql \
0<<-'SH' \
3<<-'SQL' \
4</usr/share/mysql/mysql_system_tables.sql \
5</usr/share/mysql/mysql_performance_tables.sql \
6</usr/share/mysql/mysql_system_tables_data.sql

        find -delete
        seq 3 6 | while read REPLY
                do cat <&$REPLY
        done |
        sed -e /@current_hostname/d |
        /usr/sbin/mysqld \
                --lc-messages-dir=/usr/share/mysql/english/.. \
                --bootstrap \
                --basedir=/usr \
                --datadir=/var/lib/mysql \
                --log-warnings=0 \
                --enforce-storage-engine= \
                --disable-log-bin \
                --user=mysql \
                --max_allowed_packet=8M \
                --net_buffer_length=16K
SH
        CREATE DATABASE mysql;
        USE mysql;
        SET @skip_auth_anonymous=1;
        SET @skip_auth_root_nopasswd=1;
        SET @auth_root_socket='root';
SQL

service mysql start

sh \
0<<-'SH' \
3<<-'TYPO3' \
4</var/www/cms/schema.sql \
5</var/www/cms/be_users.sql \
6</var/www/cms/pages.sql \
7</var/www/cms/sys_template.sql
        seq 3 7 | while read REPLY
                do cat <&$REPLY
        done |
        mysql
SH
        DROP DATABASE IF exists typo3;
        DROP USER IF exists typo3;
        CREATE DATABASE typo3;
        CREATE USER typo3 IDENTIFIED by 'strongpassword';
        USE typo3;
        GRANT ALL PRIVILEGES ON typo3.* TO 'typo3';
        -- SET GLOBAL general_log = 'ON';
        SET GLOBAL slow_query_log = 'ON';
TYPO3

service apache2 start