Difference between revisions of "Nginx"
Jump to navigation
Jump to search
(→PHP Configure) |
|||
Line 87: | Line 87: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Log == | == Log == | ||
* /var/log/nginx | * /var/log/nginx |
Revision as of 09:45, 1 December 2019
Contents
install
- In case for any error, stop apache first: sudo service apache2 stop
- apt-get install nginx
- allow gfw -> sudo ufw allow 'Nginx HTTP'
- Test
Restart
- service nginx start
- check start status -> systemctl status nginx.service
- systemctl restart nginx
- Default root folder /var/www/html
Full remove
- sudo apt-get remove nginx nginx-common # Removes all but config files.
- sudo apt-get purge nginx nginx-common # Removes everything.
- sudo apt-get autoremove
Config
Basic
- default config file: nano /etc/nginx/sites-available/default
- link enable config file: /etc/nginx/sites-enabled/default
- delete etc/nginx/sites-avaialble/default
- edit /etc/nginx/sites-enabled/default
- set server_name www.example.com example.com;
Furture Config
Steps | Header text | Header text |
---|---|---|
Nginx config | /etc/nginx/nginx.conf | |
Default site config | /var/www/html -> defined at /etc/nginx/sites-enabled/default | - |
- create file e.g. /etc/ningx/sites-enabled/iot.electrodragon.com.conf
- Optimize -> delete other conf file? FastCGI cache?, gzip missing?
Optimized
- sudo nano /etc/nginx/nginx.conf
- nginx -> enable gzip on, set staic file caching?, buffers, timetout
NGINX Config
server {
listen 80;
listen [::]:80;
root /usr/share/nginx/www; # root of user file
index index.html index.htm; # file name
server_name localhost; # e.g. www.electrodragon.com
location / {
try_files $uri $uri/ /index.html;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
}
Setup for uwsgi
server {
listen 80;
server_name www.portf.ltd portf.ltd;
# root /var/www/html;
# index index.html;
location / {
# try_files $uri $uri/ =404;
include uwsgi_params;
uwsgi_pass unix:/var/www/html/flask-test/sock.sock;
}
}
Log
- /var/log/nginx
Error Fix
upstream prematurely closed connection while reading response header from upstream