Centos7 install Nginx

Introduction

Nginx (pronounced the same as engine x) is an asynchronous framework web server, which can also be used as a reverse proxy, load balancer and HTTP cache . The software was created by Igor Sysoev and was first publicly released in 2004. The company of the same name was established in 2011 to provide support.

Compile and install method

  1. Install gcc gcc is used to compile the downloaded nginx source code
yum install gcc-c++
  1. Install pcre and pcre-devel

PCRE (Perl Compatible Regular Expressions) is a Perl library, including Perl compatible regular expression libraries.
The http module of nginx uses pcre to parse regular expressions, and pcre-devel is a secondary development library developed using pcre.

yum install -y pcre pcre-devel
  1. Install zlib zlib provides many compression and decompression methods, nginx needs zlib to gzip http.
yum install -y zlib zlib-devel
  1. Install openssl openssl is a secure socket layer cryptographic library, nginx must support https, and openssl is required.
yum install -y openssl openssl-devel
  1. Download nginx
wget http://nginx.org/download/nginx-1.9.9.tar.gz
  1. Unzip
tar -zxvf nginx-1.9.9.tar.gz
  1. cd to file path

  2. Compile

. /configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module
  1. installation
make && make install
  1. start up
nginx -c /etc/nginx/nginx.conf
  1. If there is a [emerg] getpwnam("nginx") failed error execution
useradd -s /sbin/nologin -M nginx
id nginx
  1. If there is an error of [emerg] mkdir() "/var/temp/nginx/client" failed (2: No such file or directory)
sudo mkdir -p /var/tem/nginx/client
  1. If you are running a firewall, run the following command to allow HTTP and HTTPS communication:
sudo firewall-cmd --permanent --zone=public--add-service=http 
sudo firewall-cmd --permanent --zone=public--add-service=https
sudo firewall-cmd --reload

yum installation method

  1. Add Nginx repository

To add CentOS 7 EPEL repository, open a terminal and use the following command:

sudo yum install epel-release
  1. Install Nginx

Now that the Nginx repository has been installed on your server, use the following yum command to install Nginx:

sudo yum install nginx

After answering yes to the prompt, Nginx will complete the installation on the server.

  1. Start Nginx

Nginx will not start by itself. To run Nginx, enter:

sudo systemctl start nginx

If you are running a firewall, run the following command to allow HTTP and HTTPS communication:

sudo firewall-cmd --permanent --zone=public--add-service=http 
sudo firewall-cmd --permanent --zone=public--add-service=https
sudo firewall-cmd --reload

If you want to enable Nginx at system startup. Please enter the following command:

sudo systemctl enable nginx

Recommended Posts

Centos7.3 install nginx
Centos7 install Nginx
1.5 Install Centos7
CentOs7.3 compile and install Nginx 1.9.9
Tencent Cloud Centos install nginx
Install Nginx server on CentOS 7
Centos6 install Python2.7.13
CentOS7.2 install Mysql5.7.13
CentOS install Redmine
Centos7 install Python 3.6.
CentOS7 install MySQL
Centos7 install protobuf
CentOS 7 install Docker
CentOS 7 install Nginx, PHP, MySQL packages
CentOS7 install GlusterFS
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
CentOS install Python 3.6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Centos7 install Python2.7
CentOS 6.x compile and install Nginx
Centos 7.6 install seleniu
How to install Nginx on CentOS 8
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install mysql
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
CentOS6 install mist.io
CentOS7 install mysql
CentOS 7 install MySQL 5.6
CentOS6.5 install CDH5.13
Centos7 install docker18
Centos install Python3
centos7 install docker
CentOS install jdk
centos7 install nginx-rtmp
CentOS8 install MySQL8.0
Centos6.3 install KVM
CentOS install PostgreSQL 9.1
CentOS7 install mysql8
CentOS 7 install Java 1.8
CentOS8 install fastdfs6.06
CentOS 7 install Gitlab
Centos 7 install PostgreSQL
CentOS7 install MySQL8
CentOS 7 install Java 1.8
Centos install php73 fast cgi + nginx
CentOS 6 install Docker
centos 6.5 install zabbix 4.4
Centos8 install Docker
CentOS6.8 install python2.7
CentOS install nodejs 8
CentOS6.5 install GNS3
centos 7.5 install mysql5.7.17
Centos7 install MySQL8.0-manual
CentOS7 install Kubernetes 1.16.3