This action will force synchronization from xiaozhuai/efserv, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
efserv is an Event-driven asynchronous http static file server written in C++，high performance，and low memory. Full name is EzFileServer.
Since it's a file server, all http request will be treated as
Before you can build, you need install
$ git clone https://github.com/xiaozhuai/libeio $ cd libeio $ ./autogen.sh $ ./configure $ make $ make install # maybe with sudo
For linux (debian like):
$ sudo apt-get install libev-dev
For linux (redhat like):
Sorry, I do not try it, find out yourself. Or build from sources is fine.
You need brew. (A package manager for osx)
$ brew install libev
efserv use cmake for building.
Follow these steps:
$ cd /path/to/efserv $ mkdir build $ cd build $ cmake .. -DCMAKE_BUILD_TYPE=Debug # or Release $ make $ make install
These things will be installed:
-- Installing: /usr/local/bin/efserv -- Installing: /usr/local/efserv/tpl -- Installing: /usr/local/efserv/tpl/dir_indexs.html -- Installing: /usr/local/efserv/tpl/err.html -- Installing: /usr/local/efserv/README.md -- Installing: /usr/local/efserv/README_CN.md -- Installing: /usr/local/efserv/LICENSE.md -- Installing: /usr/local/efserv/.efserv_access -- Installing: /usr/local/efserv/config.ini
/usr/local/bin/efservis the program binary
/usr/local/efserv/tplare the tpls used when err occured or dir indexs
/usr/local/efserv/.efserv_accessis a demo of access rules config
/usr/local/efserv/config.iniis a demo of server config
Just exec command
/var/www will be the default web root directory.
Yes, you can change it, just typing
efserv --help to get help.
EzFileServer Author : xiaozhuai Email : email@example.com Usage : efserv [OPTION]... All arguments are long options --config <file> Define the ini config path, it will be ".efserv_config" under web root by default --root <dir> Define the web root path, it will be "/var/www" by default --log-level <level> Define the log level, available levels are : disable, error, warning, info(default), debug --deamon Run as deamonize mode --help Print this help message
--root option to define the web root.
And you can define a config file on command line provide
--config option with params.
If you do not provided the
--config option, efserv will find config file in web root which named
.efserv_config. If not exist, it will use its default values.
efserv has 5 log-level, and you can define it before runing use
If you want run as deamonize mode,
--deamon option provided.
Let's find out what are there in config file.
Take a look at
/usr/local/efserv/config.ini(this is just a demo file).
# EzFileServer project # author: xiaozhuai # email: firstname.lastname@example.org # define the listening addr, use 0.0.0.0 by default #listen = 0.0.0.0 # define the listening port, use 80 by default port = 8080 # whether enable dir indexs, is enabled by default, 0 disable, 1 enable # if disable, all request to dir will be denied (403) # dir_indexs = 1 # define the view tpl of dir indexs, use "/usr/local/efserv/tpl/dir_indexs.html" by default # dir_indexs_tpl = /usr/local/efserv/tpl/dir_indexs.html # dir_indexs_tpl = tpl/dir_indexs.html # define the err page tpl, use "/use/local/efserv/tpl/err.html" by default # err_tpl = /use/local/efserv/tpl/err.html # err_tpl = tpl/err.html # define the access rule file name, use ".efserv_access" by default. This file should be under the root of web server # .efserv_access should be like this # - ^/private/.*$ # + ^/private/resources/.*$ # all request start with "/private/" will be denied, except the request start with "/private/resources/" # warning! # if change it to # + ^/private/resources/.*$ # - ^/private/.*$ # things will be different, all request start with "/private/" will be denied # the rule are matched from up to bottom, the last rule will be effective # if nothing is private, just remove this file or let it empty # by default, ".efserv_access" itself and ".efserv_config" in web root is denied, you can allow it by add line "+ .efserv_access" and "+ .efserv_config" # access_rule = .efserv_access
In config file, we see an option named
access_rule, this file contains access rule, by regex matching.
This file is under web root directory named
.efserv_access by default, you can change its name in config file, but you should always put it under web root directory.
# Denied private - /private # in-line comment + /test + /demo
+ means allow
- means denied.
And regex pattern is fine, for example
+ ^/private/resources/.*$ - ^/private/.*$
addr bind error occured, maybe port is in use, or port < 1024,
you know, if port < 1024, you need root user authority, just run with
sudo efserv ....
This not an issue.