Installer Typo3

Installation d'un environnement Typo 3 en local

Pour la mise en place dans mon environnement Linux, j'ai opté pour un environnement docker. Ceci permettra, plus tard en fonction de ce qui sera nécessaire pour Typo3, de facilement monter en version de PHP. La création de cet environnement est assez simple du coup car énormément de points sont déjà paramétrés dans les containers utilisés.

Création du container MariaDB

docker run -d --name typo3-db \
    -e MYSQL_ROOT_PASSWORD=xxxxx \
    -e MYSQL_USER=xxxxx \
    -e MYSQL_PASSWORD=xxxxx \
    -e MYSQL_DATABASE=typo3 \
    -p 3306:3306 \
    mariadb:latest \
    --character-set-server=utf8mb4 \
    --collation-server=utf8mb4_unicode_ci

Dockerfile pour la création du container Apache / PHP

# Docker image for TYPO3 CMS
# Copyright (C) 2016-2020  Martin Helmich <martin@helmich.me>
#                          and contributors <https://github.com/martin-helmich/docker-typo3/graphs/contributors>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

FROM php:7.4-apache-buster
LABEL maintainer="Emmanuel Guyot - Origine : Martin Helmich <typo3@martin-helmich.de>"

# Install TYPO3
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        wget \
# Configure PHP
        libxml2-dev libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev \
        libpq-dev \
        libzip-dev \
        zlib1g-dev \
# Install required 3rd party tools
        graphicsmagick \
        cron \
        vim \
        locales && \
# Configure extensions
    docker-php-ext-configure gd --with-libdir=/usr/include/ --with-jpeg --with-freetype && \
    docker-php-ext-install -j$(nproc) mysqli soap gd zip opcache intl pgsql pdo_pgsql && \
    echo 'always_populate_raw_post_data = -1\nmax_execution_time = 240\nmax_input_vars = 1500\nupload_max_filesize = 32M\npost_max_size = 32M' > /usr/local/etc/php/conf.d/typo3.ini && \
# Configure Apache as needed
    a2enmod rewrite && \
    a2enmod headers && \
    a2enmod ssl && \
    sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen && \
    locale-gen && \
    apt-get clean && \
    apt-get -y purge \
        libxml2-dev libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev \
        libzip-dev \
        zlib1g-dev && \
    rm -rf /var/lib/apt/lists/* /usr/src/* && \
    sed "s/memory_limit = 128M/memory_limit = 256M/" /usr/local/etc/php/php.ini-development > /usr/local/etc/php/php.ini 

COPY crontab /var/spool/cron/crontabs/www-data

ENV LANG fr_FR.UTF-8  
ENV LANGUAGE fr_FR:en  
ENV LC_ALL fr_FR.UTF-8     

# Config serveur web Perso
RUN { \
        echo '# vhost https'; \
        echo '<VirtualHost *:443>'; \
        echo '\tDocumentRoot /var/www/html'; \
        echo '\tServerName  www.emmguyot.com'; \
        echo ''; \
        echo '\tServerSignature Off'; \
        echo '\tErrorLog ${APACHE_LOG_DIR}/error_emmguyot.log      '; \
        echo '\tLogLevel info      '; \
        echo '\tLogLevel rewrite:trace4      '; \
        echo '\tCustomLog ${APACHE_LOG_DIR}/access_emmguyot.log combined      '; \
        echo ''; \
        echo '\tSSLEngine on'; \
        echo '\tSSLCertificateFile /etc/ssl/certs/emmguyot.crt'; \
        echo '\tSSLCertificateKeyFile /etc/ssl/private/emmguyot.key'; \
        echo '</VirtualHost>'; \
        echo '<VirtualHost *:443>'; \
        echo '\tDocumentRoot /var/www/html'; \
        echo '\tServerName  libertylook.emmguyot.com'; \
        echo ''; \
        echo '\tServerSignature Off'; \
        echo '\tErrorLog ${APACHE_LOG_DIR}/error_libertylook.log      '; \
        echo '\tLogLevel info      '; \
        echo '\tLogLevel rewrite:trace4      '; \
        echo '\tCustomLog ${APACHE_LOG_DIR}/access_libertylook.log combined      '; \
        echo ''; \
        echo '\tSSLEngine on'; \
        echo '\tSSLCertificateFile /etc/ssl/certs/libertylook.crt'; \
        echo '\tSSLCertificateKeyFile /etc/ssl/private/libertylook.key'; \
        echo '</VirtualHost>'; \
        echo '<VirtualHost *:443>'; \
        echo '\tDocumentRoot /var/www/html'; \
        echo '\tServerName  localhost'; \
        echo ''; \
        echo '\tServerSignature Off'; \
        echo '\tErrorLog ${APACHE_LOG_DIR}/error_localhost.log      '; \
        echo '\tLogLevel info      '; \
        echo '\tLogLevel rewrite:trace4      '; \
        echo '\tCustomLog ${APACHE_LOG_DIR}/access_localhost.log combined      '; \
        echo ''; \
        echo '\tSSLEngine on'; \
        echo '\tSSLCertificateFile /etc/ssl/certs/localhost.crt'; \
        echo '\tSSLCertificateKeyFile /etc/ssl/private/localhost.key'; \
        echo '</VirtualHost>'; \
	} | tee "$APACHE_CONFDIR/conf-available/emmguyot.conf" \
	&& a2enconf emmguyot
COPY emmguyot.key /etc/ssl/private/emmguyot.key
COPY emmguyot.crt /etc/ssl/certs/emmguyot.crt
COPY localhost.key /etc/ssl/private/localhost.key
COPY localhost.crt /etc/ssl/certs/localhost.crt
COPY libertylook.key /etc/ssl/private/libertylook.key
COPY libertylook.crt /etc/ssl/certs/libertylook.crt
EXPOSE 443

RUN cd /var/www && \
    wget --no-show-progress -O download.tar.gz https://get.typo3.org/10.4.15 && \
    echo "a29c39046b5d54e872710cd6cb1c0b36c7ef8ed529ec78eb46e28d2fd1af1481 download.tar.gz" > download.tar.gz.sum && \
    sha256sum -c download.tar.gz.sum && \
    tar -xzf download.tar.gz && \
    rm download.* && \
    cd /var/www/html && \
    rm typo3_src && \
    ln -s ../typo3_src-* typo3_src && \
    ln -s typo3_src/index.php && \
    ln -s typo3_src/typo3 && \
    cp ../typo3_src-*/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess .htaccess && \
    mkdir typo3temp && \
    mkdir typo3conf && \
    mkdir fileadmin && \
    mkdir uploads && \
    touch FIRST_INSTALL && \
    chown www-data. . && \
    chown -R www-data. ../typo3_src-* && \
    chmod 777 /var/www && \
    chmod 777 /var/www/html && \
    mkdir /var/log/typo3 && \
    chown www-data /var/log/typo3 && \
    addgroup --gid 1000 emmguyot && \
    adduser www-data emmguyot && \
    mkdir /var/log/cron && \
    chown www-data /var/spool/cron/crontabs/www-data && \
    chgrp crontab /var/spool/cron/crontabs/www-data && \
    chmod 600 /var/spool/cron/crontabs/www-data 

CMD cron && "apache2-foreground"

# Configure volumes
VOLUME /var/www/html
Un container Apache / PHP façonné à partir des containers Typo3 préparés par Martin Helmich

Lancement du container Apache / PHP

# Création de l'image à partir du Dockerfile ci-dessus : A ne faire que la première fois
docker build -t lamp-typo3:10 .

# Lancement du container
docker run -d --name typo3-web-10 \
     --link typo3-db:db \
     -p 80:80 \
     -p 443:443 \
     -v /home/emmguyot/Projets/DockerTypo3/Root:/var/www/html \
     lamp-typo3:10

Le site est opérationnel

Avec ces éléments, couplées à une restauration de ma base et des fichiers de mon hébergeur, mes sites sont opérationnels via les noms de domaine localxxx.

J'ai évidemment dû modifier mon fichier /etc/hosts pour y déclarer ces noms afin qu'ils pointent sur mon local.

Je dispose donc à présent d'un site CMS en local, avec aucune contrainte technique liée à l'hébergement, des temps de réponse excellents. Et surtout, je peux mettre à jour régulièrement et facilement ce système. Je suis ainsi passé progressivement de la version 8.7 à la version 9.5, puis à la version 10.4.

Un sentiment de liberté m'habite alors... ça fait plaisir!