18

このウェブサイトhttp://raspberrypihelp.net/tutorials/24-raspberry-pi-webserverに従って、Raspberry Pi で HTTP サーバー nginx をセットアップし、サイト コールexample.comをセットアップしようとしました。しかし、私が実行するsudo service nginx restartと、それは言った

nginx を再起動しています: nginx: [emerg] /etc/nginx/sites-enabled/example.com:3 の不明なディレクティブ " "

これがexample.comのコードです。

    server {

    server_name example.com 192.168.1.88;

    access_log /srv/www/example.com/logs/access.log;

    error_log /srv/www/example.com/logs/error.log;

    root /srv/www/example.com/public/;

    location / {

        index index.php index.html index.htm;

        try_files $uri $uri/ /index.php?$args;

    }

    location ~ \.php$ {

        include /etc/nginx/fastcgi_params;

        fastcgi_pass unix:/var/run/php5-fpm.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME /srv/www/example.com/public$fastcgi_script_name;

    }

    location /phpmyadmin {

        root /usr/share/;

        index index.php index.html index.htm;

        location ~ ^/phpmyadmin/(.+\.php)$ {

            try_files $uri =404;

            root /usr/share/;

            fastcgi_pass unix:/var/run/php5-fpm.sock;

            fastcgi_index index.php;

            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

            include /etc/nginx/fastcgi_params;

        }

        location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {

            root /usr/share/;

        }

    }

    location /phpMyAdmin {

        rewrite ^/* /phpmyadmin last;

    }

}

手順に従っているだけですが、正常に実行できません。

4

7 に答える 7

35

私は同じ問題を抱えていました.Webから設定コードをコピー/貼り付けし、EOLそこにいくつかのダーティな(行末)文字を貼り付けました。

エディターはそれらを表示しませんでしたが、nginxそれらをディレクティブのように扱いました。

すべてEOLを削除して再度追加しました。

于 2014-02-22T21:27:18.443 に答える
10

ここでコピーと貼り付けの作業を行ったようです。行末 (EOL) で見えない余分な文字が引っかかることは珍しくありません。これを試して:

このツールでテキストを実行します: http://www.textfixer.com/tools/remove-line-breaks.php

次に、削除された可能性があり、コメントの影響を受ける可能性のある中断を修正します。

これは私にとってはうまくいきました。それがうまくいくことを願っています。

于 2014-07-23T18:25:22.330 に答える
1

--without-http_fastcgi_module オプションを指定して nginx バイナリがコンパイルされたようです。これはデフォルトではありません。別のバイナリをダウンロードまたはコンパイルしてみてください。

実行してみてください

nginx -V

(大文字の V) を使用して、nginx のコンパイルに使用されたオプションを確認します。

于 2013-11-24T02:31:11.713 に答える