1. Install the preinstalled environment (compile environment and dependent libraries)

1) the GCC installed

GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC GCC Run the GCC -version command to check whether the installation is complete.

yum install gcc-c++

2) PCRE installation

PCRE(Perl Compatible Regular Expressions) is a Perl library that includes the Perl-compatible normal expression library. Nginx’s HTTP module uses PCRE to parse regular expressions, so you need to install the PCRE library on Linux.

yum install -y pcre pcre-devel

3) zlib installation

The Zlib library provides a variety of compression and decompression methods. Nginx uses Zlib to gzip the contents of HTTP packages, so you need to install the Zlib library on Linux.

yum install -y zlib zlib-devel

4) the openssl installation

OpenSSL is a powerful secure Socket layer cryptographic library that includes major cryptographic algorithms, common key and certificate encapsulation management capabilities, and SSL protocols, and provides rich applications for testing and other purposes. Nginx supports both HTTP and HTTPS (that is, HTTP over SSL), so you need to install the OpenSSL library on Linux.

yum install -y openssl openssl-devel

2 install nginx

To avoid errors, install as root

1) Get nginx source code locally

Wget -c https://nginx.org/download/nginx-1.12.1.tar.gz

2) decompression

The tar – ZXVF nginx – 1.12.1. Tar. Gz

3) configuration

Go to the decompressed folder (CD nginx-1.12.1) and run the./configure command. Such as:

When you install the PRCE library, execute./configure again, and you may be reminded of the missing libraries. To avoid errors, make sure all dependent libraries are installed

4) Install the RTMP module

A. To add support for RTMP, download nginx-rtmp-module

B. decompression

C. Reconfigure./configure — add-module=/usr/local/nginx-rtmp-module-master

–add-module= decompressed path + file name

5) to compile

make

6) the installation

 make install

7) Start nginx

Nginx in the installation directory /sbin is the nginx execution file

Whereis nginx (First check where nginx is installed)

Run the /usr/local/nginx command to run the /usr/local/nginx command.

CD sbin (go to the /sbin directory)

/nginx (start nginx, fail root mode)

8) Verify that the installation is successful

In the web page input url: http://yourIP/index.html (such as 123.12.456.789 / index. HTML)

Or you don’t check your IP, change the IP to localhost, too, that is http://localhost/index.html

Or enter your OWN IP address

If the following information is displayed, the installation is successful

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.

Commercial support is available at nginx.com.

Thank you for using nginx.

9) LAN implementation

When you are successful in the local computer you may want to try other computers can access, so the Internet computer input just the URL, found it did not work, the reason is the firewall problem, so configure the firewall, open port 80, the command is as follows

A) centos6.5

Vi /etc/sysconfig/iptables -A INPUT -m state -state NEW -m TCP -p TCP -dport 80 -j ACCEPT

service iptables save 

iptables restart 

You can also use iptables firewall, which is available online, or use centos7 firewall

Open port

Firewall-cmd –zone=public –add-port=80/ TCP — permanent

Firewall-cmd –reload (Restart the firewall)

10) added:

To stop the nginx service:./nginx -s quit

To restart the nginx service:./nginx -s reload