目次
回复内容:
ホームページ バックエンド開発 PHPチュートリアル nginx 虚拟主机配置指向不同目录,访问的时候全部指向网站跟目录

nginx 虚拟主机配置指向不同目录,访问的时候全部指向网站跟目录

Jun 06, 2016 pm 08:33 PM
nginx php

在win8下配置nginx虚拟主机
host文件:

<code>127.0.0.1 z.vilay.com
127.0.0.1 v.vilay.com
</code>
ログイン後にコピー
ログイン後にコピー

nginx.conf文件:

<code>#user nobody; 
worker_processes 1; 
#error_log logs/error.log; 
#error_log logs/error.log notice; 
#error_log logs/error.log info; 
#pid logs/nginx.pid; 
events { 
worker_connections 64; 
} 
http { 
    include mime.types; 
    default_type application/octet-stream; 
    sendfile on; 
    keepalive_timeout 65; 
    #gzip on; 
    include vhost/*.conf; 
} 
</code>
ログイン後にコピー
ログイン後にコピー

nginx/vhost下两个文件v.conf,default.conf
v.conf文件:

<code>server {
        listen       80;
        server_name  v.vilay.com;
        root   F:/www/vtest;

        #charset koi8-r;

        access_log  logs/v.access.log;

        location / {

            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }
</code>
ログイン後にコピー
ログイン後にコピー

default.conf文件:

<code>    server {
        listen       80;
        server_name  z.vilay.com;
        root   F:/www;

        #charset koi8-r;

        access_log  logs/default.access.log;

        location / {

            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }
</code>
ログイン後にコピー
ログイン後にコピー
<code>nginx重启访问的时候全部指向了网站根目录F:/www底下
</code>
ログイン後にコピー
ログイン後にコピー

回复内容:

在win8下配置nginx虚拟主机
host文件:

<code>127.0.0.1 z.vilay.com
127.0.0.1 v.vilay.com
</code>
ログイン後にコピー
ログイン後にコピー

nginx.conf文件:

<code>#user nobody; 
worker_processes 1; 
#error_log logs/error.log; 
#error_log logs/error.log notice; 
#error_log logs/error.log info; 
#pid logs/nginx.pid; 
events { 
worker_connections 64; 
} 
http { 
    include mime.types; 
    default_type application/octet-stream; 
    sendfile on; 
    keepalive_timeout 65; 
    #gzip on; 
    include vhost/*.conf; 
} 
</code>
ログイン後にコピー
ログイン後にコピー

nginx/vhost下两个文件v.conf,default.conf
v.conf文件:

<code>server {
        listen       80;
        server_name  v.vilay.com;
        root   F:/www/vtest;

        #charset koi8-r;

        access_log  logs/v.access.log;

        location / {

            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }
</code>
ログイン後にコピー
ログイン後にコピー

default.conf文件:

<code>    server {
        listen       80;
        server_name  z.vilay.com;
        root   F:/www;

        #charset koi8-r;

        access_log  logs/default.access.log;

        location / {

            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }
</code>
ログイン後にコピー
ログイン後にコピー
<code>nginx重启访问的时候全部指向了网站根目录F:/www底下
</code>
ログイン後にコピー
ログイン後にコピー

目测这里有问题

<code>fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
</code>
ログイン後にコピー

可以改成这样试试

<code>fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
</code>
ログイン後にコピー
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

nginx403を解く方法 nginx403を解く方法 Apr 14, 2025 am 10:33 AM

Nginx 403禁止エラーを修正する方法は?ファイルまたはディレクトリの許可を確認します。 2。HTACCESSファイルを確認します。 3. nginx構成ファイルを確認します。 4。nginxを再起動します。他の考えられる原因には、ファイアウォールルール、Selinux設定、またはアプリケーションの問題が含まれます。

nginx403エラーを解く方法 nginx403エラーを解く方法 Apr 14, 2025 pm 12:54 PM

サーバーには、要求されたリソースにアクセスする許可がなく、NGINX 403エラーが発生します。ソリューションには以下が含まれます。ファイル許可を確認します。 .htaccess構成を確認してください。 nginx構成を確認してください。 SELINUXアクセス許可を構成します。ファイアウォールルールを確認してください。ブラウザの問題、サーバーの障害、その他の可能なエラーなど、他の原因をトラブルシューティングします。

Nginxが開始されるかどうかを確認する方法 Nginxが開始されるかどうかを確認する方法 Apr 14, 2025 pm 01:03 PM

nginxが開始されるかどうかを確認する方法:1。コマンドラインを使用します:SystemCTLステータスnginx(Linux/unix)、netstat -ano | FindStr 80(Windows); 2。ポート80が開いているかどうかを確認します。 3.システムログのnginx起動メッセージを確認します。 4. Nagios、Zabbix、Icingaなどのサードパーティツールを使用します。

Linuxでnginxを開始する方法 Linuxでnginxを開始する方法 Apr 14, 2025 pm 12:51 PM

Linuxでnginxを開始する手順:nginxがインストールされているかどうかを確認します。 systemctlを使用して、nginxを開始してnginxサービスを開始します。 SystemCTLを使用して、NGINXがシステムスタートアップでNGINXの自動起動を有効にすることができます。 SystemCTLステータスNGINXを使用して、スタートアップが成功していることを確認します。 Webブラウザのhttp:// localhostにアクセスして、デフォルトのウェルカムページを表示します。

nginx304エラーを解く方法 nginx304エラーを解く方法 Apr 14, 2025 pm 12:45 PM

質問への回答:304変更されていないエラーは、ブラウザがクライアントリクエストの最新リソースバージョンをキャッシュしたことを示しています。解決策:1。ブラウザのキャッシュをクリアします。 2.ブラウザキャッシュを無効にします。 3.クライアントキャッシュを許可するようにnginxを構成します。 4.ファイル許可を確認します。 5.ファイルハッシュを確認します。 6. CDNまたは逆プロキシキャッシュを無効にします。 7。nginxを再起動します。

Windowsでnginxを構成する方法 Windowsでnginxを構成する方法 Apr 14, 2025 pm 12:57 PM

Windowsでnginxを構成する方法は? nginxをインストールし、仮想ホスト構成を作成します。メイン構成ファイルを変更し、仮想ホスト構成を含めます。 nginxを起動またはリロードします。構成をテストし、Webサイトを表示します。 SSLを選択的に有効にし、SSL証明書を構成します。ファイアウォールを選択的に設定して、ポート80および443のトラフィックを許可します。

Nginxクロスドメインの問題を解決する方法 Nginxクロスドメインの問題を解決する方法 Apr 14, 2025 am 10:15 AM

Nginxクロスドメインの問題を解決するには2つの方法があります。クロスドメイン応答ヘッダーの変更:ディレクティブを追加して、クロスドメイン要求を許可し、許可されたメソッドとヘッダーを指定し、キャッシュ時間を設定します。 CORSモジュールを使用します。モジュールを有効にし、CORSルールを構成して、ドメインクロスリクエスト、メソッド、ヘッダー、キャッシュ時間を許可します。

Nginxが起動されているかどうかを確認する方法は? Nginxが起動されているかどうかを確認する方法は? Apr 14, 2025 pm 12:48 PM

Linuxでは、次のコマンドを使用して、nginxが起動されるかどうかを確認します。SystemCTLステータスNGINXコマンド出力に基づいて、「アクティブ:アクティブ(実行)」が表示された場合、NGINXが開始されます。 「アクティブ:非アクティブ(dead)」が表示されると、nginxが停止します。

See all articles