Home > Backend Development > PHP Tutorial > Use PHP to implement an efficient and secure ftp server (1), PHP to implement ftp server_PHP tutorial

Use PHP to implement an efficient and secure ftp server (1), PHP to implement ftp server_PHP tutorial

WBOY
Release: 2016-07-12 09:03:10
Original
1032 people have browsed it

Use PHP to implement an efficient and secure ftp server (1), PHP to implement ftp server

Summary:

This article mainly explains the use of PHP's swoole extension to implement the ftp server, and at the same time expand the personalized functions and security of the ftp server. Really realize an ftp server that you have complete control over, an ftp server that can be customized.

 

Text:

Everyone must be familiar with FTP servers, and there are many ready-made software to use them. However, the functions of free software sometimes do not meet your needs, and secondary development is not possible, and the price of paid software is relatively high. PHP's swoole extension is a high-performance network communication framework for PHP language. It provides asynchronous multi-threaded server of PHP language, asynchronous TCP/UDP network client, asynchronous MySQL, database connection pool, AsyncTask, message queue, millisecond timer, asynchronous File reading and writing, asynchronous DNS query.

Swoole can be widely used in the Internet, mobile communications, enterprise software, online games, Internet of Things, Internet of Vehicles, smart homes and other fields. Using PHP Swoole as a network communication framework can greatly improve the efficiency of enterprise IT R&D teams and focus more on developing innovative products.

Swoole has a built-in asynchronous non-blocking, multi-threaded network IO server at the bottom layer. PHP programmers only need to handle event callbacks and do not need to care about the underlying layer. Unlike fully asynchronous frameworks such as Nginx/Tornado/Node.js, Swoole supports both fully asynchronous and synchronous.

With this foundation, server development based on TCP/IP protocol becomes easy. You may ask, C# and other languages ​​can also implement it, why use PHP? I think the main consideration is development efficiency. PHP is a scripting language that does not require compilation and is fast in development and deployment.

Without further ado, here are the steps:

00 Prepare the platform, I am using CentOS7 here;

01 To install php and swoole extensions, please refer to http://wiki.swoole.com/wiki/page/6.html;

02 Set the character set. Since file names processed by ftp are prone to garbled characters, it is recommended to set the character set of the operating system to GB18030, which is consistent with Windows. Although most ftp clients currently also support utf8 file name encoding, however, It's less than satisfying to use. Please feel free to tell me any good solutions, thank you very much;

03 Start writing php programs and test php programs;

04 Deploy the php version of ftp server.

The functional goals of this article to achieve the ftp server are:

  * 用户,组管理;
  * 密码自助修改与重置;
  * 文件夹权限管理;
  * IP访问控制;
  * 在线用户查看;
  * 磁盘空间使用查看;
  * SSL支持,保护密码及文件的传输安全;
  * 内置web管理页面,方便进行远程管理。<br /><br /> <br /> 项目目录:<br />  FtpServer<br />    |<br />    +-conf<br />    |   |<br />    |  +-config.php  //FTP配置文件<br />    |  +-ssl.crt    //ssl证书<br />    |  +-ssl.key    //ssl密钥<br />    |<br />    +-inc<br />    |  |<br />    |  +-CSmtp.php     //smtp发邮件类,用于FTP密码发送和重置<br />    |  +-ShareMemory.php //共享内存操作类<br />    |  +-User.php     //用户管理、文件权限管理、IP访问控制<br />    |<br />    +-logs  //日志文件<br />    |<br />    +-reference //参考文档<br />    |<br />    +-web<br />    |  |<br />    |  +-wwwroot    //FTP Web管理网站<br />    |  +-CWebServer.php //FTP内置http服务器<br />    |<br />    +-CFtpServer.php  //FTP服务器主程序<br />    +-MyFtpServer.php  //FTP入口程序
Copy after login

To be continued...

For sample program, please refer to http://share.realdatamed.com

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1082226.htmlTechArticleUsing PHP to implement an efficient and secure ftp server (1), php to implement ftp server Summary: This article mainly explains the use of PHP The swoole extension implements the ftp server and extends the ftp server personality...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template