【问题标题】:nginx: [emerg] unknown directive " " in example.com: 3nginx:[emerg] 未知指令“”在 example.com:3
【发布时间】:2013-10-12 17:13:50
【问题描述】:

我已关注此网站http://raspberrypihelp.net/tutorials/24-raspberry-pi-webserver 在我的 Raspberry Pi 上设置 HTTP 服务器 nginx 并尝试设置站点调用 example.com。但是当我运行sudo service nginx restart 时,它说

重启 nginx: nginx: [emerg] unknown directive " " in /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;

    }

}

我使用/usr/sbin/nginx -t -v 检查我使用的是 nginx/1.2.1。我可以去 http://127.0.0.1 查看默认站点(/usr/share/nginx/www/index.html),这意味着它可以运行文件/etc/nginx/sites-enabled/default强>。我只是按照步骤操作,但它无法成功运行。

【问题讨论】:

    标签: nginx raspberry-pi


    【解决方案1】:

    尝试添加这一行:

    server {
    
    listen 192.168.1.88:80; // Add this "listen" with port 80
    server_name example.com www.example.com;
    
    # Rest of code
    }
    

    【讨论】:

      猜你喜欢
      • 2013-10-10
      • 2020-04-09
      • 2021-08-30
      • 2020-02-17
      • 2011-07-15
      • 1970-01-01
      • 1970-01-01
      • 2017-06-05
      • 2018-11-23
      相关资源
      最近更新 更多