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

Summary of how JS operates on pages inside and outside Iframe

Table of contents Get the content of the iframe o...

Graphical tutorial on installing JDK1.8 under CentOS7.4

Linux installation JDK1.8 steps 1. Check whether ...

How to install PostgreSQL and PostGIS using yum on CentOS7

1. Update the yum source The PostgreSQL version o...

Summary of H5 wake-up APP implementation methods and points for attention

Table of contents Preface Jump to APP method URL ...

Native JS to achieve blinds special effects

This article shares a blinds special effect imple...

Detailed explanation of fs module and Path module methods in Node.js

Overview: The filesystem module is a simple wrapp...

How to optimize MySQL indexes

1. How MySQL uses indexes Indexes are used to qui...

How to view and close background running programs in Linux

1. Run the .sh file You can run it directly using...

How to modify server uuid in Mysql

Source of the problem: If the slave server is the...

How to install nginx under Linux

Nginx is developed in C language and is recommend...

Summary of MySQL development standards and usage skills

1. Naming conventions 1. Database names, table na...

Implementation of ssh non-secret communication in linux

What is ssh Administrators can log in remotely to...