Comment migrer le site Web NGINX vers ServBay

DDD
Libérer: 2024-10-01 16:07:03
original
748 Les gens l'ont consulté

How to Migrate NGINX Website to ServBay

ServBay comes with a built-in web server called Caddy, known for its simple configuration and automatic HTTPS. ServBay has already configured the Rewrite rules by default, so users usually do not need to configure them additionally. This article will detail how to migrate an NGINX website to ServBay, using examples with Laravel and WordPress.

Overview

Migrating a website involves transferring existing configurations and files to a new server environment. ServBay uses Caddy as the web server, and for most PHP frameworks and CMS systems, ServBay works out of the box without requiring additional configuration of Rewrite rules.

Preparation Before Migration

Before starting the migration, make sure you have backed up all website files and databases. Various issues may arise during migration, so backups are crucial.

Migrating Laravel Website

NGINX Configuration

The following is a typical NGINX configuration file for a Laravel website:

server {
    listen 80;
    server_name laravel.demo;

    root /Applications/ServBay/www/laravel/public;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/Applications/ServBay/tmp/php-cgi.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }
}
Copier après la connexion

Caddy Configuration

Important Notice
In ServBay, Rewrite rules and PHP processing rules are already configured by default, so users do not need to manually write configuration files.

The following is a theoretical example of Caddy configuration for comparison and understanding:

laravel.demo {
    root * /Applications/ServBay/www/laravel/public
    php_fastcgi unix//Applications/ServBay/tmp/php-cgi.sock
    file_server

    @notStatic {
        not {
            file {
                try_files {path} {path}/ /index.php?{query}
            }
        }
    }

    rewrite @notStatic /index.php
Copier après la connexion

Migrating WordPress Website

NGINX Configuration

The following is a typical NGINX configuration file for a WordPress website:

server {
    listen 80;
    server_name wordpress.demo;

    root /Applications/ServBay/www/wordpress;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/Applications/ServBay/tmp/php-cgi.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }
}
Copier après la connexion

Caddy Configuration

Important Notice
In ServBay, Rewrite rules and PHP processing rules are already configured by default, so users do not need to manually write configuration files.
The following is a theoretical example of Caddy configuration for comparison and understanding:

wordpress.demo {
    root * /Applications/ServBay/www/wordpress
    php_fastcgi unix//Applications/ServBay/tmp/php-cgi.sock
    file_server

    @notStatic {
        not {
            file {
                try_files {path} {path}/ /index.php?{query}
            }
        }
    }

    rewrite @notStatic /index.php
}
Copier après la connexion

Summary

Migrating an NGINX website to ServBay's Caddy server is very simple and does not require any configuration modifications. Users only need to add their website to ServBay. Caddy's configuration file syntax is simple and easy to read. ServBay has already configured the Rewrite rules and PHP processing by default, so users usually do not need additional configuration. This article guides you through the process of migrating Laravel and WordPress websites to ServBay.

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

source:dev.to
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!