How to use PHP to implement an efficient and secure FTP server (i) _php instance

Source: Internet
Author: User
Tags install php php language message queue file transfer protocol ftp protocol ssl certificate

The FTP server (file Transfer Protocol server) is a computer that provides file storage and access services on the Internet, which are serviced in accordance with the FTP protocol. FTP is the file Transfer Protocol (Files Transfer Protocol). As the name suggests, is specifically used to transfer files of the protocol. Simply put, the server that supports the FTP protocol is the FTP server.

Summary:

This article mainly describes the use of PHP swoole extension to implement FTP server, while extending the FTP server personalization features and security. Truly realize a full control of their FTP server, you can personalize the FTP server.

Body:

The FTP server presumably everybody is not unfamiliar, use up, ready-made software is also many. However, the free software features sometimes do not meet their own needs, and can not be two times development, paid software prices are relatively high. PHP swoole extension, is the PHP language High-performance network Communication Framework, provides the PHP language of the asynchronous multithreaded server, asynchronous TCP/UDP network client, asynchronous MySQL, database connection pool, Asynctask, message queue, millisecond timer, asynchronous file read and write, An asynchronous DNS query.

Swoole can be widely used in the fields of Internet, mobile communication, enterprise software, network games, IoT, car networking, intelligent home and so on. Using Php+swoole as the framework of network communication, it can improve the efficiency of the enterprise IT research and development team and focus on the development of innovative products.

The Swoole has built-in asynchronous non-blocking, multi-threaded network IO servers. The PHP programmer only needs to handle the event callback, without caring for the underlying. Unlike a fully asynchronous framework such as Nginx/tornado/node.js, Swoole supports both full and synchronous.

With this foundation, the TCP/IP protocol based server development becomes easier. Perhaps everyone will ask, C # and other languages can also achieve ah, why use PHP? I think the main consideration is development efficiency. PHP is a scripting language that does not need to be compiled, and deployment is faster.

  Needless to be said, here's a list of steps:

00 Prepare platform, I use here the CentOS7;

01 Install PHP and Swoole extensions, please refer to http://wiki.swoole.com/wiki/page/6.html;

02 Set character set, because the FTP processing file name easily garbled, it is recommended that the operating system set to GB18030, so that the same as windows, most of the current FTP clients, although also support UTF8 file name encoding, but the use of more than not. How to good solution please hesitate to tell, thank you very much;

03 Start to write PHP program, test PHP program;

04 The FTP server for the PHP version of the department.

  The purpose of this article is to achieve the functions of FTP server:

* User, group management;
* Password self-service modification and reset;
* Folder Rights Management;
* IP access control;
* Online user view;
* Disk space use view;
* SSL support, protect password and file transmission security;
* Built-in Web Management page for easy remote management.

Project directory:  

Ftpserver
|
+-conf
|
|
|
+-config.php//ftp configuration file
|
+-SSL.CRT//SSL Certificate
|
+-ssl.key//ssl Key
|
+-inc
|
|
|
+-csmtp.php//SMTP Email class for FTP password sending and resetting
|
+-sharememory.php//Shared memory operation class
|
+-user.php//user management, file Rights Management, IP access control
|
+-logs//log files
|
+-reference//reference documentation
|
+-web
|
|
|
+-wwwroot//ftp Web Management Web site
|
+-cwebserver.php//ftp Built-in HTTP server
|
+-cftpserver.php//FTP Server Main program
+-myftpserver.php//FTP Entry Program

This article first introduced to you here, follow-up will continue to update. For more information on how to use PHP to achieve efficient and secure FTP servers (ii), click here to learn more.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.