Setting Up Nginx and TYPO3 CMS on Debian 12¶
This guide will help you set up nginx and TYPO3 CMS on your headless Debian 12 machine.
Prerequisites¶
- SSH access to your Debian 12 machine
- Root or sudo privileges
Step 1: Install Nginx Web Server¶
SSH into your remote machine:
Update your system:
Install Nginx:
Start and enable Nginx:
Check if Nginx is running:
Configure firewall to allow HTTP and HTTPS traffic:
Step 2: Install MariaDB (MySQL)¶
Install MariaDB:
Start and enable MariaDB:
Secure your MariaDB installation:
- Press Enter for the current password (there is none by default) - Type 'Y' to set a root password, and enter a strong password - Answer 'Y' to all remaining questionsCreate a database and user for TYPO3:
Once in the MySQL prompt, run:
CREATE DATABASE typo3db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'typo3user'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON typo3db.* TO 'typo3user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 3: Install PHP and Required Extensions¶
TYPO3 requires PHP 8.1 or higher. Let's install PHP 8.2:
sudo apt install php8.2-fpm php8.2-cli php8.2-common php8.2-mysql php8.2-zip php8.2-gd php8.2-mbstring php8.2-curl php8.2-xml php8.2-bcmath php8.2-intl php8.2-soap php8.2-imap php8.2-opcache php8.2-apcu -y
Check PHP version:
Configure PHP-FPM:
Make the following adjustments:
upload_max_filesize = 50M
post_max_size = 50M
memory_limit = 256M
max_execution_time = 240
date.timezone = Your/Timezone
Restart PHP-FPM:
Step 4: Install Composer¶
Install Composer (PHP dependency manager):
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Verify the installation:
Step 5: Download and Set Up TYPO3¶
Create a web directory for your TYPO3 installation:
sudo mkdir -p /var/www/typo3
sudo chown -R www-data:www-data /var/www/typo3
sudo chmod -R 775 /var/www/typo3
Add your user to the www-data group to easily manage files:
Log out and log back in for the group changes to take effect:
Navigate to the web directory:
Download TYPO3 using Composer:
Set proper permissions for TYPO3:
sudo chown -R www-data:www-data /var/www/typo3
sudo find /var/www/typo3 -type d -exec chmod 755 {} \;
sudo find /var/www/typo3 -type f -exec chmod 644 {} \;
sudo mkdir -p /var/www/typo3/var/{assets,indexes,lock,log,transient}
sudo chmod -R 777 /var/www/typo3/var
Step 6: Configure Nginx for TYPO3¶
Create a server block for TYPO3:
Add the following configuration:
server {
listen 80;
server_name localhost; # Or your IP address or domain
root /var/www/typo3/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param TYPO3_CONTEXT Development;
}
# Static files
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires max;
log_not_found off;
}
# Deny access to sensitive files
location ~ /\.ht {
deny all;
}
location ~ \.git {
deny all;
}
client_max_body_size 50m;
}
Enable the site:
sudo ln -s /etc/nginx/sites-available/typo3 /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default # Remove default site
sudo nginx -t # Test the configuration
sudo systemctl reload nginx
Step 7: Complete TYPO3 Installation¶
Access the TYPO3 installation wizard by navigating to your server's IP address in a web browser:
Follow the TYPO3 installation wizard: 1. Select language 2. Check system environment (fix any issues) 3. Database connection: - Username: typo3user - Password: your_strong_password - Host: localhost - Database: typo3db 4. Create an admin user 5. Select a site setup
Step 8: Development Access¶
For remote development, you can access your web server through SSH tunneling:
Then access your TYPO3 installation at:
Alternatively, you can allow external access by modifying your firewall settings:
Step 9: Install Git for Version Control¶
Configure Git:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Additional Tips¶
-
Performance Monitoring:
-
Regular Backups: Create a backup script for your TYPO3 site:
Add this content:
#!/bin/bash
BACKUP_DIR="/opt/backups/typo3"
MYSQL_USER="typo3user"
MYSQL_PASS="your_strong_password"
MYSQL_DB="typo3db"
DATE=$(date +%Y-%m-%d_%H-%M-%S)
# Create backup directory if it doesn't exist
mkdir -p $BACKUP_DIR
# Backup the database
mysqldump -u $MYSQL_USER -p$MYSQL_PASS $MYSQL_DB > $BACKUP_DIR/typo3db_$DATE.sql
# Backup the files
tar -czf $BACKUP_DIR/typo3_files_$DATE.tar.gz -C /var/www/typo3 .
# Remove backups older than 7 days
find $BACKUP_DIR -type f -name "*.sql" -mtime +7 -delete
find $BACKUP_DIR -type f -name "*.tar.gz" -mtime +7 -delete
Make it executable:
Add it to crontab for automatic daily backups:
Add this line: