This article mainly introduces the basic content about Nginx, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
Nginx-Basics
1 , Environment:
2. Environment debugging confirmation:
1. Four confirmations
Confirm system network
Confirm that yum is available
Confirm to close iptables rules
iptables -L (check whether there are iptables rules)
iptables -F (Close the rules)
iptables -t nat -L (Check whether there are rules in the net table)
If there are rules in the net table, they can be executed: iptables -t nat -F
Confirm to disable selinux
2. Two installations
Install gcc, etc.:
- ##yum -y install gcc gcc-c autoconf pcre pcre-devel make automake
- Install basic tools:
##yum -y install wget httpd-tools vim
3. One-time initialization
cd /opt;mkdir app download logs work backup
app: code directory download: source code package downloaded from the Internet logs: custom log work: shell script backup:Backup
3. What is Nginx:
Nginx is an open source, high-performance and reliable HTTP middleware, proxy service.
4. Nginx advantages:
IO multiplexing epoll Lightweight-
Few functional modules Few code modules
CPU affinity )
Bind the CPU core to the Nginx worker process, fix each worker process to execute on one CPU, reduce cache misses when switching CPUs, and obtain better performance .
sendfile
Transmit the file to the user only through kernel space, not through user space-
5. Quick installation of Nginx
Enter the official website http://nginx.org/ Click download Click Linux packages for stable version-
##Modify /etc/yum.repos.d/nginx.repo , and add the content specified by the official website
Note
: baseurl needs to modify the OS and OSRELEASE to your corresponding server version
Directly yum install nginx
-
nginx -v. If the nginx version information appears, the installation is successful!
6. Nginx directory and configuration syntax
rpm -ql nginx: You can query the files installed by nginx
-
Directory
-
##/etc/logrotate.d/nginx: Configuration file, Nginx log rotation, log cutting for logrotate service
/etc/nginx, /etc/nginx/nginx.conf, /etc/nginx/conf.d, /etc/nginx/conf.d/default.conf: directory, configuration file, Nginx main configuration file
/etc/nginx/fastcgi_params, /etc/nginx/uwsgi_params, /etc/nginx/scgi_params: configuration file, cgi configuration related, fastcgi configuration
/etc/nginx/koi-utf, /etc/nginx/koi-win, /etc/nginx/win-utf: configuration files, encoding conversion mapping conversion files
/etc/nginx/mime.types: Configuration file, set the corresponding relationship between the Content-Type of the http protocol and the extension
/usr/lib/systemd/system/ nginx-debug.service, /usr/lib/systemd/system/nginx.service, /etc/sysconfig/negix, /etc/sysconfig/negix-debug: Configuration files to configure the management method of the daemon manager
/usr/lib64/nginx/modules, /etc/nginx/modules: directory, Nginx module directory
/usr/sbin/nginx, /usr /sbin/nginx-debug: command, terminal command for startup management of Nginx service
/var/cache/nginx: directory, Nginx cache directory
/var/log/nginx: Directory, Nginx log directory
-
nginx -V:
Compilation parameters
-
--with-http_stub_status_module
--with-http_sub_module
- -with-http_random_index_module
--with-ld-opt=parameters
--with-cc-opt=parameters
--user=nginx
--group=nginx
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
- ##--http-fastcgi-temp-path=/var /cache/nginx/fastcgi_temp
##--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp -- http-scgi-temp-path=/var/cache/nginx/scgi_temp --prefix=/etc/nginx -- sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules -- conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock-
##Installation destination directory or path
-
Temporary files retained by nginx when executing the corresponding module
-
Set the user and user group for nginx process startup
-
Settings Additional parameters will be added to the CFLAGS variable
-
Set the additional parameters and link the system library
-
Randomly select a homepage in the directory
-
HTTP content replacement
-
Nginx client status
Nginx default configuration syntax
worker_connections: The maximum number of connections allowed per process
-
use: The number of worker processes
-
user: Set the system user for the nginx service
-
worker_processes: The number of worker processes (preferably consistent with the number of cpu)
-
error_log : nginx error log
-
pid: nginx service startup pid
-
events:
-
7. Nginx log types
Includes: error.log and access.log
-
Configured through nginx.conf log_format in the file to define the variable format to be recorded to record the log
-
Variables that can be recorded in the log
Nginx built-in
arg_PARAMETER: request parameter
-
http_HEADER: request header
-
sent_http_HEADER: header returned by the server
HTTP request variable
-
Built-in variable
-
Custom variables
8. Nginx module
nginx -tc /etc/nginx/nginx.conf : Check whether the configuration file syntax is correct
nginx -s reload -c /etc/nginx/conf: Restart
http_stub_status_module (display Nginx related information)
Configuration syntax: stub_status
-
Default: None
-
Context: server, location
-
random_index_module
Configuration syntax: random_index on|off
##default: sub_filter_once on
##sub_filter_last_modified on|off
limit_conn_module (connection frequency limit)
Configuration syntax: limit_conn zone number Default: None
-
Context: http, server, location
- Configuration syntax: limit_conn_zone key zone=name:size
Default: None
-
Context: http
##limit_conn_zone limit_conn
-
limit_req_module (request frequency limit)
Configuration syntax: limit_req zone=name [brust=number] [ nodelay]
Default: None
-
Context: http
limit_req_zone limit_req
Default: None
- Context: http, server, location, limit_except
Configuration syntax: allow address|CIDR (network segment)|unix:|all;
-
Default: None
Context: http, server, location, limit_except
Limitations: Access through a proxy will be invalid
You can use http_x_forwarded_for-
Combined with geo module Passed through http custom variables
http_auth_basic_module (User-based trust login)
Configuration syntax: auth_basic_user_file filePath Default: None
Context: http, server, location, limit_except
Configuration syntax: auth_basic string | off;-
Default: None Context: http, server, location, limit_except
auth_basic auth_basic_user_file
Note
: The format of the file is specified, you can use httpd-tools# to generate the password ##Command:
htpasswd -c filePath username
The above is the detailed content of Basic content about Nginx. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn