Skip to content

Installera Caddy Web Server med PHP 8.1 på Ubuntu 22.04

Netcloud24
Cloud Infrastructure Expert
NetCloud24 Expert Guides Open the dedicated video page

Video transcript: NetCloud24 Expert Guides. Practical knowledge for a reliable cloud. Cloud and VPS expertise, security, performance, and step-by-step tutorials. Learn, deploy, and keep building with NetCloud24.

 

 

I den här guiden går vi igenom hur du installerar Caddy, en modern webbserver, med PHP 8.1 på Ubuntu 22.04. Denna installation kan vara särskilt användbar för användare av en VPS-server.

Förutsättningar

  • Ubuntu 22.04 installerat på din server.
  • Root-åtkomst eller sudo-rättigheter.
  • En aktiv internetanslutning.

Steg 1: Uppdatera systemet

Öppna terminalen och kör följande kommando för att uppdatera systempaketen:

sudo apt update && sudo apt upgrade -y

Steg 2: Installera PHP 8.1

Kör följande kommando för att installera PHP 8.1 och nödvändiga tillägg:

sudo apt install php8.1 php8.1-fpm php8.1-mysql php8.1-xml php8.1-mbstring -y

Steg 3: Installera Caddy Web Server

Lägg till Caddy repository:

echo "deb [trusted=yes] https://apt.caddyserver.com/ caddy main" | sudo tee /etc/apt/sources.list.d/caddy.list

Uppdatera paketlistan och installera Caddy:

sudo apt update
sudo apt install caddy -y

Steg 4: Konfigurera Caddy för att använda PHP

Öppna Caddy-konfigurationsfilen:

sudo nano /etc/caddy/Caddyfile

Lägg till följande konfiguration i filen:

Visual overview of Installera Caddy Web Server med PHP 8.1 på Ubuntu 22.04
Visual overview: Installera Caddy Web Server med PHP 8.1 på Ubuntu 22.04
your_domain_or_IP {
        root * /var/www/html
        php_fastcgi unix//run/php/php8.1-fpm.sock
        file_server
        encode gzip
    }

Ersätt `your_domain_or_IP` med din faktiska domän eller IP-adress.

Steg 5: Skapa en testfil för PHP

Skapa en testfil för att kontrollera att PHP fungerar:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Steg 6: Starta om Caddy-tjänsten

Kör följande kommando för att starta om Caddy:

sudo systemctl restart caddy

Steg 7: Åtkomst till din webbplats

Navigera till följande URL i din webbläsare för att se din PHP-info-sida:

http://your_domain_or_IP/info.php

Avslutning

Ditt Caddy-webbserver med PHP 8.1 är nu installerat och klart för användning. Genom att använda denna metod kan du enkelt hantera din webbserver från en VPS-server.

Windows VPS Deutschland

Windows VPS España

Windows VPS Nederland

Windows VPS Italia

Key topics covered in Installera Caddy Web Server med PHP 8.1 på Ubuntu 22.04
Key topics covered in this NetCloud24 guide.

Windows VPS Portugal

VPS Windows Italia

Windows VPS

Windows VPS

Windows VPS Sverige

Windows VPS Norge

Windows VPS

Windows VPS Türkiye

Practical checklist for Installera Caddy Web Server med PHP 8.1 på Ubuntu 22.04
Practical checklist for applying the guidance in this article.

Windows RDS (Remote Desktop Services)

Windows VPS

Installera Caddy Web Server med PHP 8.1 på Ubuntu 22.04
Installera Caddy Web Server med PHP 8.1 på Ubuntu 22.04
Explore more

More on this topic

Netcloud24
Netcloud24
Cloud Infrastructure Expert · NetCloud24

Comments are closed.