Installing the Typo3 v11 content management system
published onTypo3 is another content management system. However, you might not be too familiar with it as it is aimed more at enterprises rather than a smaller, simpler site or blog that a lot of people use something like Wordpress to create.
Typo3 can be installed on Apache or NGinx and this post will show you how to do both.
Initial setup
To begin with I install some basic packages which can be necessary later on.
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common language-pack-en-base zip unzipsudo locale-gen en_US.UTF-8
Install PHP 8.1
Next I will install PHP by running the following commands
sudo add-apt-repository ppa:ondrej/phpsudo apt updatesudo apt install openssl php8.1-{common, cli, bz2, zip, curl, intl, mysql, snmp, memcached, imagick, gd, fileinfo, imap, ldap, soap, tidy, xml, gd, gmp, pspell, mbstring, opcache, fpm, ssh2, imap, redis, apcu, mcrypt}sudo apt ghostscript imagemagick
To configure PHP I run sudo nano /etc/php/8.1/fpm/pool.d/www.conf and add, or edit, the following lines to look like the ones below
listen = /run/php/php8.1-fpm.socklisten.owner = www-datalisten.mode = 0660
I then make similar edits to the php.ini file by running sudo nano /etc/php/8.1/fpm/php.ini and adding, editing or uncommenting the following lines to look like the ones below
output_buffering = Offexpose_php = offmax_execution_time = 240max_input_time = 60max_input_vars = 1500memory_limit = 512Mpost_max_size = 10Mupload_max_filesize = 10Mdate.timezone = Europe/Londonopcache.enable=1opcache.jit_buffer_size=100Mopcache.jit=1255opcache.memory_consumption=128opcache.max_accelerated_files=10000opcache.revalidate_freq=2
Now install the MariaDB database
The following two commands will install MariaDB and tools necessary for backing databases up. The second of the commands will secure the MariaDB installation.
sudo apt-get install mariadb-server mariadb-backupsudo mysql_secure_installation
There are two other changes which I will make to a configuration file by running sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf and making sure the two lines below appear as shown here.
bind-address = 127.0.0.1local-infile = 0
Set up the Typo3 database
Enter sudo mysql -u root -p at the command line and type the following commands at the MariaDB command prompt.
CREATE DATABASE t3_db charset=utf8mb4;CREATE USER 't3_user'@'localhost' IDENTIFIED BY 'my_password';GRANT ALL PRIVILEGES ON t3_db.* to 't3_user'@'localhost';FLUSH PRIVILEGES;exit
Make sure to change the database name, user name and password to something more secure.
If you are going to use the Apache web server
If you choose to use Apache the enter the following commands at the prompt.
sudo add-apt-repository -y ppa:ondrej/apache2sudo apt update && sudo apt upgradesudo apt-get install apache2 apache2-utilssudo a2enmod mime http2 rewrite deflate expires headers sslsudo apt-get install libapache2-mod-fcgidsudo a2enmod proxy_fcgi setenvifsudo a2enconf php8.1-fpmsudo systemctl restart php8.1-fpmsudo a2dissite 000-default.confsudo systemctl restart apache2
Once Apache is installed create the virtual host file for Typo3 by running sudo nano /etc/apache2/sites-available/typo3.conf and adding the following lines
<VirtualHost *:80> ServerAdmin [email address] ServerName [domain] ServerAlias www.[domain] DocumentRoot /var/www/[domain]/typo3_src-11.5.x Protocols h2 http/1.1 DirectoryIndex index.php index.html <Directory /var/www/[domain]/typo3_src-11.5.x> Options +SymLinksIfOwnerMatch -MultiViews -Indexes -Includes -ExecCGI AllowOverride All Require all granted </Directory> <FilesMatch "\.php$"> SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost" </FilesMatch> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript </IfModule> SetEnv TZ Europe/London AddDefaultCharset UTF-8 DefaultLanguage en FileETag none ###Header set Strict-Transport-Security "max-age=31536000; includeSubdomains;" env=HTTPS Header set X-XSS-Protection "1; mode=block" Header set X-Content-Type-Options nosniff Header set X-Frame-Options SAMEORIGIN Header set Referrer-Policy: no-referrer-when-downgrade ###Header set Content-Security-Policy "default-src 'self';" ###Header set X-Permitted-Cross-Domain-Policies "none" ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Once you have created the Apache virtual host you will want to run the following two commands to activate it.
sudo a2ensite typo3.confsudo systemctl restart apache2
If you are going to use the NGinx web server
sudo add-apt-repository -y ppa:ondrej/nginx-mainlinesudo apt update && sudo apt upgradesudo apt install nginx-core nginx-common nginx nginx-full libgeoip-dev libpcre3-dev
Once NGinx has been installed you will want to run sudo nano /etc/nginx/sites-available/typo3.conf and add the following lines to create the NGinx server block.
server { listen 80; listen [::]:80; root /var/www/[domain]/typo3_src-11.5.x; index index.php index.html index.htm; server_name example.com www.example.com;# Compressing resource files will save bandwidth and so improve loading speed especially for users# with slower internet connections. TYPO3 can compress the .js and .css files for you.# *) Set $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = 9 for the Backend# *) Set $GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel'] = 9 together with the TypoScript properties# config.compressJs and config.compressCss for GZIP compression of Frontend JS and CSS files.location ~ \.js\.gzip$ { add_header Content-Encoding gzip; gzip off; types { text/javascript gzip; }}location ~ \.css\.gzip$ { add_header Content-Encoding gzip; gzip off; types { text/css gzip; }}# TYPO3 - Rule for versioned static files, configured through:# - $GLOBALS['TYPO3_CONF_VARS']['BE']['versionNumberInFilename']# - $GLOBALS['TYPO3_CONF_VARS']['FE']['versionNumberInFilename']if (!-e $request_filename) { rewrite ^/(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ /$1.$3 last;}# TYPO3 - Block access to composer fileslocation ~* composer\.(?:json|lock) { deny all;}# TYPO3 - Block access to flexform fileslocation ~* flexform[^.]*\.xml { deny all;}# TYPO3 - Block access to language fileslocation ~* locallang[^.]*\.(?:xml|xlf)$ { deny all;}# TYPO3 - Block access to static typoscript fileslocation ~* ext_conf_template\.txt|ext_typoscript_constants\.txt|ext_typoscript_setup\.txt { deny all;}# TYPO3 - Block access to miscellaneous protected fileslocation ~* /.*\.(?:bak|co?nf|cfg|ya?ml|ts|typoscript|tsconfig|dist|fla|in[ci]|log|sh|sql|sqlite)$ { deny all;}# TYPO3 - Block access to recycler and temporary directorieslocation ~ _(?:recycler|temp)_/ { deny all;}# TYPO3 - Block access to configuration files stored in fileadminlocation ~ fileadmin/(?:templates)/.*\.(?:txt|ts|typoscript)$ { deny all;}# TYPO3 - Block access to libraries, source and temporary compiled datalocation ~ ^(?:vendor|typo3_src|typo3temp/var) { deny all;}# TYPO3 - Block access to protected extension directorieslocation ~ (?:typo3conf/ext|typo3/sysext|typo3/ext)/[^/]+/(?:Configuration|Resources/Private|Tests?|Documentation|docs?)/ { deny all;}location / { try_files $uri $uri/ /index.php$is_args$args;}# TYPO3 Backend URLslocation = /typo3 { rewrite ^ /typo3/;}location /typo3/ { try_files $uri /typo3/index.php$is_args$args;}location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_buffer_size 32k; fastcgi_buffers 8 16k; fastcgi_connect_timeout 240s; fastcgi_read_timeout 240s; fastcgi_send_timeout 240s; fastcgi_pass unix:/run/php/php8.1-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; }}
Once the server block has been created you can run the following commands to disable the default server block and activate the one above.
sudo unlink /etc/nginx/sites-enabled/defaultsudo ln -s /etc/nginx/sites-available/typo3.conf /etc/nginx/sites-enabled/sudo nginx -tsudo systemctl restart nginx
Now install Typo3
Regardless of whether you chose to use Apache or NGinx you can install Typo3 on your server by running the following commands.
sudo mkdir /var/www/[domain]cd /var/www/[domain]sudo wget --content-disposition https://get.typo3.org/11sudo tar xzf typo3_src-11.5.x.tar.gzcd typo3_src-11.5.xsudo touch FIRST_INSTALLsudo chown -R www-data:www-data /var/www/[domain]/typo3_src-11.5.xsudo chmod -R 755 /var/www/[domain]/typo3_src-11.5.x
Remember that the [domain] above needs to be the same one you would use in the document root of your virtual host or server block above. You will need to substitute the x in the commands above with the actual number in the compressed file you download.
Secure your Typo3 install with an SSL / TLS certificate
First install Certbot by running the following commands
sudo apt-get install snapd sudo snap install core; sudo snap refresh coresudo snap install --classic certbotsudo ln -s /snap/bin/certbot /usr/bin/certbot
If you installed Apache run sudo certbot -d [domain] -d www.[domain] --apache to get your certificate and, if you installed NGinx, run sudo certbot -d [domain] -d www.[domain] --nginx instead.
Setup Typo3
Visit [domain]/typo3/install.php in your browser and work your way through the setup guide in order to finish off creating your new Typo3 content management system.
Final thoughts
This guide, like the others, explains how to get your content management system installed on your server. However, you may want to make a number of changes to your virtual host file or server block to suit your own preferences and needs.
The hard work will obviously be in using Typo3 to set up your site the way you want it. To help you along the way Typo3 provide a few videos which can be found https://typo3.org/help/documentation/video-tutorials and documentation for their system can be found https://docs.typo3.org/.
