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 and build Nginx server on Linux

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

Share

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

Today Xiaobian to share with you how to install and build Nginx server on Linux related knowledge points, detailed content, clear logic, I believe most people are still too familiar with this knowledge, so share this article for everyone to refer to, I hope you read this article after some harvest, let's take a look at it.

1. Upload nginx compressed package nginx-1.8.0.tar.gz to linux server

2. since nginx is developed in c language and we install nginx here by compiling the source code of nginx, we need to install gcc, the compilation environment of c language, on linux.

This step can be omitted if already installed, otherwise execute the command:

yum install gcc-c++

3.The http module of nginx uses pcre to parse regular expressions, so you need to install the pcre library on linux.

yum install -y pcre pcre-devel

4.The zlib library provides many ways to compress and decompress. Nginx uses zlib to gzip the contents of http packages, so you need to install the zlib library on linux.

yum install -y zlib zlib-devel

5.nginx not only supports http protocol, but also https (that is, http is transmitted over ssl protocol), so you need to install openssl library in linux.

yum install -y openssl openssl-devel

6. Create a temporary directory of nginx on linux, note that I am creating a folder temp under/var under the linux file system to create nginx under temp. /var/temp/nginx

7. Execute command:

./ configure \--prefix=/usr/local/nginx \--pid-path=/var/run/nginx/nginx.pid \--lock-path=/var/lock/nginx.lock \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--with-http_gzip_static_module \--http-client-body-temp-path=/var/temp/nginx/client \--http-proxy-temp-path=/var/temp/nginx/proxy \--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \--http-scgi-temp-path=/var/temp/nginx/scgi

8. Compile source code, install nginx:

makemake install

9. Start nginx:

cd /usr/local/nginx/sbin/./ nginx -c /usr/local/nginx/conf/nginx.cof

Visit: http://localhost in browser

We can also see the nginx process running at this point:

ps aux|grep nginx

10.How to stop nginx server:

Method 1: First find out the nginx process id and then use the kill command to force the process to kill.

cd /usr/local/nginx/sbin./ nginx -s stop

Method 2 (recommended): Stop after the nginx process finishes processing tasks.

cd /usr/local/nginx/sbin./ nginx -s quit The above is "How to install and build Nginx server on Linux" All the contents of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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