I have problem with Nginx configuration ?
My first VPS Debian8 64bit, Nginx 1.10(from dotdeb).
I saw only easy short configuration in man.
testing:
Main configuration
file: /etc/nginx/nginx.conf
sudo nginx -t
nginx: [emerg] invalid variable name in /etc/nginx/nginx.conf:54
nginx: configuration file /etc/nginx/nginx.conf test failed
54 last "}"
user www-data;
worker_processes auto;
pid /run/nginx.pid;
#include /etc/nginx/modules-enabled/*.conf;
# include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
#include /etc/nginx/sites-available/*;
events {
worker_connections 768;
# multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
server {
server_name IP_VPS mysite.com www.mysite.com;
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
location / {
root /var/www/html;
try_files $uri $uri/ =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_nam$;
include fastcgi_params;
}
}
}
"site configuration" for the piwigo gallery
file:
/etc/nginx/sites-available/piwigo
After activation include /etc/nginx/sites-available/*;
sudo nginx -t
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-available/piwigo:1
nginx: configuration file /etc/nginx/nginx.conf test failed
If i remove server the location is directive is not allowed here
server {
location ~ /\.ht {
deny all;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# piwigo distribution files
location ~ ^/(README|doc)$ {
deny all;
}
# prevent direct acces to uploaded images, derivates and logs
location ~ ^/(_data/(logs)/ {
deny all;
}
location / {
index index.php;
try_files $uri $uri/ @rewrite;
}
location / {
rewrite ^/picture((/|$).*)$ /picture.php$1 last;
rewrite ^/index((/|$).*)$ /index.php$1 last;
rewrite ^/i((/|$).*)$ /i.php$1 last;
}
location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
try_files $script_name = 404;
}
}
#piwigo
client_max_body_size 50m;
client_body_buffer_size 25m;
set $check_referal "";
I tried to put everything in one file /etc/nginx/nginx.conf but it did not work.
Thank you for your attention.
My first VPS Debian8 64bit, Nginx 1.10(from dotdeb).
I saw only easy short configuration in man.
testing:
Main configuration
file: /etc/nginx/nginx.conf
sudo nginx -t
nginx: [emerg] invalid variable name in /etc/nginx/nginx.conf:54
nginx: configuration file /etc/nginx/nginx.conf test failed
54 last "}"
user www-data;
worker_processes auto;
pid /run/nginx.pid;
#include /etc/nginx/modules-enabled/*.conf;
# include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
#include /etc/nginx/sites-available/*;
events {
worker_connections 768;
# multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
server {
server_name IP_VPS mysite.com www.mysite.com;
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
location / {
root /var/www/html;
try_files $uri $uri/ =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_nam$;
include fastcgi_params;
}
}
}
"site configuration" for the piwigo gallery
file:
/etc/nginx/sites-available/piwigo
After activation include /etc/nginx/sites-available/*;
sudo nginx -t
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-available/piwigo:1
nginx: configuration file /etc/nginx/nginx.conf test failed
If i remove server the location is directive is not allowed here
server {
location ~ /\.ht {
deny all;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# piwigo distribution files
location ~ ^/(README|doc)$ {
deny all;
}
# prevent direct acces to uploaded images, derivates and logs
location ~ ^/(_data/(logs)/ {
deny all;
}
location / {
index index.php;
try_files $uri $uri/ @rewrite;
}
location / {
rewrite ^/picture((/|$).*)$ /picture.php$1 last;
rewrite ^/index((/|$).*)$ /index.php$1 last;
rewrite ^/i((/|$).*)$ /i.php$1 last;
}
location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
try_files $script_name = 404;
}
}
#piwigo
client_max_body_size 50m;
client_body_buffer_size 25m;
set $check_referal "";
I tried to put everything in one file /etc/nginx/nginx.conf but it did not work.
Thank you for your attention.