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 in a lnmp environment

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How do I install nginx in a lnmp environment? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

First, you need to install the dependency modules pcre, zlib, and openssl.

Gzip module requires zlib library

Rewrite module requires pcre library

Openssl library is required for ssl function

1. Install pcre dependencies

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

Decompress tar-zxvf pcre-8.38.tar.gz

Go to the unzip directory cd your directory / pcre-8.38

Compile. / configure-- prefix=/opt/project/pcre # specify the installation directory

Install make & & make install after compilation is complete

two。 Install zlib dependencies

Download zlib-1.2.11 wget http://zlib.net/zlib-1.2.11.tar.gz

Decompress tar-zxvf zlib-1.2.11.tar.gz

Go to the unzip directory cd your directory / zlib-1.2.11

Compile. / configure-- prefix=/opt/project/zlib # specify the installation directory

Install make & & make install after compilation is complete

3. Install openSSL dependencies

Download openssl-1.1.1-pre5 wget https://www.openssl.org/source/openssl-1.1.1-pre5.tar.gz

Decompress tar-zxvf openssl-1.1.1-pre5.tar.gz

Go to the unzip directory cd your directory / openssl-1.1.1-pre5

Compile. / configure-- prefix=/opt/project/openssl # specify the installation directory

Install make & & make install after compilation is complete

4. Install the nginx service

Manually create nginx users and user groups

Groupadd nginx

Useradd nginx-g nginx-s / sbin/nologin-M

Download wget http://nginx.org/download/nginx-1.14.0.tar.gz

Decompress tar-zxvf nginx-1.14.0.tar.gz

Compile

. / configure-- prefix=/opt/project/nginx-1.14 # nginx installation location

-- sbin-path=/opt/project/nginx-1.14/sbin/nginx # sets the path to the nginx executable file

-- conf-path=/opt/project/nginx-1.14/config/nginx.conf # sets the path of nginx configuration file

-- pid-path=/opt/project/nginx-1.14/logs/nginx.pid # set up the nginx.pid file

-- error-log-path=/opt/project/nginx-1.14/logs/error.log # sets the name of the primary error, warning, and diagnostic file

-- lock-path=/opt/project/nginx-1.14/logs/nginx.log\

-- http-log-path=/opt/project/nginx-1.14/logs/access.log # sets the name of the log file of the main requested HTTP server

-- with-http_ssl_module

-- user=nginx\

-- group=nginx\

-- with-pcre=/var/software/nginx/pcre-8.38 # refers to the source path of pcre

-- with-zlib=/var/software/nginx/zlib-1.2.11 # refers to the source path of zlib

-- with-openssl=/var/software/nginx/openssl-1.1.1-pre5 # refers to the source path of openssl

Install make & & make install

After the nginx compilation and installation is complete, modify the nginx.conf

User nginx nginx

Start nginx/ opt/project/nginx/nginx

Restart nginx/ opt/project/nginx/nginx-s reload

Kill the process pkill-9 nignx

View port netstat-ano | grep 80

View the process ps-ef | grep nginx

6 >

If you can't access it, you need to turn off the firewall.

Centos7 View Firewall status

Firewall-cmd-state # running Firewall is running (not running is turned off)

Turn off the firewall

Systemctl stop firewalld.service # stop firewall

Systemctl disable firewalld.service # prevents firewall from booting

If you encounter problems during the installation process, please google yourself, because the errors encountered may be different due to differences in the system.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Servers

Wechat

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

12
Report