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

How to install Nginx server under CentOS7

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to install Nginx server under CentOS7" related knowledge, editor through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope that this "how to install Nginx server under CentOS7" article can help you solve the problem.

Environment required for installation

Nginx is a c language development, it is recommended to run on linux, of course, you can also install the windows version, this article uses centos 7 as the installation environment.

one。 Gcc installation

To install nginx, you need to compile the source code downloaded from the official website. The compilation depends on the gcc environment. If there is no gcc environment, you need to install:

Yum install gcc-c++

two。 Pcre pcre-devel installation

Pcre (perl compatible regular expressions) is a perl library, including a perl-compatible library of regular expressions. Nginx's http module uses pcre to parse regular expressions, so you need to install the pcre library on linux. Pcre-devel is a secondary development library developed using pcre. This library is also required for nginx. Command:

Yum install-y pcre pcre-devel

three。 Zlib installation

The zlib library provides many ways to compress and decompress. Nginx uses zlib to gzip the contents of the http package, so you need to install the zlib library on centos.

Yum install-y zlib zlib-devel

four。 Openssl installation

Openssl is a powerful secure socket layer cipher library that includes major cryptographic algorithms, commonly used key and certificate encapsulation management functions, and ssl protocols, and provides rich applications for testing or other purposes.

Nginx supports not only the http protocol, but also https (that is, http over the ssl protocol), so you need to install the openssl library on centos.

Yum install-y openssl openssl-devel

Download from the official website

1. Download the .tar.gz installation package directly at:

two。 Download using the wget command (recommended).

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

I downloaded version 1.10.1, which is the current stable version.

Decompression

It's still a direct order:

Tar-zxvf nginx-1.10.1.tar.gzcd nginx-1.10.1

Configuration

In fact, in the nginx-1.10.1 version, you don't need to configure related things, just default. Of course, it's OK if you want to configure the directory yourself.

1. Use default configuration

. / configure

two。 Custom configuration (not recommended)

. / configure\-- prefix=/usr/local/nginx\-- conf-path=/usr/local/nginx/conf/nginx.conf\-- pid-path=/usr/local/nginx/conf/nginx.pid\-- lock-path=/var/lock/nginx.lock\-- error-log-path=/var/log/nginx/error.log\-- http-log-path=/var/log/nginx/access.log\-- with-http_gzip_static_module\-- http-client-body- Temp-path=/var/temp/nginx/client\-http-proxy-temp-path=/var/temp/nginx/proxy\-http-fastcgi-temp-path=/var/temp/nginx/fastcgi\-http-uwsgi-temp-path=/var/temp/nginx/uwsgi\-http-scgi-temp-path=/var/temp/nginx/scgi

Note: to specify the temporary file directory as / var/temp/nginx, you need to create temp and nginx directories under / var

Compilation and installation

Makemake install

Find the installation path:

Whereis nginx

Start and stop nginx

Cd / usr/local/nginx/sbin/

. / nginx

. / nginx-s stop

. / nginx-s quit

. / nginx-s reload

. / nginx-s quit: in this way, the stop step is to stop after the nginx process has finished processing the task.

. / nginx-s stop: this method is equivalent to finding out the nginx process id and then using the kill command to force the killing of the process.

Query the nginx process:

Ps aux | grep nginx

Restart nginx

1. Stop and then start (recommended):

Restarting nginx is equivalent to stopping and then starting, that is, executing the stop command before the startup command. As follows:

. / nginx-s quit./nginx

two。 Reload the configuration file:

When nginx's configuration file nginx.conf is modified, you need to restart nginx for the configuration to take effect. You can use-s reload to take effect in nginx without first stopping nginx and then starting nginx, as shown below:

. / nginx-s reload

After launching successfully, you can see a page like this in the browser:

Boot self-start

That is, add the startup code to rc.local.

Vi / etc/rc.local

Add one line / usr/local/nginx/sbin/nginx

Set execution permissions:

Chmod 755 rc.local

This is the end of the introduction on "how to install Nginx server under CentOS7". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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

Internet Technology

Wechat

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

12
Report