Debianでnginxを使用するlocalhostと同じものは何ですか?

Debianでnginxを使用するlocalhostと同じものは何ですか?

私が見つけたすべてのnginx設定ガイドは、example.comのサーバー設定に関するものです。しかし、ドメイン名はありません。 XAMPPに付属のApacheを使用して、Windowsのlocalhostに似たローカルDNSを設定したいと思います。 2つのポートを作りたいです。これがnginxのサーバーブロックだと思います。ポートの1つはAPI用、ポートの1つはフロントエンド用です。私は2つのファイルを作成しました。

/etc/nginx/conf.d/chubak.conf:

server {
        listen 85;
        server_name chubak.com;
        access_log /srv/logs/vue.access.log;
        error_log /srv/logs/vue.error.log;
        gzip_static on;
# root /srv/default;
        root /var/www/chubak.com/html;
        index index.html;
        location / {
                add_header 'Access-Control-Allow-Origin' '*';
                try_files $uri $uri/ /index.html;
        }

および/etc/nginx/conf.d/api.chubak.conf:

server {
        listen 180;
        server_name api.chubak.com;
        access_log /var/www/api.chubak.com/logs/api.access.log;
        error_log /var/www/api.chubak.com/logs/api.error.log;
        root /var/www/api.chubak.com/html;
        index index.php index.html;
        client_max_body_size 128M;
        location / {
            try_files $uri $uri/ /index.php?_url=$uri&$args;
        }
        location ~ \.php$ {
            include /etc/nginx/fastcgi.conf;
            fastcgi_split_path_info       ^(.+\.php)(/.+)$;
            fastcgi_param PATH_INFO       $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_read_timeout 600;
            fastcgi_intercept_errors on;
            gzip off;
            fastcgi_index   index.php;
        }

/var/www/site/htmlフォルダにindex.htmlファイルを作成しましたが、そのファイルにアクセスする方法がわかりません。私が言ったように、チュートリアルでは常にサーバーを指すドメイン名があるとします。

ベストアンサー1

Debianベースのシステムのlocalhostファイルはです/etc/hosts。最後の行の後に、次のように1行を追加します127.0.0.1(最も適切なIPアドレスを使用)。

127.0.0.1    chubak.com
127.0.0.1    api.chubak.com

おすすめ記事