Last active
July 23, 2023 16:17
-
-
Save oliverthiele/999b29a675a0c46687b627dc259bf382 to your computer and use it in GitHub Desktop.
Script for installing TYPO3 with v12.4 (or v11.5) LTS on a clean Ubuntu 22.04 root server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### Before executing this script make a system update: | |
# $> apt update; apt --assume-yes dist-upgrade; apt --assume-yes autoremove; | |
# $> reboot | |
# VirtualBox does not work with ipv6, so you have to disable it before running this script: | |
# $> sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 | |
# $> sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 | |
############# Edit begin: ################## | |
setVariables() { | |
# Paths | |
typo3Version='^12.4' | |
echo "TYPO3 Version ${typo3Version}" | |
wwwRoot='/var/www/' | |
composerDirectory="${wwwRoot}typo3/" | |
typo3PublicDirectory="${composerDirectory}public/" | |
if [ "${typo3Version}" = '^12.4' ]; then | |
pathSettings="${composerDirectory}config/system/"; | |
pathAdditionalSettings="${pathSettings}additional.php"; | |
typo3CliName='typo3'; | |
else | |
pathSettings="${composerDirectory}public/typo3conf/"; | |
pathAdditionalSettings='${pathSettings}AdditionalConfiguration.php'; | |
typo3CliName='typo3cms'; | |
fi | |
CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-*/!@#$%_&*[]()" | |
# Passwort generieren | |
systemPass=$(for i in {1..12}; do echo -n "${CHARS:RANDOM%${#CHARS}:1}"; done; echo) | |
echo "System Password: ${systemPass}" | |
} | |
############# Edit end: ################## | |
getUbuntuVersionAndSetDefaultVariables() { | |
ubuntuVersion=$(lsb_release -rs) | |
echo "Ubuntu: ${ubuntuVersion}" | |
if [ "${ubuntuVersion}" = '22.04' ]; then | |
# todo Install php 7.4 for TYPO3 10 | |
phpVersion='8.1' | |
fi | |
if [ "${ubuntuVersion}" = '20.04' ]; then | |
phpVersion='7.4' | |
fi | |
if [ "${ubuntuVersion}" = '18.04' ]; then | |
phpVersion='7.2' | |
fi | |
pathToPhpIni="/etc/php/${phpVersion}/fpm/php.ini" | |
echo "PHP Version: ${phpVersion}" | |
echo "Path to php.ini: ${pathToPhpIni}" | |
echo "---" | |
} | |
#add_a_user() { | |
# USER=$1 | |
# PASSWORD=$2 | |
# shift | |
# shift | |
# # Having shifted twice, the rest is now comments ... | |
# COMMENTS=$@ | |
# echo "Adding user $USER ..." | |
# echo useradd -c "$COMMENTS" $USER | |
# echo passwd $USER $PASSWORD | |
# echo "Added user $USER ($COMMENTS) with pass $PASSWORD" | |
#} | |
confirmation() { | |
read -rp "Install TYPO3 in '${typo3PublicDirectory}' with PHP ${phpVersion}. Is this correct [y/N] " response | |
case "$response" in | |
[yY][eE][sS] | [yY]) | |
echo "Start the installation" | |
;; | |
*) | |
echo "Installation cancelled by user. Exiting..." | |
exit | |
;; | |
esac | |
} | |
installSoftware() { | |
echo "INFO Install System (nginx, php ${phpVersion}, MySQL, Redis, …)" | |
apt --assume-yes install nginx-full apache2-utils \ | |
php${phpVersion}-gd php${phpVersion}-mysql \ | |
php-soap php-apcu php-redis \ | |
php${phpVersion}-{fpm,cli,common,curl,zip,gd,mysql,xml,mbstring,intl,yaml,opcache} \ | |
redis-server mariadb-server \ | |
graphicsmagick ghostscript git tig zip unzip catdoc argon2 file zsh zsh-syntax-highlighting \ | |
dos2unix webp \ | |
update-notifier-common | |
read -rp "Do you want to install monit? [y/N] " response | |
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
## Install MTA, if monit is installed | |
apt --assume-yes install monit | |
fi | |
if [ "${ubuntuVersion}" = '20.04' ]; then | |
echo "Install Lets Encrypt certbot" | |
apt --assume-yes install certbot python3-certbot-nginx | |
fi | |
if [ "${ubuntuVersion}" = '22.04' ]; then | |
echo "Install Lets Encrypt certbot" | |
apt --assume-yes install certbot python3-certbot-nginx | |
fi | |
} | |
# @todo Prepare Let's Encrypt Ubuntu 18 | |
#apt install software-properties-common | |
#add-apt-repository universe | |
#add-apt-repository ppa:certbot/certbot | |
#apt update | |
#apt install certbot | |
#apt install python-certbot-nginx | |
# } | |
############# Create DB ################### | |
createDatabase() { | |
encryptionKey="$(openssl rand -hex 48)" | |
if [ ! -f .env.temp ]; then | |
echo "INFO Create MySQL DB" | |
dbUser='typo3' | |
# create random password | |
dbPass="$(openssl rand -base64 12)" | |
dbDatabase=${dbUser}_1 | |
dbHost='localhost' | |
mysql -e "CREATE DATABASE ${dbDatabase} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" | |
mysql -e "CREATE USER ${dbUser}@localhost IDENTIFIED BY '${dbPass}';" | |
mysql -e "GRANT ALL PRIVILEGES ON ${dbDatabase}.* TO '${dbUser}'@'localhost';" | |
mysql -e "FLUSH PRIVILEGES;" | |
cat >.env.temp <<EOL | |
DB_DB="${dbDatabase}" | |
DB_USER="${dbUser}" | |
DB_PASS="${dbPass}" | |
DB_HOST="${dbHost}" | |
ENCRYPTION_KEY="${encryptionKey}" | |
EOL | |
fi | |
} | |
cleanTargetDirectoryAndDatabase() { | |
if [ -d "${composerDirectory}" ]; then | |
read -rp "The directory ${composerDirectory} already exists. Are you sure you want to delete it? [y/N] " response | |
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
rm -rf ${composerDirectory} | |
echo "Directory ${composerDirectory} removed" | |
mysql -e "DROP DATABASE ${dbDatabase};" | |
echo "Database ${dbDatabase} dropped" | |
else | |
echo "Operation cancelled" | |
fi | |
fi | |
} | |
######################### | |
# Optimize php.ini | |
# ####################### | |
optimizePhpSettings() { | |
echo "Optimize PHP ${phpVersion} Settings in ${pathToPhpIni}" | |
# sed -i 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=300/g' /etc/php-7.0.d/10-opcache.ini | |
sed -i 's/max_execution_time = 30/max_execution_time = 240/' ${pathToPhpIni} | |
sed -i 's/max_input_time = 60/max_input_time = 120/' ${pathToPhpIni} | |
# PHP 7.2 | |
sed -i 's/; max_input_vars = 1000/max_input_vars = 10000/' ${pathToPhpIni} | |
# PHP 7.4 | |
sed -i 's/;max_input_vars = 1000/max_input_vars = 10000/' ${pathToPhpIni} | |
sed -i 's/memory_limit = 128M/memory_limit = 196M/' ${pathToPhpIni} | |
sed -i 's/post_max_size = 8M/post_max_size = 200M/' ${pathToPhpIni} | |
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 200M/' ${pathToPhpIni} | |
sed -i 's/max_file_uploads = 20/max_file_uploads = 200/' ${pathToPhpIni} | |
service php${phpVersion}-fpm restart | |
} | |
################################################## Install composer | |
installComposer() { | |
echo "Install composer from https://getcomposer.org" | |
EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)" | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" | |
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then | |
echo >&2 'ERROR: Invalid installer checksum' | |
rm composer-setup.php | |
exit 1 | |
fi | |
php composer-setup.php --quiet | |
RESULT=$? | |
rm composer-setup.php | |
if [ $RESULT -eq 0 ]; then | |
echo 'Composer installation was successful' | |
else | |
echo 'Composer Setup Result:' $RESULT | |
fi | |
# Make composer globally availible | |
mv composer.phar /usr/local/bin/composer | |
} | |
################################################## Install Yarn | |
installYarn() { | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null | |
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
apt update | |
apt --assume-yes install yarn | |
} | |
################################################## Install TYPO3 | |
installTypo3() { | |
echo "INFO Install TYPO3" | |
chown www-data:www-data /var/www/ -R | |
cd ${wwwRoot} || exit | |
sudo -i -H -u www-data composer create-project "typo3/cms-base-distribution:${typo3Version}" /var/www/typo3/ | |
# Add Extension directory for your extensions, sitepackages, ... | |
cd ${composerDirectory} || exit | |
mkdir packages | |
sudo -i -H -u www-data composer --file="${composerDirectory}composer.json" config repositories.local '{"type": "path", "url": "./packages/*"}' | |
sudo -u www-data sh -c "cd ${composerDirectory} && composer require vlucas/phpdotenv" | |
sudo -u www-data sh -c "composer require typo3/cms-adminpanel ${typo3Version} typo3/cms-lowlevel ${typo3Version} \ | |
typo3/cms-redirects ${typo3Version} typo3/cms-recycler ${typo3Version} typo3/cms-workspaces ${typo3Version} \ | |
typo3/cms-linkvalidator ${typo3Version} typo3/cms-opendocs ${typo3Version} typo3/cms-scheduler ${typo3Version}" | |
# todo Check versions for TYPO3 v10, v11 + v12 | |
sudo -u www-data sh -c "composer require helhum/typo3-console" | |
find -type d -print0 | xargs -0 chmod 2770 && find -type f ! -perm /u=x,g=x,o=x -print0 | xargs -0 chmod 0660 | |
chown www-data: /var/www/ -R | |
# todo remove | |
# dbDatabase="typo3_1" | |
# dbUser="typo3" | |
# dbPass="E7FkEi9bqdc7l2At" | |
# dbHost="localhost" | |
# systemPass="testA123#" | |
php ${composerDirectory}vendor/bin/${typo3CliName} install:setup \ | |
--no-interaction \ | |
--database-user-name=${dbUser} \ | |
--database-user-password=${dbPass} \ | |
--database-host-name=${dbHost} \ | |
--database-port=3306 \ | |
--database-name=${dbDatabase} \ | |
--use-existing-database \ | |
--admin-user-name=TYPO3-Admin \ | |
--admin-password=${systemPass} \ | |
--site-setup-type=site | |
} | |
configureNginx() { | |
################################################## Enable Website in nginx | |
echo "INFO Configure website in nginx" | |
cat >/etc/nginx/snippets/browserCaching.nginx <<EOL | |
# CSS / JS | |
location ~* ^/typo3temp/Assets/.*\.js { | |
expires max; | |
add_header Vary Accept-Encoding; | |
add_header Pragma public; | |
add_header Cache-Control "public"; | |
gzip on; | |
} | |
location ~* ^/typo3conf/ext/.*\.(js|css)$ { | |
expires max; | |
add_header Pragma public; | |
add_header Cache-Control "public"; | |
} | |
# Media | |
location ~* \.(?:ico|gif|jpe?g|png|ogg|bmp|png|webp|mp4|webm|h264|h265|svg|woff|woff2|ttf|eot)$ { | |
if (\$http_origin ~ "^(https://code.jquery.com|http://example.com)$") { | |
add_header Access-Control-Allow-Headers Content-Type; | |
add_header Access-Control-Max-Age 86400; | |
add_header Access-Control-Allow-Origin \$http_origin; | |
} | |
expires 30d; | |
add_header Pragma public; | |
add_header Cache-Control "public"; | |
# # etag is supported on nginx >= 1.3.3 | |
# # etag on; | |
# # https://www.maxcdn.com/blog/accept-encoding-its-vary-important/ | |
# add_header Vary Accept-Encoding; | |
} | |
EOL | |
cat >/etc/nginx/snippets/compression.nginx <<EOL | |
# Compression | |
gzip on; | |
gzip_http_version 1.1; | |
gzip_min_length 1000; | |
gzip_buffers 16 8k; | |
gzip_disable "MSIE [1-6] \."; | |
gzip_types | |
# text/html # text/html is always compressed by HttpGzipModule | |
text/css | |
text/xml | |
application/x-javascript | |
application/atom+xml | |
text/mathml | |
text/plain | |
text/vnd.sun.j2me.app-descriptor | |
text/vnd.wap.wml | |
text/x-component | |
text/javascript | |
application/javascript | |
application/json | |
application/xml | |
application/rss+xml | |
font/truetype | |
font/opentype | |
application/vnd.ms-fontobject | |
image/svg+xml; | |
gzip_vary on; | |
EOL | |
if [ -f "/etc/nginx/sites-available/default" ]; then | |
rm /etc/nginx/sites-available/default | |
fi | |
if [ -L "/etc/nginx/sites-enabled/default" ]; then | |
rm /etc/nginx/sites-enabled/default | |
fi | |
#cat >/etc/nginx/sites-available/default <<EOL | |
#server { | |
# listen 80 default_server; | |
# listen [::]:80 default_server; | |
# location / { | |
# deny all; | |
# } | |
#} | |
#EOL | |
cat >/etc/nginx/snippets/typo3v11Up.nginx <<EOL | |
# TYPO3 11.5 Backend URLs | |
location = /typo3 { | |
rewrite ^ /typo3/; | |
} | |
# Allow access to all public resources | |
location ~ ^/typo3/(.*/)?Resources/Public/ { | |
allow all; | |
break; | |
} | |
location /typo3/ { | |
# include snippets/BasicAuth.nginx; | |
try_files \$uri /typo3/index.php\$is_args\$args; | |
} | |
EOL | |
cat >/etc/nginx/sites-available/typo3.nginx <<EOL | |
server { | |
listen 80; | |
listen [::]:80; | |
charset utf-8; | |
root ${typo3PublicDirectory}; | |
# Add index.php to the list if you are using PHP | |
index index.html index.php; | |
server_name _; | |
port_in_redirect off; | |
server_name_in_redirect off; | |
client_max_body_size 64M; | |
client_header_buffer_size 32k; | |
large_client_header_buffers 16 512k; | |
# todo check function | |
# include snippets/browserCaching.nginx; | |
# include snippets/compression.nginx; | |
include snippets/typo3v11Up.nginx; | |
# Installtool | |
# Path for TYPO3 7.6: /typo3/sysext/install/Start/Install.php | |
rewrite ^/typo3/install/\$ /typo3/install.php permanent; | |
# versionNumberInFilename | |
rewrite "^(.*)\.(\d{10})\.(css|js)$" \$1.\$3 last; | |
location / { | |
# auth_basic "Restricted"; | |
# auth_basic_user_file /var/www/typo3/.htpasswd; | |
# any / all | |
# satisfy any; | |
# allow 127.0.0.1; | |
# allow 127.0.1.1; | |
try_files \$uri \$uri/ /index.php?\$args; | |
} | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
expires max; | |
break; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
# Restrict access to deleted files in Recycler directories | |
location ~ ^/fileadmin/(.*/)?_recycler_/ { | |
deny all; | |
access_log off; | |
log_not_found off; | |
break; | |
} | |
# For CSS with compression | |
location ~* "\.css(\.|\.\d{10}\.)gzip$" { | |
rewrite "^(.+css)\.(\d+\.)gzip$" /\$1.gzip; | |
add_header Content-Encoding gzip; | |
add_header Vary Accept-Encoding; | |
add_header Access-Control-Allow-Origin *; | |
gzip off; | |
types { text/css gzip; } | |
expires max; | |
log_not_found off; | |
} | |
# For JavaScript with compression | |
location ~* "\.js(\.|\.\d{10}\.)gzip$" { | |
rewrite "^(.+js)\.(\d{10}\.)gzip$" /\$1.gzip; | |
add_header Content-Encoding gzip; | |
add_header Vary Accept-Encoding; | |
gzip off; | |
default_type application/javascript; | |
expires max; | |
log_not_found off; | |
} | |
# pass PHP scripts to FastCGI server | |
location ~ \.php$ { | |
# regex to split \$uri to \$fastcgi_script_name and \$fastcgi_path | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
# Check that the PHP script exists before passing it | |
try_files \$fastcgi_script_name =404; | |
# Bypass the fact that try_files resets \$fastcgi_path_info | |
# see: http://trac.nginx.org/nginx/ticket/321 | |
set \$path_info \$fastcgi_path_info; | |
fastcgi_param PATH_INFO \$path_info; | |
fastcgi_index index.php; | |
include fastcgi.conf; | |
fastcgi_param TYPO3_CONTEXT Development; | |
#fastcgi_param TYPO3_CONTEXT Production/Staging; | |
#fastcgi_param TYPO3_CONTEXT Production; | |
fastcgi_pass unix:/var/run/php/php${phpVersion}-fpm.sock; | |
} | |
# deny access to .htaccess files, if Apache's document root | |
# concurs with nginx's one | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
EOL | |
ln -sfT /etc/nginx/sites-available/typo3.nginx /etc/nginx/sites-enabled/typo3.nginx | |
service nginx restart | |
} | |
activateTypo3() { | |
################################################## Enable TYPO3 installation | |
echo "Enable TYPO3 installation" | |
cd ${typo3PublicDirectory} || exit | |
touch FIRST_INSTALL | |
cat >/var/www/typo3/.env.example <<EOL | |
PROJECT_NAME="" | |
# Domain without scheme (used for trustedHostPattern) | |
DOMAIN="" | |
DB_DB="" | |
DB_USER="" | |
DB_PASS="" | |
DB_HOST="localhost" | |
ENCRYPTION_KEY="" | |
TYPO3_INSTALL_TOOL="" | |
SMTP_SERVER="" | |
SMTP_USER="" | |
SMTP_PASSWORD="" | |
# Bool: 0 / 1 | |
SMTP_TRANSPORT_ENCRYPT=0 | |
DEFAULT_MAIL_FROM_ADDRESS="" | |
DEFAULT_MAIL_FROM_NAME="" | |
EOL | |
cp -ap /root/.env.temp /var/www/typo3/.env.development | |
mkdir -p ${pathSettings} | |
cat > ${pathAdditionalSettings} <<EOL | |
<?php | |
declare(strict_types=1); | |
# Old: | |
# defined('TYPO3') or die(); | |
defined('TYPO3') or die(); | |
use TYPO3\CMS\Core\Core\Environment; | |
\$context = Environment::getContext(); | |
/** | |
* Default for production systems | |
*/ | |
\$GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] = ''; | |
\$GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] = ''; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = ''; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'] = '0'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'] = '4096'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '2770'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660'; | |
/** | |
* Development environment | |
* TYPO3_CONTEXT Development | |
*/ | |
if (\$context->isDevelopment()) { | |
\$dotenv = Dotenv\Dotenv::createImmutable('/var/www/typo3/', '.env.development'); | |
\$dotenv->load(); | |
\$GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] = '1'; | |
\$GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] = '1'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = '*'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'] = '1'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'] = '12290'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] = '[Dev] TYPO3 CMS'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*'; | |
} | |
/** | |
* Staging environment | |
* TYPO3_CONTEXT Production/Staging | |
*/ | |
if (\$context->isProduction() && \$context->__toString() | |
=== 'Production/Staging') { | |
\$dotenv = Dotenv\Dotenv::createImmutable('/var/www/typo3/', '.env.staging'); | |
\$dotenv->load(); | |
\$GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] = ''; | |
\$GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] = ''; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = ''; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'] = '0'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'] = '4096'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] = '[Staging] TYPO3 CMS'; | |
} | |
/** | |
* Staging environment | |
* TYPO3_CONTEXT Production/Staging | |
*/ | |
if (\$context->isProduction() && \$context->__toString() === 'Production') { | |
\$dotenv = Dotenv\Dotenv::createImmutable('/var/www/typo3/', '.env'); | |
\$dotenv->load(); | |
\$GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] = ''; | |
\$GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] = ''; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = ''; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'] = '0'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'] = '4096'; | |
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] = '[Production] TYPO3 CMS'; | |
} | |
\$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] = \$_ENV['DB_DB']; | |
\$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['user'] = \$_ENV['DB_USER']; | |
\$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['password'] = \$_ENV['DB_PASS']; | |
\$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['host'] = \$_ENV['DB_HOST']; | |
\$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_username'] = \$_ENV['SMTP_USER']; | |
\$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_password'] = \$_ENV['SMTP_PASSWORD']; | |
\$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_server'] = \$_ENV['SMTP_SERVER']; | |
\$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_encrypt'] = (bool)\$_ENV['SMTP_TRANSPORT_ENCRYPT']; | |
if (getenv('IS_DDEV_PROJECT') == 'true') { | |
\$GLOBALS['TYPO3_CONF_VARS'] = array_replace_recursive( | |
\$GLOBALS['TYPO3_CONF_VARS'], | |
[ | |
'DB' => [ | |
'Connections' => [ | |
'Default' => [ | |
'dbname' => 'db', | |
'driver' => 'mysqli', | |
'host' => 'db', | |
'password' => 'db', | |
'port' => '3306', | |
'user' => 'db', | |
'charset' => 'utf8mb4', | |
'tableoptions' => [ | |
'charset' => 'utf8mb4', | |
'collate' => 'utf8mb4_unicode_ci', | |
], | |
], | |
], | |
], | |
// This GFX configuration allows processing by installed ImageMagick 6 | |
'GFX' => [ | |
'processor' => 'ImageMagick', | |
'processor_path' => '/usr/bin/', | |
'processor_path_lzw' => '/usr/bin/', | |
], | |
// This mail configuration sends all emails to mailhog | |
'MAIL' => [ | |
'transport' => 'smtp', | |
'transport_smtp_encrypt' => false, | |
'transport_smtp_server' => 'localhost:1025', | |
], | |
'SYS' => [ | |
'trustedHostsPattern' => '.*.*', | |
'devIPmask' => '*', | |
'displayErrors' => 1, | |
], | |
] | |
); | |
} | |
if (\$_ENV['TYPO3_INSTALL_TOOL'] === '') { | |
echo 'Error: No install tool password given.'; | |
die(); | |
} | |
EOL | |
} | |
################################################## Edit user www-data / add user typo3 | |
configureWwwUser() { | |
echo "www-data:${systemPass}" | chpasswd | |
if [ ! -d "/var/www/.ssh/" ]; then | |
mkdir /var/www/.ssh/ | |
cp -ap /root/.ssh/authorized_keys /var/www/.ssh/authorized_keys | |
fi | |
} | |
################################################## Change all permissions | |
setPermissions() { | |
cd ${composerDirectory} || exit | |
echo "Change permissions" | |
find -type d -print0 | xargs -0 chmod 2770 && find -type f ! -perm /u=x,g=x,o=x -print0 | xargs -0 chmod 0660 | |
chown www-data: /var/www/ -R | |
# Permissions for special files | |
chown -h www-data: /var/www/.ssh/authorized_keys | |
chmod 0700 /var/www/.ssh/ | |
chmod 0600 /var/www/.ssh/authorized_keys | |
chmod +x ${composerDirectory}vendor/typo3/cms-cli/typo3 | |
# todo file exists? | |
chmod +x ${composerDirectory}vendor/helhum/typo3-console/typo3cms | |
} | |
############## | |
finish() { | |
ipAddress=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') | |
echo "---------------------------------------" | |
echo "---- FINISH ----" | |
echo "---------------------------------------" | |
echo "" | |
echo "TYPO3 User: TYPO3-Admin" | |
echo "TYPO3 Password / SSH password (www-data): ${systemPass}" | |
echo "DB Password: ${dbPass}" | |
echo "" | |
echo "You find this passwords in the file ${composerDirectory}install-log-please-remove.log" | |
echo "Please finish the installation in your browser http://"${ipAddress} | |
cat >${composerDirectory}install-log-please-remove.log <<EOL | |
# TYPO3 Server | |
## System User (SSH): | |
User: www-data / TYPO3-Admin | |
Password: ${systemPass} | |
## Database: | |
Database: ${dbDatabase} | |
User: ${dbUser} | |
Password: ${dbPass} | |
EOL | |
} | |
activateZshShell() { | |
# Change the login shell for user root and www-data | |
chsh -s /bin/zsh root | |
if [ ! -d "/root/.oh-my-zsh" ]; then | |
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh | |
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="agnoster"/g' /root/.zshrc | |
fi | |
if ! grep -q "source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ~/.zshrc; then | |
echo "source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> /root/.zshrc | |
fi | |
chsh -s /bin/zsh www-data | |
cp -ap /root/.oh-my-zsh /root/.zshrc /var/www/ | |
echo "alias typo3cms='/var/www/typo3/vendor/bin/typo3cms'" >> /var/www/.zshrc | |
echo "alias typo3='/var/www/typo3/vendor/bin/typo3'" >> /var/www/.zshr | |
echo "cd /var/www/typo3/" >> /var/www/.zshrc | |
chown www-data /var/www/ -R | |
} | |
### | |
# Main body of script starts here | |
### | |
echo "===============================================================" | |
getUbuntuVersionAndSetDefaultVariables | |
setVariables | |
confirmation | |
cleanTargetDirectoryAndDatabase | |
installSoftware | |
installComposer | |
installYarn | |
locale-gen de_DE.UTF-8 | |
activateZshShell | |
createDatabase | |
optimizePhpSettings | |
installTypo3 | |
configureNginx | |
activateTypo3 | |
configureWwwUser | |
setPermissions | |
finish | |
echo "End of script..." |
Todo: I have add this to my.cnf:
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
Current version is WIP, but you can install now the complete TYPO3 10.4 on a Ubuntu 20.04. After installation with this script a login in the TYPO3 Backend is possible. Now the script generates .env files and the AdditionalConfiguration.php.
The current version now works with TYPO3 v12.4 LTS (can be switched to v11.5), but is still WIP. Monit e.g. can be installed but is not configured. New: it installs the zsh shell for root and www-data.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 17 should be
# typo3Version='^9.5';
without the double quotes.
Then the installation of 9.5 works.