Install Nginx on Linux, source code installation and create soft connection

foreword

Nginx is a powerful, high-performance, scalable, easy-to-use and secure web server and reverse proxy server, widely used in enterprise and Internet fields

  1. Extensibility: Nginx can extend its functionality by adding various modules and plugins, including HTTP flow control, SSL encryption, compression and decompression, access control, and more.

  2. High reliability: Nginx adopts a distributed architecture with multiple optimization algorithms and health check mechanisms, which can effectively prevent problems such as single point failures and crashes, and ensure stability.

  3. Easy to configure: Nginx's configuration files are very simple and easy to understand, users can easily modify and adjust, and its configuration is also very flexible, supporting multiple languages ​​and grammars.

  4. Security: Nginx has powerful security features that can protect and filter requests initiated by clients and servers, including preventing DDoS attacks, SQL injection, XSS and other security issues.

1. Download and install

Linux installation Nginx: download link

☺️ My version:
insert image description here

Download the jar package

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

decompress

tar -xvzf nginx-1.5.7.tar.gz 

move to /usr/local

mv nginx-1.5.7 /usr/local/

The environment dependencies that need to be installed for nginx installation: 不安装此步骤, an error will be reported when compiling.

yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++

Go to the installation directory for source code installation

cd /usr/local/nginx-1.5.7

//.configure是源码安装的第一步,主要的作用是对即将安装的软件进行配置
./configure 

//执行make编译命令
make

//执行make install安装命令
make install

After installation, the same-level directory of nginx-1.5.7 will appear in the nginx directory
insert image description here

cd /usr/local/nginx/sbin

Perform startup, shutdown, and restart operations through nginx under /usr/local/nginx/sbin:

Start: ./nginx
Shutdown: ./nginx -s stop
Restart:./nginx -s reload

After starting the nginx service, it is successful to directly access the ip and appear a page.
insert image description here

2. Configuration file address

Configure nginx.conf

# 打开配置文件
vi /usr/local/nginx/conf/nginx.conf

insert image description here

After the modification is complete, restart nginx

/usr/local/nginx/sbin/nginx -s reload

3. Create a soft connection for easy operation

Every time you want to operate nginx, you have to enter /usr/local/nginx/sbin/nginx
, let’s create a soft connection, similar to a shortcut.

ln -sv /usr/local/nginx/sbin/nginx /usr/bin/nginx

In this way, we can directly run commands anywhere to operate nginx
start: nginx
shut down: nginx -s stop
restart:nginx -s reload

Guess you like

Origin blog.csdn.net/weixin_45549188/article/details/130316371