Home  >  Article  >  Operation and Maintenance  >  Analysis of Nginx installation examples in Linux centos7 environment

Analysis of Nginx installation examples in Linux centos7 environment

王林
王林forward
2023-05-28 14:32:25930browse

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. Configure installation and run 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 to solve the problem (needs to be running under the network and Is the super administrator identity)

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

Linux centos7环境下Nginx安装实例分析

To switch to the root super administrator identity: su

Linux centos7环境下Nginx安装实例分析

Linux centos7环境下Nginx安装实例分析

Reconfigure now

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

If the reconfiguration fails, you need to install gcc

yum –y install gcc

Linux centos7环境下Nginx安装实例分析

After installing gcc, configure it again

Linux centos7环境下Nginx安装实例分析

5. Compile 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 the startup fails, it may be caused by a firewall problem

At this time 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 the command: nginx -s reload

Go to blog here 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 Analysis of Nginx installation examples 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