SoFunction
Updated on 2025-04-08

Implementation example of Nginx installation configuration

1. Download the installation package

wget /download/nginx-1.13.

2. Configure the installation environment

# 1. Decompressiontar -xvf /opt/apk/nginx-1.13. -C /opt/apk

# 2. Add user groupgroupadd nginx
# 3. Add unloginable useruseradd -r -g nginx nginx -s /sbin/nologin

# 4. Change the user group to which the folder belongschown nginx:nginx /opt/apk/nginx-1.13.7/ -R

# 5. Check installation dependenciesyum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

3. Compile and install Nginx

# Enter the directory that was decompressedcd /opt/apk/nginx-1.13.7

# Execute the command Considering the subsequent installation of the ssl certificate, add two modules./configure \
    --user=nginx \      # Set the user when the Nginx process is running    --group=nginx \     # Set the group when the Nginx process is running    --prefix=/opt/nginx-1.13.7 \    # Specify the installation prefix directory of Nginx    --with-http_ssl_module \     # Enable HTTP SSL module to support HTTPS protocol    --with-http_stub_status_module \   # Used to provide a simple server status page    --with-http_realip_module \  # Used to identify the real IP address of the client    --with-http_slice_module \  # Enable HTTP Slice module to support slice response, suitable for streaming and other fields    --with-stream  # Enable the Stream module for handling non-HTTP traffic, such as TCP and UDP data streamsNotice:--prefix=/usr/local/nginx The installation directory and the decompression directory cannot be the same

# Execute the make commandmake && make install

# Create a soft connection.  You can not use absolute paths, which are comparable to /etc/profileln -s /opt/nginx-1.13.7/sbin/nginx  /usr/local/bin/nginx

# Check whether the configuration file is correct (-t is checking, -c is the specified loading path)/opt/nginx-1.13.7/sbin/nginx -t -c /opt/nginx-1.13.7/conf/

# Service start/opt/nginx-1.13.7/sbin/nginx -c /opt/nginx-1.13.7/conf/
# Service restart/opt/nginx-1.13.7/sbin/nginx -c /opt/nginx-1.13.7/conf/ -s reload
# Service suspended/opt/nginx-1.13.7/sbin/nginx -c /opt/nginx-1.13.7/conf/ -s stop

# Check health statusps aux | grep nginx

This is the end of this article about the implementation example of Nginx installation configuration. For more information about Nginx installation configuration, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!