Example of how to install nginx to a specified directory

Example of how to install nginx to a specified directory

Due to company requirements, two nginx servers in different locations need to be installed on the same machine. what! I used to install it directly in /user/local/, or yum install nginx in /etc/nginx, what should I do now?

After some searching, I finally found some reliable answers.

./configure \
--prefix=directory you want to install to\
--sbin-path=/directory you want to install/nginx \
--conf-path=/directory you want to install/nginx.conf \
--pid-path=/directory you want to install/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/pcre-8.38 \
--with-zlib=/usr/local/zlib-1.2.11 \
--with-openssl=/usr/local/openssl-1.0.1t  

make && make install 

test -d

My understanding

This is the source code to compile and install nginx. The ./configure step is to set some constants for nginx. And --prefix sets the address of the nginx executable file after compilation.

Although there are some tutorials on the Internet, many of them are old and some packages can no longer be found. Then I will share my installation steps.

Install nginx to a custom location

Install pcre first

  cd /usr/local/
  # Download wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
  # Unzip tar -zxvf pcre-8.38.tar.gz

  cd pcre-8.38

  ./configure
  # Compile make && make install

  # Remember this installation directory, it will be used later# /usr/local/pcre-8.38

Next is zlib

  cd /usr/local/
  # Download wget http://www.zlib.net/zlib-1.2.11.tar.gz
  # Unzip tar -zxvf zlib-1.2.11.tar.gz

  cd zlib-1.2.11
  
  ./configure
  # Compile make && make install

  # Remember this installation directory, it will be used later# /usr/local/zlib-1.2.11

ssl This does not need to be compiled, it is simple

  cd /usr/local/
  wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
  tar -zxvf openssl-1.0.1t.tar.gz
  
  # Remember this installation directory, it will be used later# /usr/local/openssl-1.0.1t

Now install Nginx

  cd /usr/local
  #Download and decompress wget http://nginx.org/download/nginx-1.4.2.tar.gz
  tar -zxvf nginx-1.4.2.tar.gz
  # Note: This is only the source code cd nginx-1.4.2

  # Set constants ./configure \
  --prefix=/customlocation/\
  --sbin-path=/custom location/nginx \
  --conf-path=/custom location/nginx.conf \
  --pid-path=/custom location/nginx.pid \
  --with-http_ssl_module \
  --with-pcre=/usr/local/pcre-8.38 \ # The location of the pcre just installed --with-zlib=/usr/local/zlib-1.2.11 \ # The location of the zlib just installed --with-openssl=/usr/local/openssl-1.0.1t # The location of the openssl just installed # Compile make && make install

  # Important: If not executed, the real nginx file test -d will not be created

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Implementation of multi-port mapping of nginx reverse proxy
  • Nginx port mapping configuration method
  • How to set directory whitelist and IP whitelist in nginx
  • Solve the problem of "Welcome to nginx on Fedora!" after installing nginx on Centos7, and there is no default.conf file in the conf.d directory
  • Find the running nginx directory in Linux system
  • How to redirect nginx directory path
  • Detailed explanation of Vue deployment in subdirectories or secondary directories through NGINX
  • Nginx local directory mapping implementation code example

<<:  Quickly solve the problem that the mysql57 service suddenly disappeared

>>:  WeChat applet realizes multi-line text scrolling effect

Recommend

Detailed explanation of the principle of creating tomcat in Eclipse

When creating a tomcat server on a local eclipse,...

JavaScript Snake Implementation Code

This article example shares the specific code of ...

The process of quickly converting mysql left join to inner join

During the daily optimization process, I found a ...

Detailed explanation of primary keys and transactions in MySQL

Table of contents 1. Comments on MySQL primary ke...

MySQL should never write update statements like this

Table of contents Preface cause Phenomenon why? A...

js to achieve drag and drop sorting details

Table of contents 1. Introduction 2. Implementati...

Summary of Common Problems with Mysql Indexes

Q1: What indexes does the database have? What are...

How to simulate enumeration with JS

Preface In current JavaScript, there is no concep...

Detailed explanation of using split command to split Linux files

A few simple Linux commands let you split and rea...

Detailed explanation of MySQL transactions and MySQL logs

Transactional Characteristics 1. Atomicity: After...

A brief discussion on browser compatibility issues in JavaScript

Browser compatibility is the most important part ...

Various problems encountered by novices when installing mysql into docker

Preface Recently, my computer often takes a long ...

Example of how to adapt the Vue project to the large screen

A brief analysis of rem First of all, rem is a CS...