Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Nginx in Linux system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How do I install Nginx on a Linux system? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

Install using system binary source

In the Ubuntu/Debian department

Sudo apt-get install nginx

Or RedHat/CentOS system.

Sudo yum install nginx

This is the easiest, quickest way, but not the best way. Let's talk about the main problem below.

Advantages

All installation binary dependencies have been dealt with, don't worry about compatibility, use it right out of the box

There is no need to deal with the connection configuration and user permissions of Nginx. I have already written this piece for you.

Don't worry about Nginx Bug maintenance and upgrade, just get the latest system directly.

It's easy to uninstall, just one command.

Log maintenance is simple, automatically truncate the current day's log, compress and save

Shortcoming

Cannot choose the installation version on your own

You cannot choose compiled modules independently.

Extending functionality becomes troublesome and needs to be recompiled

The structure of the object class is complex, the configuration file is in / etc/, and the deployment file is in / var/www

Root permission is required to restart the service and modify the configuration.

Poor performance compilation and installation

If you are a novice to Linux, it is absolutely recommended to use this method of installation, without considering the compilation dependency, you can use it directly after installation. However, if your server is used in a production environment that is developing a gradual improvement process, this approach is not recommended. Third-party modules may be added in the future, and be sure to compile and install them (as we'll see below). When restarting the server, do not use the root user, but use sudo to get the root briefly. If your server is used to deploy some static files, mainly do some web space, usually mainly use ftp tools to deploy files, there is certainly no problem in this way.

Compilation and installation

Advantages and disadvantages, I will not write, basically is the above upside down on it. Using this method of installation, you must have some knowledge of Linux compilation before moderate Linux users can control it. I see that for most tutorials online, it is not good to install compilation dependencies directly in / usr/local/. If we want to uninstall these dependencies in the future, we will find it very troublesome. It is not possible to delete it directly under the category. Some Linux distributions will write the installation files to the configuration files. I don't know where to find these configuration files. If relying on the version affects other software, how to deal with the version problem. We just wanted to install Nginx, which led to a lot of problems.

Compilation environment preparation

Before you start, make sure your Linux has software like gcc, make, and wget,g++.

Create an object class to store the download file, enter the directory to download the dependent library source file

Download openssl is mainly used for ssl module encryption and supports htps

Wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz

Download pcre to support address redirection, address rewriting, localtion instructions and regular expressions

Wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz

Download the zlib gzip compression module

Wget https://zlib.net/zlib-1.2.11.tar.gz

Download Nginx

Wget http://nginx.org/download/nginx-1.17.1.tar.gz

Use tar to extract all files

Ls * .tar.gz | xargs-N1 tar xzvf

Compilation option

Scripts that use. / configure to set various Nginx parameters, including paths to source and configuration files, compiler options, connection handling methods, and module lists. This script is done by creating compiled code and installing the Makefile required for Nginx open source.

Parameter description-the prefix=Nginx installation directory, as well as the base location of all relative paths set by paths with other configuration script options. Default value / usr/local/nginx-sbin-path=

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report