Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the steps to install nginx under CentOS 7.4

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the steps of installing nginx under CentOS 7.4. the content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Install the software that nginx depends on

Nginx is written in C and needs to be compiled in GCC; rewrite module in nginx requires gzip module in PCRE;nginx and HTTP SSL module in zlib;nginx requires OpenSSL.

The installed GCC version information is as follows:

[root@VM_2_13_centos] # gcc-v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper

Target: x86_64-redhat-linux

Configured with:.. / configure-- prefix=/usr-- mandir=/usr/share/man-- infodir=/usr/share/info-- with-bugurl= http://bugzilla.redhat.com/bugzilla-- enable-bootstrap-enable-shared-- enable-threads=posix-- enable-checking=release-- with-system-zlib-- enable-__cxa_atexit-- disable-libunwind-exceptions-- enable-gnu-unique-object-- enable-linker-build-id-- with-linker-hash-style=gnu-- enable-languages=c,c++,objc,obj-c++,java Fortran,ada,go,lto-enable-plugin-enable-initfini-array-disable-libgcj-with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install-with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install-enable-gnu-indirect-function-with-tune=generic-with-arch_32=x86 64-build=x86_64-redhat-linux

Thread model: posix

Gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)

1. Zlib source code installation:

Zlib download official website: http://www.zlib.net/

Download the latest zlib version 1.2.11 source code:

[root@VM_2_13_centos stalker] # wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.11.tar.gz

Extract and enter the zlib code root directory:

[root@VM_2_13_centos stalker] # tar zxvf zlib-1.2.11.tar.gz

[root@VM_2_13_centos stalker] # cd zlib-1.2.11

Configure, compile, install:

[root@VM_2_13_centos zlib-1.2.11] #. / configure

[root@VM_2_13_centos zlib-1.2.11] # make

[root@VM_2_13_centos zlib-1.2.11] # make install

Rm-f / usr/local/lib/libz.a

Cp libz.a / usr/local/lib

Chmod 644 / usr/local/lib/libz.a

Cp libz.so.1.2.11 / usr/local/lib

Chmod 755 / usr/local/lib/libz.so.1.2.11

Rm-f / usr/local/share/man/man3/zlib.3

Cp zlib.3 / usr/local/share/man/man3

Chmod 644 / usr/local/share/man/man3/zlib.3

Rm-f / usr/local/lib/pkgconfig/zlib.pc

Cp zlib.pc / usr/local/lib/pkgconfig

Chmod 644 / usr/local/lib/pkgconfig/zlib.pc

Rm-f / usr/local/include/zlib.h / usr/local/include/zconf.h

Cp zlib.h zconf.h / usr/local/include

Chmod 644 / usr/local/include/zlib.h / usr/local/include/zconf.h

[root@VM_2_13_centos zlib-1.2.11] # whereis zlib

Zlib: / usr/include/zlib.h / usr/share/man/man3/zlib.3.gz

2. PCRE source code installation:

PCRE official website: http://www.pcre.org/

Download the latest version of PCRE 8.41 source code:

[root@VM_2_13_centos stalker] # wget http://downloads.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz

Extract and enter the PCRE code root directory:

[root@VM_2_13_centos stalker] # tar zxvf pcre-8.41.tar.gz

[root@VM_2_13_centos stalker] # cd pcre-8.41

Configure, compile, install:

[root@VM_2_13_centos pcre-8.41] #. / configure

[root@VM_2_13_centos pcre-8.41] # make

[root@VM_2_13_centos pcre-8.41] # make install

View the version:

[root@VM_2_13_centos pcre-8.41] # pcre-config-- version

8.41

Indicates that the installation was successful.

3. OpenSSL source code installation:

OpenSSL official website: https://www.openssl.org/

Download the OpenSSL version 1.0.2n source code:

[root@VM_2_13_centos stalker] # wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz

Extract and enter the openssl code root directory:

[root@VM_2_13_centos stalker] # tar zxvf openssl-1.0.2n.tar.gz

[root@VM_2_13_centos stalker] # cd openssl-1.0.2n

Configure, compile, install:

[root@VM_2_13_centos openssl-1.0.2n] #. / config

[root@VM_2_13_centos openssl-1.0.2n] # make

[root@VM_2_13_centos openssl-1.0.2n] # make install

2. Install nginx with source code

Download the latest stable version of nginx 1.12.2 source code:

[root@VM_2_13_centos stalker] # wget wget http://nginx.org/download/nginx-1.12.2.tar.gz

Extract and enter the nginx code root directory:

[root@VM_2_13_centos stalker] # tar zxvf nginx-1.12.2.tar.gz

[root@VM_2_13_centos stalker] # cd nginx-1.12.2

Configuration:

[root@VM_2_13_centos nginx-1.12.2] # / configure-- with-http_ssl_module-- with-pcre=../pcre-8.41-- with-zlib=../zlib-1.2.11

The correct information after. / configure is as follows:

Configuration summary

+ using PCRE library:.. / pcre-8.41

+ using system OpenSSL library

+ using zlib library:.. / zlib-1.2.11

Nginx path prefix: "/ usr/local/nginx"

Nginx binary file: "/ usr/local/nginx/sbin/nginx"

Nginx modules path: "/ usr/local/nginx/modules"

Nginx configuration prefix: "/ usr/local/nginx/conf"

Nginx configuration file: "/ usr/local/nginx/conf/nginx.conf"

Nginx pid file: "/ usr/local/nginx/logs/nginx.pid"

Nginx error log file: "/ usr/local/nginx/logs/error.log"

Nginx http access log file: "/ usr/local/nginx/logs/access.log"

Nginx http client request body temporary files: "client_body_temp"

Nginx http proxy temporary files: "proxy_temp"

Nginx http fastcgi temporary files: "fastcgi_temp"

Nginx http uwsgi temporary files: "uwsgi_temp"

Nginx http scgi temporary files: "scgi_temp"

If. / configure prompts OpenSSL that it cannot be found:

Checking for OpenSSL library... Not found

Checking for OpenSSL library in / usr/local/... Not found

Checking for OpenSSL library in / usr/pkg/... Not found

Checking for OpenSSL library in / opt/local/... Not found

. / configure: error: SSL modules require the OpenSSL library.

You can either do not enable the modules, or install the OpenSSL library

Into the system, or build the OpenSSL library statically from the source

With nginx by using-- with-openssl= option.

Follow the instructions,-- with-openssl=.

[root@VM_2_13_centos nginx-1.12.2] # / configure-- with-http_ssl_module-- with-pcre=../pcre-8.41-- with-zlib=../zlib-1.2.11-- with-openssl=../openssl-1.0.2n

The configuration is correct, and the information is as follows:

Configuration summary

+ using PCRE library:.. / pcre-8.41

+ using OpenSSL library:.. / openssl-1.0.2n

+ using zlib library:.. / zlib-1.2.11

Nginx path prefix: "/ usr/local/nginx"

Nginx binary file: "/ usr/local/nginx/sbin/nginx"

Nginx modules path: "/ usr/local/nginx/modules"

Nginx configuration prefix: "/ usr/local/nginx/conf"

Nginx configuration file: "/ usr/local/nginx/conf/nginx.conf"

Nginx pid file: "/ usr/local/nginx/logs/nginx.pid"

Nginx error log file: "/ usr/local/nginx/logs/error.log"

Nginx http access log file: "/ usr/local/nginx/logs/access.log"

Nginx http client request body temporary files: "client_body_temp"

Nginx http proxy temporary files: "proxy_temp"

Nginx http fastcgi temporary files: "fastcgi_temp"

Nginx http uwsgi temporary files: "uwsgi_temp"

Nginx http scgi temporary files: "scgi_temp"

Compile and install:

[root@VM_2_13_centos nginx-1.12.2] # make

[root@VM_2_13_centos nginx-1.12.2] # make install

Check the correctness of the nginx.conf configuration:

[root@VM_2_13_centos] # / usr/local/nginx/sbin/nginx-t

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

Start nginx:

[root@VM_2_13_centos ~] # / usr/local/nginx/sbin/nginx

Enter the host IP address in the browser and see the following page indicating that nginx is installed successfully

Nginx is added to boot and starts automatically

Edit the system startup script vim / etc/rc.local first. This file is automatically executed after the system starts, so we will add the startup command to this file.

[root@VM_2_13_centos ~] # vim / etc/rc.local

/ usr/local/nginx/sbin/nginx-c / usr/local/nginx/conf/nginx.conf & > / tmp/nginx.log 2 > & 1

View the progress of nginx

[root@VM_2_13_centos ~] # ps-ef | grep nginx

Root 16976 16360 0 18:03 pts/2 00:00:00 grep-color=auto nginx

Root 25192 1 0 13:25? 00:00:00 nginx: master process / usr/local/nginx/sbin/nginx

Nobody 25769 25192 0 13:37? 00:00:00 nginx: worker process

Modify global environment variables

[root@VM_2_13_centos ~] # vim / etc/profile

Export PATH=$PATH:/usr/local/mysql/bin:/usr/local/nginx/sbin

Default installation location of Nginx

/ usr/local/nginx

Configuration file for / usr/local/nginx/conf/nginx.conf / / nginx

/ usr/local/nginx/html / / default web page file

Related connections:

CentOS 7.4 build LNMP (Linux+Nginx+MySQL+PHP):

Https://blog.csdn.net/u014558668/article/details/79314878

CentOS 7.4 install PHP 5.4.16 using yum source

Https://blog.csdn.net/u014558668/article/details/79315641

Install mongodb and php extension mongodb under CentOS 7:

Https://blog.csdn.net/username11211/article/details/52945488

Install php-redis extension and easy to use under CentOS 7:

Https://blog.csdn.net/baidu_30000217/article/details/51481138

On CentOS 7.4 what is the steps to install nginx is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report