Prepare the environment

yum install gcc-c++ 
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
Copy the code

Compile the installation

Create folder /temp/nginx under /var

mkdir -p /var/temp/nginx  
Copy the code

Note: This document installs nginx in the /opt/nginx directory, and can be modified as requiredUpload the nginx package 1.19.8 to the specified directory Unpack the

The tar - ZXVF nginx - 1.19.8. Tar. GzCopy the code

Configuration parameters

#Go to the nginx unzip directoryCD nginx 1.19.8 /
#Run the command to configure installation parameters
#For ease of operation, this document sets the application directory, configuration directory, and execution directory respectively as
## / opt/nginx/home, / opt/nginx/home/conf/nginx. Conf, / opt/nginx/home/sbin/nginx
## The above Settings can be modified according to your actual needs
./configure --prefix=/opt/nginx/home --pid-path=/var/run/nginx/nginx.pid --conf-path=/opt/nginx/home/conf/nginx.conf --sbin-path=/opt/nginx/home/sbin/nginx --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module
Copy the code

Parameter Description:

parameter instructions
–prefix Installs the application to the specified directory
–pid-path Define the file that stores the ID of the nginx main process
–sbin-path Point to (Execute) program file (nginx)
–conf-path Pointing to configuration files
–lock-path The installation file is locked to prevent the installation file from being used by others or misoperated by yourself
–error-log-path Configuration errors are logged
–http-log-path Path to the HTTP log
–with-http_gzip_static_module Online real-time compression output data stream
–http-client-body-temp-pathx Define a storage directory for storing temporary files that host the client request body
–http-proxy-temp-path Define directories for storing temporary files that host data received from proxy servers
–http-fastcgi-temp-path Set the HTTP FastCGI temporary file path
–http-uwsgi-temp-path Set the HTTP UWSGI temporary file path
–http-scgi-temp-path Set the HTTP SCGI temporary file path
–with-http_ssl_module Enable ngx_HTTP_SSL_module support (HTTPS request support must be installed
–with-http_flv_module Enable ngx_HTTP_FLv_module support (provides seeking memory using time-based offset files)
–with-http_stub_status_module Enable ngx_HTTP_stub_status_module support (get the working status of nginx since it was last started

Compile the installation

## compiler
make
## installation
make install
Copy the code

If no error is reported, the installation is successful. Check the directory for verification

cd /opt/nginx/home/
Copy the code

run

Go to the sbin directory of nginx and run nginx in the current directory

## enter directory
cd /opt/nginx/home/sbin/
## run nginx
./nginx
Copy the code

View the nginx process

ps aux|grep nginx
Copy the code

Browser Access Authentication

Enter the server IP address in the browser. No port is required by default

stop

Go to the sbin directory of nginx and enter the close command

./nginx -s quit
Copy the code

Nginx. conf configuration notes

#user  nobody;             Configure the user or group. Default is nobody nobodyworker_processes 2; # Number of processes allowed to be generated. Default is 1
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid        logs/nginx.pid;      # specify the address where the nginx process run file is storedevents { worker_connections 1024; Accept_mutex on = 1024; # set network connection serialization to prevent group alarm, default to on #use epoll; # event driven model, select | poll | kqueue | epoll | who | / dev/poll | eventport multi_accept on; HTTP {include mime.types; Default_type application/octet-stream; The default file type is text/plain #access_log off. Log_format mainFormat '$remote_ADDR - $remote_user [$time_local] "$request" $status $body_bytes_SENT "$http_referer""$http_user_agent" "$http_x_forwarded_for"'; Access_log /access.log mainFormat; #combined = default value sendFile on; # Allow sendfile (off by default) to transfer files in HTTP block, server block, location block sendfile_max_chunk 100K; The number of transfers per call of each process cannot exceed the set value. The default value is 0, that is, no upper limit is set. #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; Gzip on the HTTP, server, location block; server { keepalive_requests 120; Listen 80; Server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html/build; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php${# proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php${# root HTML; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:! aNULL:! MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # #}}}Copy the code