1

nginx を使用するのはこれが初めてで、2 つの問題があります。最初の 1 つは、http://localhost/project を自動的にhttp://localhot/project/en/ にリダイレクトしたいということです。事業。

2 番目の問題: localhost/project/en/ で index.php を見ることができます。つまり、メイン ページを意味しますが、プロジェクトからリダイレクトするたびに、localhost/project/en/people/ や localhost/project/en/ のように 404 が見つかりません。人/記事1

NB:私はdrupalと. ここに私の設定があります:

    worker_processes  1;
events {
    worker_connections  1024;
}
http {
    server_tokens       on;
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    ssi         off;

    #Timeouts
        client_body_timeout 5;
        client_header_timeout   5;
        keepalive_timeout   25 25;
        send_timeout        15s;
    resolver_timeout    3s;

    #Directive sets timeout period for connection with FastCGI-server. It should be noted that this value can't exceed 75 seconds. 
    fastcgi_connect_timeout 5s;

    #Directive sets the amount of time for upstream to wait for a fastcgi process to send data. Change this directive if you have long running fastcgi processes that do not produce output until they have finished processing. If you are seeing an upstream timed out error in the error log, then increase this parameter to something more appropriate. 
    fastcgi_read_timeout    400s;

    #Directive specifies request timeout to the server. The timeout is calculated between two write operations, not for the whole request. If no data have been written during this period then serve closes the connection.
    fastcgi_send_timeout    150s;

    fastcgi_buffers 8 32k;
    fastcgi_buffer_size 32k;
    #fastcgi_busy_buffers_size 256k;
    #fastcgi_temp_file_write_size 256k;

    open_file_cache off;

    #php max upload limit cannot be larger than this       
    client_max_body_size 8m;
        ####client_body_buffer_size  1K;
        client_header_buffer_size 1k;
        large_client_header_buffers 2 1k;   
    types_hash_max_size 2048;

    include nginx.mimetypes.conf;
    default_type text/html;

    ##
    # Logging Settings
    ##
    access_log "c:/wt-nmp/log/nginx_access.log";
    error_log "c:/wt-nmp/log/nginx_error.log" warn; #debug or warn
    log_not_found on;  #enables or disables messages in error_log about files not found on disk. 
    rewrite_log off;

    #Leave this off
    fastcgi_intercept_errors off;

    gzip  off;

    index  index.php index.htm index.html;

    server {
        listen      127.0.0.1:80    default_server;
        #listen     [::1]:80    ipv6only=on;
        server_name  localhost;

        root "c:/wt-nmp/www/";
        autoindex on;

        allow       127.0.0.1;
        #allow      ::1;
        deny        all;

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
           # deny  all;   
        }

    location /project {
    index index.php;
    try_files $uri $uri/ @handler;
    }

    location @handler { rewrite / /project/en/index.php; }

    location ~ ^/en/ {
         root "c:/wt-nmp/www/project";
        try_files $uri $uri/ /en/index.php?$args;
    }
        #tools are now served from wt-nmp/include/tools/
        location ~ ^/tools/.*\.php$ {                   
            root "c:/wt-nmp/include";
            try_files $uri =404; 
            include     nginx.fastcgi.conf;
            fastcgi_pass    php_farm;
        }
        location ~ ^/tools/ {
            root "c:/wt-nmp/include";
        }

        location ~ \.php$ {
           # try_files $uri =404; 
               # fastcgi_pass   php_farm;
            fastcgi_pass     127.0.0.1:9000;
            include     nginx.fastcgi.conf;
            }

    }

    include domains.d/*.conf;

    include nginx.phpfarm.conf;
}
4

1 に答える 1

0

「クリーン URL」を使用した Drupal 7 の WPN-XM サーバー スタックのインストール手順

インストール手順:

  1. ダウンロードhttp://ftp.drupal.org/files/projects/drupal-7.34.zip
  2. c:\wpn-xm\www に解凍します。
  3. バージョン化されたフォルダーの名前を単に「drupal」に変更 = drupal へのフル パス = c:\wpn-xm\www\drupal
  4. drupal インストールを実行します - http://localhost/drupal/install.php
  5. 不足している PHP 拡張機能を有効にします: gd2、mbstring などを使用してから、php を再起動します。
  6. インストールページをリロード、すべて緑色、データベースダイアログに進む
  7. データベースダイアログに入力する前に、管理者でデータベース「drupal」を作成し、それをダイアログでdbとして使用します
  8. 完了するまでインストール手順を続行します

ブラウズ: http://localhost/drupal/ OK、Drupal を localhost にインストールしました。


URL 書き換えとクリーン URL の手順:

インストール後、短い URL を機能させるには 3 つのことが必要です。

  1. 新しいホスト「http://drupal.dev」を提供します
  2. URL 書き換え用の Nginx 構成を追加する
  3. Drupal 構成で「クリーン URL」を有効にする

重要なお知らせ

short/nice/clean URLは、「localhost」ではなく、 「 http://drupal.dev/ 」で始まる URL に対してのみ機能します。メガホンの使用: " http://localhost/ ..." で動作しない - " http://drupal.dev/ ..." を使用してください。


  1. hostsファイルに「drupal.dev」を追加

「hosts」ファイルに「drupal.dev」を追加する必要があります。

  • 手動または
  • WPN-XM サーバー コントロール パネルから - 手順:
    • トレイ アイコンを右クリック - [ホストの管理]
    • 「追加」 - データ「127.0.01」「drupal.dev」
    • [OK] をクリックします。
    • Windows 権限ダイアログが表示されます。
    • [OK] をクリックして、「hosts」ファイルへの書き込みを許可します。
    • Anti-Virus ツールがホスト ファイルへの書き込みをブロックする場合は、AV を無効にし、手順を繰り返して、再度有効にします。

チェック: http://drupal.dev/?q=admin - わかりました

-

  1. **Drupal7 用の Nginx サーバー ブロックを追加します **

URL の書き換えを有効にするには、次の Nginx 構成ファイルを使用します。

https://github.com/WPN-XM/software/blob/master/nginx/config/conf/domains-disabled/drupal7.conf

includeメインでディレクティブを使用nginx.confしてロードする場合があります。

Nginx を再起動または再ハッシュして、新しい構成を有効にします。

これで、ブラウザーでURL " http://drupal.dev " の使用を開始できます。

サーバーブロックの次のディレクティブが重要です

# Make site accessible from http://drupal.dev/
server_name drupal.dev;

と書き換えルールrewrite ^/(.*)$ /index.php?q=$1;

チェック: http://drupal.dev/admin


  1. Drupal 設定で「クリーン URL」を有効にする

メニュー内のリンクは、「?q=」なしの「クリーン URL」形式で表示する必要があります。

最終チェック:

終わり。

于 2015-02-14T19:56:22.507 に答える