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 build a picture server through Nginx and vsftpd by Centos

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Editor to share with you how Centos builds a picture server through Nginx and vsftpd. I hope you will get something after reading this article. Let's discuss it together.

1. Introduction to Nginx

Nginx (engine x) is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP server. Nginx was developed by Igor Sesoyev for the second most visited Rambler.ru site in Russia. The first public version 0.1.0 was released on October 4, 2004.

It distributes the source code as a BSD-like license and is known for its stability, rich feature set, sample configuration files, and low consumption of system resources. Nginx 1.0.4 was released on June 1, 2011.

Nginx is a lightweight Web server / reverse proxy server and email (IMAP/POP3) proxy server, and is distributed under a BSD-like protocol. It is characterized by low memory and strong concurrency ability. in fact, the concurrency ability of nginx does perform well in the same type of web server. Chinese mainland uses nginx website users: Baidu, JD.com, Sina, NetEase, Tencent, Taobao and so on.

This article mainly introduces Centos to build a picture server through nginx and vsftpd. Friends who need it can refer to it.

2. Nginx installation

Nginx official website

Ngxin download address

2.1.The nginx installation environment

Yum install-y gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel

Here are some brief introductions

Nginx is developed in C language and is recommended to run on linux. This tutorial uses Centos 7.2 as the installation environment.

# cat / etc/redhat-release# uname-a

To install nginx, you need to compile the source code downloaded from the official website. The compilation depends on the gcc environment. If there is no gcc environment, you need to install gcc:

Yum install gcc-c++

PCRE (PerlCompatible Regular Expressions) is a Perl library, including a perl-compatible library of regular expressions. Nginx's http module uses pcre to parse regular expressions, so you need to install the pcre library on linux.

Yum install-y pcre pcre-devel

Note: pcre-devel is a secondary development library developed using pcre. This library is also required for nginx.

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

Yum install-y zlib zlib-devel

OpenSSL is a powerful secure socket layer cipher library that includes major cryptographic algorithms, commonly used key and certificate encapsulation management functions, and SSL protocols, and provides rich applications for testing or other purposes.

Nginx supports not only the http protocol, but also https (that is, http over the ssl protocol), so you need to install the openssl library on linux.

Yum install-y openssl openssl-devel

Download Nginx compilation and installation

Three types of versions are available on Nginx's official website.

Mainline version:Mainline is the version currently being done by the main force of Nginx, which can be said to be a development version.

Stable version: the latest stable version, recommended for production environments

Legacy versions: a stable version of the old version left over

The latest stable version is nginx-1.12.1.

The demo uses nginx-1.13.4

1. Download Nginx

# wget http://nginx.org/download/nginx-1.13.4.tar.gz

2. Decompress:

Tar-zxvf nginx-1.13.4.tar.gz

3. Enter the root directory of nginx:

Cd nginx-1.13.4

4. Configure configuration

Query detailed parameters

. / configure-- help

Only the installation directory is configured here. Other parameters default.

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

Screenshot with successful configuration

5. Compile and install

Make make install

Make compilation (the process of make is to turn source files written in various languages into executable files and various library files)

Make install installation (make install copies these compiled executables and library files to the appropriate place)

View the installation directory successfully:

3. Start and stop Nginx

3.1 determine whether the configuration file is correct

Cd / usr/local/nginx/sbin./nginx-t or specify the configuration file. / nginx-t-c / usr/local/nginx/conf/nginx.conf

3.2 start

Cd / usr/local/nginx/sbin/./nginx

Note: execute. / nginx to start nginx, where you can specify the loaded nginx configuration file by-c, as follows:

Cd / usr/local/nginx/sbin/./nginx-c / usr/local/nginx/conf/nginx.conf

If you do not specify-c conf-path= Nginx to load the conf/nginx.conf file by default at startup, the address of this file can also be specified when compiling and installing nginx (--conf-path= points to the configuration file (nginx.conf)).

Query the nginx process:

27811 is the process of the nginx main process id,27812 is the process id of the nginx worker process

3.3 stop and restart nginx

3.3.1 stop

Mode 1, quick stop:

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

This approach is equivalent to finding out the nginx process id and then using the kill command to force the killing of the process.

Method 2, stop completely (recommended):

Cd / usr/local/nginx/sbin. / nginx-s quit

In this way, the stop step is stopped after the nginx process has finished processing the task.

3.3.2 restart nginx

Method 1, stop and then start (recommended):

Restarting nginx is equivalent to stopping nginx and then starting nginx, that is, executing the stop command before starting the command.

As follows:

. / nginx-s quit. / nginx

Mode 2, reload the configuration file:

When the configuration file nginx.conf of nginx is modified, you need to restart nginx for the configuration to take effect. You can use-s reload to take effect in nginx without first stopping nginx and then starting nginx, as shown below:

. / nginx-s reload

4. Test Nginx

After Nginx is successfully installed, start nginx to access the Nginx on the virtual machine. If Nginx is started and other computers cannot access it, please set up a firewall.

5. FTP installation

Please refer to a previous article to build a FTP file service based on CentOS

FTP picture upload and save directory is / data/ftp/pub/img

6. Configure Nginx to access pictures on FTP

6.1 create a Nginx configuration directory

Create the Nginx configuration directory conf.d in the / usr/local/nginx/conf directory to facilitate unified management of Nginx configuration files.

Mkdir-p / usr/local/nginx/conf/conf.d

6.2 set up the main profile

Set the main configuration file to load all configuration files with the suffix conf in conf.d and open the log of log_format main

Include conf.d/*.conf

6.3 Nginx add Picture server

Add the img.conf file to the / usr/local/nginx/conf/conf.d directory and add the following:

Server {listen 8190; error_log logs/storer_error.log debug; access_log logs/storer_access.log main; location / img/ {# alias / data/ftp/pub/img/; root / data/ftp/pub/;}}

Check that the configuration file is correct

.. / sbin/nginx-t

Start Nginx

.. / sbin/nginx

If it was started before,

.. / sbin/nginx-s reload

The browser enters the Nginx access address to test http://10.211.55.4:8190/img/666.jpeg

After reading this article, I believe you have some understanding of "how Centos builds a picture server through Nginx and vsftpd". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

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