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

Vue.js implements tab switching and color change operation explanation

When implementing this function, the method I bor...

If I change a property randomly in Vue data, will the view be updated?

Interviewer: Have you read the source code of Vue...

Summary of the understanding of virtual DOM in Vue

It is essentially a common js object used to desc...

Installing the ping tool in a container built by Docker

Because the Base images pulled by Docker, such as...

Let you understand the working principle of JavaScript

Table of contents Browser kernel JavaScript Engin...

How to add Nginx proxy configuration to allow only internal IP access

location / { index index.jsp; proxy_next_upstream...

What does href=# mean in a link?

Links to the current page. ------------------- Com...

nginx solves the problem of slow image display and incomplete download

Written in front Recently, a reader told me that ...

WeChat applet example of using functions directly in {{ }}

Preface In WeChat applet development (native wxml...

CocosCreator classic entry project flappybird

Table of contents Development Environment Game en...

jQuery achieves the effect of advertisement scrolling up and down

This article shares the specific code of jQuery t...

5 issues you should pay attention to when making a web page

1. Color matching problem <br />A web page s...

Zookeeper stand-alone environment and cluster environment construction

1. Single machine environment construction# 1.1 D...