greendata.dk@web: ~/guides
$ cat ./guides/wordpress-ssl-debian-12

How to install WordPress with SSL on Debian 12

Sådan installerer du WordPress med SSL på Debian 12

Apache + PHP 8.2 + MariaDB + Let's Encrypt, from a fresh Debian 12 server to a working HTTPS site.

Apache + PHP 8.2 + MariaDB + Let's Encrypt, fra en frisk Debian 12-server til en fungerende HTTPS-side.

Prerequisites

Forudsætninger

A server running Debian 12, and root or sudo access (commands below assume root — drop the leading path if using sudo).

En server med Debian 12, samt root- eller sudo-adgang (kommandoerne herunder forudsætter root).

1. Update the system

1. Opdatér systemet

Before installing anything, make sure all packages are current.

Før du installerer noget, så sørg for at alle pakker er opdaterede.

apt-get update -y && apt-get upgrade -y

2. Install Apache

2. Installér Apache

apt install apache2 -y

Enable and start the service:

Aktivér og start servicen:

systemctl enable apache2 && systemctl start apache2

Confirm it's running:

Bekræft at den kører:

systemctl status apache2
Expect active (running) in the output.
Du bør se active (running) i outputtet.

3. Install PHP

3. Installér PHP

apt-get install php8.2 php8.2-cli php8.2-common php8.2-imap php8.2-redis php8.2-snmp php8.2-xml php8.2-mysqli php8.2-zip php8.2-mbstring php8.2-curl libapache2-mod-php unzip -y

Verify the installed version:

Verificér den installerede version:

php -v

4. Install MariaDB

4. Installér MariaDB

apt install mariadb-server -y && systemctl enable --now mariadb && systemctl status mariadb

5. Create the WordPress database

5. Opret WordPress-databasen

Log into MariaDB:

Log ind i MariaDB:

mariadb

Then run each of the following:

Kør derefter hver af følgende:

CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'YourStrongPasswordHere';
CREATE DATABASE wpdatabase;
GRANT ALL PRIVILEGES ON wpdatabase.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Save these credentials — you'll need them in step 7. The WordPress database user is separate from the WordPress admin login you'll create later.
Gem disse oplysninger — du skal bruge dem i trin 7. Database-brugeren er ikke det samme som WordPress-admin-loginet, du opretter senere.

6. Download & install WordPress

6. Download & installér WordPress

cd /var/www/html && wget https://wordpress.org/latest.zip && unzip latest.zip && rm latest.zip

Set correct ownership and permissions:

Sæt korrekt ejerskab og rettigheder:

chown -R www-data:www-data wordpress/ && cd wordpress/ && find . -type d -exec chmod 755 {} \; -o -type f -exec chmod 644 {} \;

7. Configure WordPress

7. Konfigurér WordPress

mv wp-config-sample.php wp-config.php && nano wp-config.php

Update the database settings to match step 5:

Opdatér databaseindstillingerne, så de matcher trin 5:

  • DB_NAMEwpdatabase
  • DB_USERwpuser
  • DB_PASSWORDyour strong password from step 5din stærke adgangskode fra trin 5

8. Create the Apache virtual host

8. Opret Apache virtual host

cd /etc/apache2/sites-available/ && nano wordpress.conf
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/html/wordpress

<Directory /var/www/html/wordpress>
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable the rewrite module and the new site, then check the config and reload:

Aktivér rewrite-modulet og den nye site, tjek konfigurationen, og genindlæs:

a2enmod rewrite && a2ensite wordpress.conf
apachectl -t
systemctl reload apache2 && systemctl restart apache2 && systemctl status apache2

Finish the install by visiting http://yourdomain.com in a browser.

Afslut installationen ved at gå til http://yourdomain.com i en browser.

9. Set up SSL with Let's Encrypt

9. Opsæt SSL med Let's Encrypt

apt install certbot python3-certbot-apache -y
certbot --apache -d yourdomain.com

You'll be asked for an email address (for renewal/security notices) and to accept the Terms of Service. Once done, you should see a confirmation that HTTPS is enabled.

Du bliver bedt om en e-mailadresse (til fornyelse/sikkerhedsmeddelelser) og skal acceptere vilkårene. Bagefter skal du se en bekræftelse på, at HTTPS er aktiveret.

Verify the automatic renewal timer exists:

Verificér at den automatiske fornyelses-timer findes:

systemctl list-timers

And test that renewal actually works:

Og test at fornyelsen rent faktisk virker:

certbot renew --dry-run

10. Troubleshooting

10. Fejlfinding

If something's wrong with the SSL setup, check Apache's logs:

Hvis noget er galt med SSL-opsætningen, så tjek Apaches logs:

journalctl -u apache2

Ran into an issue, or want a hand doing this? I offer remote setup and troubleshooting.

Stødt på et problem, eller vil du have hjælp til dette? Jeg tilbyder fjernopsætning og fejlfinding.

get in touch → kontakt mig →