Home  >  Article  >  Operation and Maintenance  >  How to install and configure nginx for LNMP compilation and installation

How to install and configure nginx for LNMP compilation and installation

王林
王林forward
2023-05-13 22:22:18689browse

1. Foreword

This installation uses source code installation. The main resource package is downloaded from the official website, and the secondary dependencies are installed using yum. This article only involves the installation of nginx, not The configuration of nginx and how nginx accesses php are not covered in this article.

2. Installation steps

nginx

2.1. Download nginx

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

How to install and configure nginx for LNMP compilation and installation

##2.2 , Download the pcre installation package

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz

How to install and configure nginx for LNMP compilation and installation

This package does not need to be installed, it is just a medium

2.3. Unzip nginx and pcre

tar zxvf nginx-1.12.0.tar.gz

How to install and configure nginx for LNMP compilation and installation

tar zxvf pcre-8.39.tar.gz

How to install and configure nginx for LNMP compilation and installation

2.4. Install dependency packages

yum install -y gcc gcc-c++ zlib-devel

How to install and configure nginx for LNMP compilation and installation

2.5. Generate makefile

cd nginx-1.12.0

How to install and configure nginx for LNMP compilation and installation

./configure --prefix=/usr/local/nginx (installation directory) --with-pcre=../pcre-8.39/(pcre relative directory)

How to install and configure nginx for LNMP compilation and installation

The results are as follows:

How to install and configure nginx for LNMP compilation and installation

2.6. Compile and install

make && make install

How to install and configure nginx for LNMP compilation and installation

The results are as follows :

How to install and configure nginx for LNMP compilation and installation

The nginx installation is completed here

3. Start nginx

/usr/local/ nginx/sbin/nginx

Check the running status through ps aux|grep nginx

How to install and configure nginx for LNMP compilation and installation

At this point nginx will start normally.

4. Open port 80 for external access

If you only run it without opening the port, the browser will not be able to access it.

firewall-cmd --zone=public --add-port=80/tcp --permanent

How to install and configure nginx for LNMP compilation and installation

Successfully opened port 80

You need to restart the firewall to open the play port

systemctl restart firewalld.service

How to install and configure nginx for LNMP compilation and installation

Go here , you can re-open the browser and access

How to install and configure nginx for LNMP compilation and installation

Access the browser, and the above interface appears, which means that nginx has been installed.

The above is the detailed content of How to install and configure nginx for LNMP compilation and installation. 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