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.
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).
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
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
active (running) in the output.active (running) i outputtet.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
apt install mariadb-server -y && systemctl enable --now mariadb && systemctl status mariadb
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;
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 {} \;
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_NAME → wpdatabaseDB_USER → wpuserDB_PASSWORD → your strong password from step 5din stærke adgangskode fra trin 5cd /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.
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
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 →