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 under Centos

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the knowledge of "how to install Nginx under Centos". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Nginx ("engine x") is a lightweight http and reverse proxy server. Compared with apache and lighttpd, it has the advantages of less memory, strong concurrency and high stability. Its most common use is to provide reverse proxy services.

Under linux we need to download the nginx source code package and compile it manually instead of using package management tools such as yum and aptitude to install it. Because we need to configure nginx at compile time, we have to compile manually, so we rely on some tools and library files.

First, you need to install the compilation environment for the c language, because nginx is written in the c language Usually most linux will install gcc by default, if not, you can install it as follows.

Install make:

Yum-y install gcc automake autoconf libtool make

Install the galleys:

Yum install gcc gcc-c++

Pcre Library:

Nginx requires pcre (perl compatible regular expression) because both nginx's rewrite module and the http core module use pcre regular expression syntax. The download address is, or we can install it through yum.

Yum install pcre pcre-devel

The above is the prompt that has been installed.

Zlib Library:

The zlib library provides compression algorithms, and the gzip algorithm is used in many parts of nginx. It can be downloaded from or installed through yum.

Yum install zlib zlib-devel

The above is not installed or is not the latest package.

Openssl:

In nginx, if the server provides secure pages, you need to use the openssl library. It can be downloaded from or installed through yum.

Yum install openssl openssl-devel

Download nginx:

The nginx source code package can be downloaded from the official website. The latest stable version is 1.10.1, and there is also a development version to choose from. The relevant commands are as follows:

Wget

Tar zxf nginx-1.10.1.tar.gz

Cd nginx-1.10.1/

Install nginx:

Configuration is required before installation, which is a common step in installing software under linux. The initial installation can directly use the configure script, if necessary, you can set the switch option to turn on the desired function module, so we will not expand it here. The relevant commands are as follows:

. / configure

Make

Make install

Run nginx:

Nginx will be installed by default in the / usr/local/nginx directory, we cd to the / usr/local/nginx/sbin/ directory, there is a nginx binary executable. You can start nginx by running directly. After running successfully, open a browser to access the ip of this machine, and the following screen indicates success.

Nginx related commands:

Nginx-h-> help command

Nginx-s stop-> stop the daemon immediately (term signal)

Nginx-s quit-> gently stop the daemon (quit signal)

Nginx-s reopen-> reopen the log file

Nginx-s reload-> reload the configuration file

Nginx-t-> Test whether the configuration file is legal

Killall nginx-> forcibly terminate the nginx process

Because any nginx command checks whether the configuration file is legal, and if the configuration file is illegal, the command will not be executed, and the killall command can avoid failing to stop the nginx service.

Nginx configuration files have their own unique syntax, so I won't expand them here.

This is the end of "how to install Nginx under Centos". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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