Skip to main content

Configuring the environment

On this page, you get informations about configuring your web server, etc. for hosting Typo3.

About Composer

There are two ways of installing Typo3 and managing an installation: via composer or in the traditional way. Composer is officially recommended, so you should probably use it. I have seen extensions that can only be installed by composer, so the days of the traditional way are counted. Mixed installations are not possible, if you use composer for the base installation, you have to use it for installing extensions, too.

I do not use composer. There is a simple reason: Shared hosting. Command line access gets extra charged, ready-to-use packages come without composer. On my develpoment machine at home, I do not want to have options that are missing in the production environment.

So to the drawbacks: To use the command line typo3, you have to have the package cms-cli installed. This requires composer. Fortunately, there is the package typo3_console that can be installed via the extension manager. It runs crawler queues (after adjusting file permissions), so anything is fine, at first.

 

Transferring data from one Typo3 installation to another

When you get a testing installation at home and a production installation on the internet, you sometimes have to sync them. The best technique is surely to use git. You should also create a sitepackage.

When you want to transfer a complete site, you can pack all the files, dump the database, and, on the destination computer, unpack the files and undump the database. I had to recreate the site entry, and it was done. Here is one description using phpMyAdmin, there is another using mysqldump. By the way, you can of course use these methods to backup your Typo3 instance, too. It is helpful to do some cleanup before dumping the database. This cleanup does not only save bandwidth, it also avoids problems, as tables about cached data contain absolute path names. Do it this way:

  • Flush all caches (top menu, also Admin Tools/Maintainance)
  • Clear persistent tables (Admin Tools, Maintainance)
  • Remove temporary assets (Admin Tools, Maintainance)

There exists a phpmyadmin plugin for Typo3. You may even use it to read in a dump of your database (this is uncool, but I had to do it once because a provider's (before you ask: not at Serverprofis; here anything runs fine) other phpmyadmin was broken.  But then you should log out immediately after the restore is done.

For transferring part of the page tree, there is XML import and export (right-click the page, click More Options, and there you are. You may transfer a single page or subpages too. Watch the preview report carefully so that you do not miss what will not work. Here is a list of things that do not work and have to be repaired by hand:

  • Categories will not get copied, you have to set them again (and, eventually, to create them).
  • Links get broken. Create them again.
  • When you copy a subtree without checking Update, the pages get numers appended to their names, so home becomes home-1. Needless to say that this ruins your navigation. So either check Update or delete the pages that will get imported.

Improving Security

You should check the Mozilla Observatory for your domain and you should try to get an 'A'. Getting 'B+' is easily achievable with Typo3. The normal way to improve your rating with a site running on Apache is to edit the .htaccess-File. I added the following lines to an <IfModule mod_headers.c> section:

# willadt Absicherung
  Header always set Strict-Transport-Security  "max-age=31536000; \
    includeSubDomains; preload"
  Header always set X-Frame-Options     "SAMEORIGIN"
  Header always set X-XSS-Protection    "1; mode=block"
  Header always set Content-Security-Policy "default-src https: ;\
     object-src 'none' ; img-src 'self' data: ; \
     base-uri 'self'; frame-ancestors 'self' ; \
     style-src 'self' 'unsafe-inline' ;\
     script-src 'self' 'unsafe-eval' 'unsafe-inline' ; \
     form-action 'self' ; \
     font-src 'self' fonts.gstatic.com; "

If your hosting provider does not offer mod_headers.c, you can use Typoscript for the same results. I added the following lines to the setup section of my template:

config.additionalHeaders {
 10 {
    header = X-Content-Type-Options: nosniff
    # replace previous headers with the same name?
    replace = 1
  }
  20 {
    header = X-Frame-Options: SAMEORIGIN
    replace = 1
  }
  30 {
     header = X-XSS-Protection: 1; mode=block
    replace = 1
  }
  40 {
    header = Content-Security-Policy: default-src https: ; object-src 'none' ; img-src 'self' data: ; base-uri 'self'; frame-ancestors 'self' ;       style-src 'self' 'unsafe-inline' ; script-src 'self' 'unsafe-eval' 'unsafe-inline' ; form-action 'self' ; font-src 'self' fonts.gstatic.com;
    replace = 1
  }
  50 {
      header = Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
  }
}

Unfortunately, you can't use braces to split the CSP line. Oh, before I forget: You have to check your site, perhaps you have to loosen CSP restrictions.

By the way, my strategy for getting the correct settings is:

  1. Consult Mozilla observatory.
  2. Implement recommendations, if not ruled out
  3. Open your browser's development console.
  4. Check your site. Eatch the development console.
  5. Loosen restrictions if anything does not work. Rule out the recommendations causing trouble.
  6. Go to step 1.

Running Multiple Sites with Typo3

A single Typo3 installation is capable of managing multiple sites. But you also have to configure your system accordingly. The following description is for OpenSuSE Leap 15.2.

Configuring the System for Multiple Servers

Let me confess in advance that I do not run a DNS server any more. I created two virtual hosts for my locally running apache, made thema ccessible and told Typo3 about them. These are the steps I took.

  • Edit /etc/hosts. I appended the new host names to the line 127.0.0.1   localhost so that it looked like this:
    127.0.0.1   localhost phasenumkehr.peter.local homepage.peter.local
    (all in one line).
  • Edit /etc/nsswitch.conf. Oh, I have to confess that I deeplay hate zeroconf, uPnP and similiar stuff. I had to change the line reading
    hosts:   files mdns4_minimal [NOTFOUND=return] dns
    to
    hosts:   files dns
    because the zeroconf guys could not imagine that anybody else but them would ever use the top level domain .local.
  • Go to the directory /etc/apache2/vhosts.d. Copy vhost.template to phasenumkehr.conf.
  • edit phasenumkehr.conf. I will only show lines that had to be changed:
    ServerAdmin peter@localhost
    ServerName phasenumkehr.peter.local
    DocumentRoot /srv/www/typo3docs
    [...]
    <Directory "/srv/www/typo3docs">
    Options Indexes SymLinksIfOwnerMatch
    RewriteEngine On
    AllowOverride All
    You may also set ErrorLog and CustomLog.
  • Create and edit homepage.conf the same way.
  • Restart Apache2.
  • Log in to the Typo3 admin panel.
  • Go to Site Management/Sites, edit site configuration.
    • On page General, set useful site identifier, e.g. phasenumkehr, set usefule title, set the etnry point to http://phasenumkehr.peter.local/ (watch for the railing slash).
    • Choose an apropriate language for your site.

Getting Typo3 running on OpenSuSE Leap

Installing Typo3 should be straight and easy, but there are some details I had to touch.

  • Be warned: The Typo3 installation routine does some checks, but you will not get error reporting for every possible error. You should at least check your (Apache) error log.
  • The www root and any files therein should be writable for your Webserver.
  • During Typo3 configuration, some values for PHP have to be changed. I had to encrease limits for memory and open files in /etc/php7/apache2/php.ini. As the installation script checks for it, there should be no problem.
  • You have to check that all required apache modules get loaded. You find the list within /etc/sysconfig/apache2. I had to add
    deflate rewrite filter headers to APACHE_MODULES=.
  • For your server, you have to say
    Options SymLinksIfOwnerMatch
    AllowOverride All
    OverwriteEngine On
    I edited /etc/apache2/default-server.conf for this.
  • I changed ownership of the www root and the typo3 distribution accordingly to wwwrun.
  • Of course, you should reload your apache after these edits.
  • For some reason unknown to me, the default .htaccess file for Typo3 did not get copied to the document root, I had to issue
    cp ./typo3_src-10.4.4/typo3/sysext/install/Resources/
    Private/FolderStructureTemplateFiles/root-htaccess htdocs/.htaccess
    (issued from /srv/www, all in one line with no space between Resources/ and Private, but with space before htdocs).