search
HomeOperation and MaintenanceNginxHow to build a picture server on Linux platform through nginx and vsftpd

1. nginx installation

1. nginx installation environment

nginx is developed in C language. It is recommended to run on Linux. This tutorial Use centos6.5 as the installation environment.

To install nginx, you need to compile the source code downloaded from the official website first. 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 that includes a perl-compatible regular expression library. The http module of nginx uses pcre to parse regular expressions, so the pcre library needs to be installed on Linux.

yuminstall -y pcre pcre-devel

Note: pcre-devel is a secondary development library developed using pcre. nginx also requires this library.

The zlib library provides many compression and decompression methods. nginx uses zlib to gzip the contents of the http package, so the zlib library needs to be installed on Linux.

yuminstall -y zlib zlib-devel

openssl is a powerful secure socket layer cryptographic library, including major cryptographic algorithms, commonly used key and certificate encapsulation management functions and SSL protocols, and provides a wealth of applications for testing or other purposes use.

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

yuminstall -y openssl openssl-devel

2. Compile and install

Copy nginx-1.8.0.tar.gz to the linux server.

Unzip:

tar -zxvf nginx-1.8.0.tar.gz

Enter the root directory of nginx:

cd nginx-1.8.0

a.configure

./configure --help Query detailed parameters (refer to this tutorial Appendix part: nginx compilation parameters)

The parameter settings are as follows:

./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

Note: The temporary file directory is specified as /var/temp/nginx above, and the temp and nginx directories need to be created under /var

b. Compile and install

make
make install

Installation is successful. Check the installation directory:

How to build a picture server on Linux platform through nginx and vsftpd

c. Start nginx

cd /usr/local/nginx/sbin/
./nginx

Query the nginx process:

How to build a picture server on Linux platform through nginx and vsftpd

##15098 is the process id of the nginx main process, 15099 is the process id of the nginx worker process


Note: Execute ./nginx to start nginx. Here you can specify the loaded nginx configuration file with -c, as follows:

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

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


d. Stop nginx

Method 1, quick stop:

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

This method is equivalent to finding out the nginx process ID first and then using the kill command to forcefully kill the process.

Method 2, complete stop (recommended):

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

The stop step in this method is to stop the nginx process after the task is completed.

e. Restart nginx

Method 1, stop and then start (recommended):

Restarting nginx is equivalent to stopping nginx first and then Start nginx, that is, execute the stop command first and then the start command.

As follows:

./nginx -s quit 
./nginx

Method 2, reload the configuration file:

When the nginx configuration file nginx.conf is modified, you want to make the configuration To take effect, nginx needs to be restarted. Use -s reload to make the configuration information effective in nginx without first stopping nginx and then starting nginx, as follows:

./nginx -s reload

f. Test

nginx installation is successful, start nginx , you can access nginx on the virtual machine:

How to build a picture server on Linux platform through nginx and vsftpd

This means that nginx is successfully installed.

2. FTP installation

1. Install the vsftpd component

[root@bogon ~]# yum -y install vsftpd

After installation, there is the /etc/vsftpd/vsftpd.conf file, which is vsftp configuration file.

2. Add an ftp user

This user is used to log in to the ftp server.

[root@bogon ~]# useradd ftpuser

After such a user is created, you can use this to log in. Remember to use normal login instead of anonymous. After logging in, the default path is /home/ftpuser. ​


3. Add a password to the ftp user.

[root@bogon ~]# passwd ftpuser

Enter the password twice and then change the password.

4. Firewall opens port 21

Because the default port of ftp is 21, and centos is not enabled by default, you need to modify the iptables file. Some centos installations do not enable the firewall by default. No need to think about this step.

[root@bogon ~]# vim /etc/sysconfig/iptables

There is 22 on the line -jaccept. Enter a new line similar to that line, just replace 22 with 21, and then: wq to save.


Also run and restart iptables

[root@bogon ~]# service iptables restart

5. Modify selinux

The external network can be accessed, but I found that I cannot return to the directory (using ftp Active mode, passive mode is still inaccessible), and it cannot be uploaded because selinux is causing trouble.

Modify selinux:

Execute the following command to check the status:

[root@bogon ~]# getsebool -a | grepftp 
allow_ftpd_anon_write --> off 
allow_ftpd_full_access --> off 
allow_ftpd_use_cifs --> off 
allow_ftpd_use_nfs --> off 
ftp_home_dir --> off 
ftpd_connect_db --> off 
ftpd_use_passive_mode --> off 
httpd_enable_ftp_server --> off 
tftp_anon_write --> off 
[root@bogon ~]#

Execute the above command, and then return the result to see that both lines are off, which means that the external network is not enabled. Access

[root@bogon ~]#setsebool -p allow_ftpd_full_access on 
[root@bogon ~]#setsebool -p ftp_home_dir on

这样应该没问题了(如果,还是不行,看看是不是用了ftp客户端工具用了passive模式访问了,如提示entering passive mode,就代表是passive模式,默认是不行的,因为ftp passive模式被iptables挡住了,下面会讲怎么开启,如果懒得开的话,就看看你客户端ftp是否有port模式的选项,或者把passive模式的选项去掉。如果客户端还是不行,看看客户端上的主机的电脑是否开了防火墙,关吧) 

filezilla的主动、被动模式修改:

菜单:编辑→设置

How to build a picture server on Linux platform through nginx and vsftpd

6、关闭匿名访问

修改/etc/vsftpd/vsftpd.conf文件:

How to build a picture server on Linux platform through nginx and vsftpd

重启ftp服务:

[root@bogon ~]# service vsftpd restart

7、开启被动模式

默认是开启的,但是要指定一个端口范围,打开vsftpd.conf文件,在后面加上

pasv_min_port=30000 
pasv_max_port=30999

表示端口范围为30000~30999,这个可以随意改。改完重启一下vsftpd
由于指定这段端口范围,iptables也要相应的开启这个范围,所以像上面那样打开iptables文件。
也是在21上下面另起一行,更那行差不多,只是把21 改为30000:30999,然后:wq保存,重启下iptables。这样就搞定了。 

8、设置开机启动vsftpd ftp服务

[root@bogon ~]# chkconfig vsftpd on

         

The above is the detailed content of How to build a picture server on Linux platform through nginx and vsftpd. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
什么是linux设备节点什么是linux设备节点Apr 18, 2022 pm 08:10 PM

linux设备节点是应用程序和设备驱动程序沟通的一个桥梁;设备节点被创建在“/dev”,是连接内核与用户层的枢纽,相当于硬盘的inode一样的东西,记录了硬件设备的位置和信息。设备节点使用户可以与内核进行硬件的沟通,读写设备以及其他的操作。

Linux中open和fopen的区别有哪些Linux中open和fopen的区别有哪些Apr 29, 2022 pm 06:57 PM

区别:1、open是UNIX系统调用函数,而fopen是ANSIC标准中的C语言库函数;2、open的移植性没fopen好;3、fopen只能操纵普通正规文件,而open可以操作普通文件、网络套接字等;4、open无缓冲,fopen有缓冲。

linux中什么叫端口映射linux中什么叫端口映射May 09, 2022 pm 01:49 PM

端口映射又称端口转发,是指将外部主机的IP地址的端口映射到Intranet中的一台计算机,当用户访问外网IP的这个端口时,服务器自动将请求映射到对应局域网内部的机器上;可以通过使用动态或固定的公共网络IP路由ADSL宽带路由器来实现。

什么是linux交叉编译什么是linux交叉编译Apr 29, 2022 pm 06:47 PM

在linux中,交叉编译是指在一个平台上生成另一个平台上的可执行代码,即编译源代码的平台和执行源代码编译后程序的平台是两个不同的平台。使用交叉编译的原因:1、目标系统没有能力在其上进行本地编译;2、有能力进行源代码编译的平台与目标平台不同。

linux中eof是什么linux中eof是什么May 07, 2022 pm 04:26 PM

在linux中,eof是自定义终止符,是“END Of File”的缩写;因为是自定义的终止符,所以eof就不是固定的,可以随意的设置别名,linux中按“ctrl+d”就代表eof,eof一般会配合cat命令用于多行文本输出,指文件末尾。

linux怎么判断pcre是否安装linux怎么判断pcre是否安装May 09, 2022 pm 04:14 PM

在linux中,可以利用“rpm -qa pcre”命令判断pcre是否安装;rpm命令专门用于管理各项套件,使用该命令后,若结果中出现pcre的版本信息,则表示pcre已经安装,若没有出现版本信息,则表示没有安装pcre。

linux怎么查询mac地址linux怎么查询mac地址Apr 24, 2022 pm 08:01 PM

linux查询mac地址的方法:1、打开系统,在桌面中点击鼠标右键,选择“打开终端”;2、在终端中,执行“ifconfig”命令,查看输出结果,在输出信息第四行中紧跟“ether”单词后的字符串就是mac地址。

linux中rpc是什么意思linux中rpc是什么意思May 07, 2022 pm 04:48 PM

在linux中,rpc是远程过程调用的意思,是Reomote Procedure Call的缩写,特指一种隐藏了过程调用时实际通信细节的IPC方法;linux中通过RPC可以充分利用非共享内存的多处理器环境,提高系统资源的利用率。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools