Home  >  Article  >  Operation and Maintenance  >  How to install Nginx in Linux centos7 environment

How to install Nginx in Linux centos7 environment

王林
王林forward
2023-05-19 17:55:061703browse

Detailed explanation of the steps to install nginx under linux centos7 environment

1. First go to the nginx official website to download the nginx installation package

After downloading, you will see a file similar to the following

Linux centos7环境下如何安装Nginx

Create the nginx-src directory and go to the nginx-src directory and run the following command:

mkdir nginx-src && cd nginx-src

Of course, you can also run the following command under Linux to download the nginx installation package

wget http://nginx.org/download/nginx-1.5.9.tar.gz

Linux centos7环境下如何安装Nginx

2. Unzip the nginx-1.5.9.tar.gz file

tar -zxvf nginx-1.5.9.tar.gz

Linux centos7环境下如何安装Nginx

3. Delete the installation package File command

rm -f nginx-1.5.9.tar.gz

Linux centos7环境下如何安装Nginx

4. Configuration, installation and running command

cd nginx-1.5.9/

./configure --prefix=/usr/local/nginx

Linux centos7环境下如何安装Nginx

Maybe prompts missing package:

./configure: error: the http rewrite module requires the pcre library.

you can either disable the module by using --without-http_rewrite_module

option, or install the pcre library into the system, or build the pcre library

statically from the source with nginx by using --with-pcre=98953a78f52873edae60a617ec082494 option.

install pcre-devel solves the problem (needs to run under the network and be the super administrator)

yum -y install pcre-devel
yum -y install openssl openssl-devel

Linux centos7环境下如何安装Nginx

To switch to the root super administrator: su

Linux centos7环境下如何安装Nginx

Linux centos7环境下如何安装Nginx

Reconfigure now

./configure --prefix=/usr/local/nginx

If the reconfiguration is unsuccessful, you need to install gcc

yum –y install gcc

Linux centos7环境下如何安装Nginx

Configure again after installing gcc

Linux centos7环境下如何安装Nginx

5 , Compilation command

make

Linux centos7环境下如何安装Nginx

6. Installation command

make install

Linux centos7环境下如何安装Nginx

##7. After installation, start nginx

cd /usr/local/nginx/sbin

./nginx

Linux centos7环境下如何安装Nginx

If started Failure may be caused by firewall problems

At this time, you need to turn off the firewall

systemctl stop firewalld.service

Linux centos7环境下如何安装Nginx

8. Visit nginx

http://ip address

Linux centos7环境下如何安装Nginx

9. If you want to streamline the configuration file

Reload the configuration file

Run Command: nginx -s reload

Up to here blogger, I have successfully installed the nginx server

under linux centos7 and have successfully accessed nginx through the IP address on the browser.

The above is the detailed content of How to install Nginx in Linux centos7 environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete