Nginx: [an unknown] directive appears in / etc / nginx / sites-enabled / example.com.

I followed this site http://raspberrypihelp.net/tutorials/24-raspberry-pi-webserver to configure the nginx HTTP server on my Raspberry Pi and try to configure the call to example.com . But when I started sudo service nginx restart , he said

Restarting nginx: nginx: [unknown] "" directive appears in / etc / nginx / sites -enabled / example.com: 3

Here is the code in 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; } } 

I just follow the steps, but it cannot work successfully.

+6
source share
3 answers

I had the same problem that I was copying / pasting confic code from a webpage and some dirty EOL characters (end of line) there.

the editor did not show them, but nginx created them as a directive.

just deleted every EOL and added again.

+7
source

It looks like you made a copy and paste here. It is not uncommon to catch some extra characters that are invisible at the end of a line (EOL). Try the following:

Run your text with this tool: http://www.textfixer.com/tools/remove-line-breaks.php

then fix any gaps that might have been removed and will be affected by the comments.

It worked for me. Hope this works for you.

+7
source

It looks like the nginx binary was compiled with the --without-http_fastcgi_module option. This is not the default. Try downloading or compiling another binary.

Try to run

 nginx -V 

(uppercase V) to find out which options were used to compile nginx.

+1
source

Source: https://habr.com/ru/post/955206/


All Articles