Example of how to configure nginx in centos server

Example of how to configure nginx in centos server

Download the secure terminal MobaXterm_Personal

First, download the secure terminal and connect to your public IP.

After the connection is successful, the display is as above.

Introduction to Nginx

Nginx is a lightweight web server and reverse proxy server. Compared with Apache and lighttpd, it has the advantages of less memory usage and higher stability. Its most common use is to provide reverse proxy services

After connecting to the server

Step 1: Install gcc gcc-c++

The command is:

yum install -y gcc gcc-c++

Step 2: Install the PCRE library

$ cd /usr/local/
$ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
$ tar -zxvf pcre-8.36.tar.gz
$ cd pcre-8.36
$ ./configure
$ make && make install

If an error is reported: configure: error: You need a C++ compiler for C++ support

Solution: yum install -y gcc gcc-c++

Step 3: Install SSL library

$ cd /usr/local/
$ wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
$ tar -zxvf openssl-1.0.1j.tar.gz
$ cd openssl-1.0.1j
$ ./config
$ make && make install

Step 4: Install zlib library

$ cd /usr/local/
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxvf zlib-1.2.11.tar.gz
$ ./configure
$ make && make install

Step 5: Install nginx

$ cd /usr/local/
$ wget http://nginx.org/download/nginx-1.8.0.tar.gz
$ tar -zxvf nginx-1.8.0.tar.gz
$ cd nginx-1.8.0 
$ ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module
(Note: If you do not add --with-http_ssl_module: after configuring ssl: on in nginx.conf, the startup will report nginx: [emerg] unknown directive "ssl" in /opt/nginx/conf/nginx.conf exception)
$ make && make install

Start nginx

$ /usr/local/nginx/sbin/nginx

Step 6: Check whether the startup is successful

Open the browser and access the IP address of this machine. If the browser displays Welcome to nginx!, it means that Nginx has been installed and is running successfully.

Here are some things I encountered during this process:

When I reached step 6, the connection with the browser was unsuccessful and no response appeared, so I checked whether port 80 of the firewall was open.

The command is:

firewall-cmd --list-all Check port 80

firewall-cmd --zone=public --add-port=80/tcp If port 80 is not open, open port 80

firewall-cmd --reload Re-enable the firewall

Restart the nginx service again:

/usr/local/nginx/sbin/nginx –s reload

If you still cannot connect to this IP address, check whether the local connection is normal:

The command is:

curl localhost 

As shown in the picture, the local connection is successful, but the IP is inaccessible

Finally, I checked and found that it was because the Alibaba Cloud security group only opened ports 22 and 3389 for the new server, but not port 80.

Only these two port numbers are not enough. In order to connect to the server, port 80 needs to be opened.

Add configuration rules for security groups

Since we are using Alibaba Cloud, we can use Alibaba Cloud's security group operations to achieve the port opening effect.

After logging in to Alibaba Cloud, select in the following order: Cloud Server ECS->Security Group->Configuration Rules

There are currently three security group rules, namely 22, 3389 and ICMP protocols.

Then click Add Security Group Rules in the upper right corner.

Add port 80

As shown in the figure, only two changes are needed:

Port range: 21/21 means starting from 21 and ending at 21

Authorization object: 0.0.0.0/0 means all IP addresses can access this port

As shown in the figure, a new rule is added

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:
  • CentOS+Nginx+PHP+MySQL detailed configuration (illustration)
  • CentOS 6.4 installation and configuration of LNMP server (Nginx+PHP+MySQL)
  • Install and configure Nginx on CentOS 7
  • CentOS+Nginx+PHP+MySQL standard production environment configuration method
  • How to install and configure Nginx on CentOS 6.3
  • Deploy nginx, php (including fastcgi), and virtual host configuration in CentOS 6.1 environment
  • Tutorial on configuring Nginx+Gunicorn+Python+Flask environment on CentOS
  • Compile, install and configure Nginx+PHP+MySql environment under Centos7
  • CentOS7 configuration Nginx support HTTPS access implementation solution
  • How to configure Nginx, MySql, and php-fpm on CentOS6
  • Detailed explanation of configuring Nginx auto-start based on CentOS 7
  • How to install Nginx in CentOS7 and configure automatic startup

<<:  A brief comparison of Props in React

>>:  Tutorial on configuring and changing passwords for the MySQL free installation version

Recommend

Some problems that may be caused by inconsistent MySQL encoding

Stored procedures and coding In MySQL stored proc...

Three strategies for rewriting MySQL query statements

Table of contents Complex query and step-by-step ...

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

Preface In WeChat applet development (native wxml...

Example code for css flex layout with automatic line wrapping

To create a flex container, simply add a display:...

How to check PCIe version and speed in Linux

PCIE has four different specifications. Let’s tak...

Some problems you may encounter when installing MySQL

Question 1: When entering net start mysql during ...

TypeScript interface definition case tutorial

The role of the interface: Interface, in English:...

Vue template compilation details

Table of contents 1. parse 1.1 Rules for intercep...

A magical MySQL deadlock troubleshooting record

background Speaking of MySQL deadlock, I have wri...

Django uses pillow to simply set up verification code function (python)

1. Import the module and define a validation stat...

In-depth analysis of the diff algorithm in React

Understanding of diff algorithm in React diff alg...

Quickly master the use of Docker to build a development environment

As the platform continues to grow, the project...

Three.js sample code for implementing dewdrop animation effect

Preface Hello everyone, this is the CSS wizard - ...

Detailed introduction to Mysql date query

Query the current date SELECT CURRENT_DATE(); SEL...