Example of a method for installing nginx to a specified directory
The company needs to install nginx in two different locations on the same machine. What! I used to install it directly under / user/local/, or yum install nginx installed in / etc/nginx, what should I do?
After a lot of searching, I finally saw some reliable answers.
. / configure\-- prefix= directory you want to install\-- 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 ngixn,./configure this step is to set some constants for nginx. And-- prefix is to set the address of the nginx execution file everywhere after compilation.
Now, although there are some tutorials on the Internet, many of them are old and some packages can't be found. Then I will share the steps of my installation.
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 # extract tar-zxvf pcre-8.38.tar.gz cd pcre-8.38. / configure # compile make & & make install # remember that this installation directory will use # / usr/local/pcre-8.38 later
The second is zlib.
Cd / usr/local/ # download wget http://www.zlib.net/zlib-1.2.11.tar.gz # extract tar-zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11. / configure # compile make & & make install # remember that this installation directory will use # / usr/local/zlib-1.2.11 later
Ssl doesn't need to be compiled. It's 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 that this installation directory will use # / usr/local/openssl-1.0.1t later
Install Nginx now
Cd / usr/local # download decompress wget http://nginx.org/download/nginx-1.4.2.tar.gz tar-zxvf nginx-1.4.2.tar.gz # Note: this is just the source code cd nginx-1.4.2 # setting constant. / configure\-- prefix=/ custom location /-- 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\ # location of pcre just installed-with-zlib=/usr/local/zlib-1.2.11\ # location of zlib just installed-with-openssl=/usr/local/openssl-1.0.1t # just installed The location of the openssl # compile make & & make install # important: if it is not executed, the real nginx file test-d will not be created
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.