nginxarchitecture
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
nginxarchitecture [2024/10/27 01:59] – [PHP-FPM Config and Optimize] admin | nginxarchitecture [2024/10/27 02:55] (current) – [Basic Nginx Configuration] admin | ||
---|---|---|---|
Line 26: | Line 26: | ||
* Since Nginx comes only with core features that are required for a web server, **it is lightweight when compared to Apache**. | * Since Nginx comes only with core features that are required for a web server, **it is lightweight when compared to Apache**. | ||
* The performance and scalability of Nginx is not completely dependent on hardware resources, whereas the performance and scalability of the Apache is dependent on underlying hardware resources like memory and CPU. | * The performance and scalability of Nginx is not completely dependent on hardware resources, whereas the performance and scalability of the Apache is dependent on underlying hardware resources like memory and CPU. | ||
+ | ===== Basic Nginx Configuration ===== | ||
+ | Some basic directives: | ||
+ | * Location (refer: https:// | ||
+ | user nobody; # a directive in the ' | ||
+ | |||
+ | events { | ||
+ | # configuration of connection processing | ||
+ | } | ||
+ | |||
+ | http { | ||
+ | # Configuration specific to HTTP and affecting all virtual servers | ||
+ | |||
+ | server { | ||
+ | # configuration of HTTP virtual server 1 | ||
+ | location /one { | ||
+ | # configuration for processing URIs starting with '/ | ||
+ | } | ||
+ | location /two { | ||
+ | # configuration for processing URIs starting with '/ | ||
+ | } | ||
+ | } | ||
+ | |||
+ | server { | ||
+ | # configuration of HTTP virtual server 2 | ||
+ | } | ||
+ | } | ||
+ | |||
+ | stream { | ||
+ | # Configuration specific to TCP/UDP and affecting all virtual servers | ||
+ | server { | ||
+ | # configuration of TCP virtual server 1 | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | * request_filename (refer: https:// | ||
+ | if (!-e $request_filename) { rewrite ^ / | ||
+ | </ | ||
+ | * try_files (refer https:// | ||
+ | location / { | ||
+ | try_files $uri $uri/ $uri.html =404; | ||
+ | } | ||
+ | </ | ||
+ | location / { | ||
+ | try_files $uri $uri/ / | ||
+ | } | ||
+ | </ | ||
+ | location / => matches all locations** | ||
+ | try_files $uri =>try $uri first, for example http:// | ||
+ | $uri/=> which means if you didn't find the first condition $uri try the URI as a directory | ||
+ | </ | ||
===== Optimize nginx configuration for performance and benchmark ===== | ===== Optimize nginx configuration for performance and benchmark ===== | ||
refer: | refer: |
nginxarchitecture.1729994361.txt.gz · Last modified: 2024/10/27 01:59 by admin