how to enable a site conf in nginx
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
how to enable a site conf in nginx
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
How to Configure NGINX
1. Directives, Blocks, and Contexts
File: /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
. . .
}
http {
. . .
}
2. The http Block
File: /etc/nginx/nginx.conf
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
3. Server Blocks
File: /etc/nginx/conf.d/example.com.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
root /var/www/example.com;
index index.html;
try_files $uri /index.html;
}
4. Listening Ports
File: /etc/nginx/conf.d/example.com.conf
server_name example.com www.example.com;
5. Location Blocks
location / { }
location /images/ { }
location /blog/ { }
location /planet/ { }
location /planet/blog/ { }
6. Location Root and Index
location / {
root html;
index index.html index.htm;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us