Experience example of Setting up nginxweb service for Aliyun centos7 server

  • 2020-06-19 12:17:45
  • OfStack

(1) After the purchase of centos7 server, 1 must enter the security group rules in the management console of Aliyun, enter the direction, add security group rules, open port 80, and authorize the object to fill in 0.0.0.0/0 to authorize all ipv4 addresses. Remember, I just didn't do this, then all sorts of firewall open 80 port, then browser 1 straight still can't access.

(2) Download and install Nginx:

Download:


wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

Install nginx's dependency libraries:

Installation of gcc (usually comes with 1, no need to install again) :


yum install gcc-c++  # Note: gcc -v Check to see if it is installed gcc version 

Install pcre ES22en-ES23en:


yum install -y pcre pcre-devel

Install zlib zlib-ES29en:


yum install -y zlib zlib-devel

Install openssl:


yum install -y openssl openssl-devel

Extract:


tar -zxvf nginx-1.10.1.tar.gz

Compile and install:


cd nginx-1.10.1
./configure --prefix=/usr/local/nginx    # (You can customize other configuration options) 
make
make install

(3) Open port 80 of the firewall

The firewall under centos7 no longer USES /etc/sysconfig/iptables, but firewall.

1. Check whether port 80 is open:


firewall-cmd --query-port=80/tcp

If prompted FirewallD is not running
Represents an unknowable firewall that needs to be checked for status and turned on

2. Check the firewall status:


systemctl status firewalld

The running state is when the firewall is on
The dead state means that the firewall is not on

3. Open the firewall:


systemctl start firewalld

4. Open permanent port number 80:


yum install gcc-c++  # Note: gcc -v Check to see if it is installed gcc version 
0

5. Reload configuration:


yum install gcc-c++  # Note: gcc -v Check to see if it is installed gcc version 
1

6. Check again whether the intended port is open:


yum install gcc-c++  # Note: gcc -v Check to see if it is installed gcc version 
2

Prompt yes indicates success

(4) Start nginx:


cd /usr/local/nginx

You can modify the configuration file as needed./conf/ ES95en.conf (make a backup before modification to avoid error correction)


yum install gcc-c++  # Note: gcc -v Check to see if it is installed gcc version 
4

Start according to the configuration file:


yum install gcc-c++  # Note: gcc -v Check to see if it is installed gcc version 
5

Check to see if nginx started successfully:


yum install gcc-c++  # Note: gcc -v Check to see if it is installed gcc version 
6

(5) Enter the corresponding server IP in the browser and the interface of welcome to nginx will appear.


Related articles: