linux Server nginx Uninstall and Install Tutorial

  • 2021-06-28 14:46:12
  • OfStack

Preface

On the newly contacted linux server, the nginx configuration was somewhat outrageous, so we reloaded the old one.Next, let's go into more detail.

uninstall

linux has a series of software managers, such as the common yum under linux, apt-get under Ubuntu, and so on.These software managers allow you to quickly uninstall the software without any file or configuration residues.Here I'm using yum with the following commands


yum remove nginx

install

Installation can be more cumbersome than uninstalling, but it's okay.Step 1 Step ~

1. Download and unzip the installation package


wget http://nginx.org/download/nginx-1.13.7.tar.gz

tar -xvf nginx-1.13.7.tar.gz

mv nginx-1.13.7.tar.gz nginx //  Rename to Short Name 

Many people say that you depend on it first, yes, but you can also put it in the back, see the error, need that one, so you can still be impressed ~~

There are four main ways to install dependencies first

gcc, gcc-c++: Used primarily for compilation-related purposes

openssl, openssl-devel: 1 This is usually required when configuring the https service

zlib, zlib-devel: Used mainly for file decompression

pcre, pcre-devel: rewrite module of Nginx and HTTP core module use PCRE regular expression syntax

Others, less errors before loading

2. Configuration, compilation and installation


./configure

make

make install

3. nginx Start Test


./nginx -t

The following indicates that the configuration is correct

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

You may encounter the problem of missing dependencies in the process. If you have less dependencies, go ahead. yum install XXX is appropriate.That's the end of the configuration ~~

Naive!!!

Above is the "One Way Down Wind" process.

If you want to configure an https for server, you may encounter the following error

nginx: [emerg] unknown directive "ssl"

ssl directive not recognized?!This is because the relevant modules of OpenSSL were not loaded at the time of default compilation, and the solution is as follows:


./configure --with-http_ssl_module //  again config And specify other modules http_ssl_module
 
make //  No make install No make install No make install  That will cover it 

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak //  First put the original nginx Backup can be deleted if you want 

cp objs/nginx /usr/local/nginx/sbin/nginx // objs  The directory is the compiled file 

/usr/local/nginx/sbin/nginx -t //  In Test 1 lower 

Wait until you really run your project before you finish it~~Get here first

summary


Related articles: