标签:
为了避免参数都在命令行中导致太长,或者不能玩一些高级配置;可以使用inets的配置文件,OTP项目已经有各种配置文件的例子:
[root@whyang ~]# cd otp_src_17.5/lib/inets/ [root@whyang inets]# find . -type f -name *.config ./test/inets.config ./src/inets_app/inets.config [root@whyang inets]# find . -type f -name *.conf ./examples/server_root/conf/8888.conf ./examples/server_root/conf/ssl.conf ./examples/server_root/conf/httpd.conf ./examples/server_root/conf/8080.conf ./test/ftp_SUITE_data/vsftpd.conf ./test/httpd_test_data/server_root/conf/8888.conf ./test/httpd_test_data/server_root/conf/ssl.conf ./test/httpd_test_data/server_root/conf/httpd.conf ./test/httpd_test_data/server_root/conf/8080.conf ./test/httpc_proxy_SUITE_data/apache2/apache2.conf ./test/property_test/ftp_simple_client_server_data/vsftpd.conf ./test/old_httpd_SUITE_data/server_root/conf/8888.conf ./test/old_httpd_SUITE_data/server_root/conf/ssl.conf ./test/old_httpd_SUITE_data/server_root/conf/httpd.conf ./test/old_httpd_SUITE_data/server_root/conf/8080.conf [root@whyang inets]#
比如inets APP级配置文件inet_test.config,内容大约如下:
[root@whyang inets]# cat ./test/inets.config [{inets,[{services,[{httpd,"/ldisk/tests/bmk/inets/priv_dir/8099.conf"}]}]}]. [root@whyang inets]# cat ./src/inets_app/inets.config [{inets,[{services,[{httpd,"/var/tmp/server_root/conf/8888.conf"}, {httpd,"/var/tmp/server_root/conf/8080.conf"}]}]}]. [root@whyang inets]#
我这里inets APP级配置文件内如下:
[root@whyang ~]# cat inets_httpd18880.config [{inets,[{services,[{httpd,"/root/inetsConf/18880.conf"}]}]}]. [root@whyang ~]#
而模块级别配置文件,如8888.conf,https.conf等等,我这里模块httpd的配置文件如下:
[root@whyang ~]# cat inetsConf/18880.conf Port 18880 ServerName whyang.yang.net SocketType ip_comm Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_include mod_dir mod_get mod_head mod_log mod_disk_log ServerAdmin andypeker@163.com ServerRoot . server_tokens full log_format common ErrorLog /var/log/inets/error_log_18880 TransferLog /var/log/inets/access_log_18880 SecurityLog /var/log/inets/security_log_18880 ErrorDiskLog /var/log/inets/error_disk_log_18880 ErrorDiskLogSize 200000 10 TransferDiskLog /var/log/inets/access_disk_log_18880 TransferDiskLogSize 200000 10 SecurityDiskLog /var/log/inets/security_disk_log SecurityDiskLogSize 200000 10 MaxClients 50 #KeepAlive 5 #KeepAliveTimeout 10 DocumentRoot /var/www/html DirectoryIndex main.html index.html DefaultType text/plain Alias /icons/ /var/www/html/icons/ Alias /pics/ /var/www/html/icons/ ScriptAlias /cgi-bin/ /var/www/html/cgi-bin/ ScriptAlias /htbin/ /var/www/html/cgi-bin/ ErlScriptAlias /cgi-bin/erl httpd_example io EvalScriptAlias /eval httpd_example io #Script HEAD /cgi-bin/printenv.sh #Action image/gif /cgi-bin/printenv.sh <Directory /var/www/html> AuthDBType plain AuthName Open Area AuthUserFile /root/inetsConf/auth/passwd AuthGroupFile /root/inetsConf/auth/group require user franklin require group groupf groupm </Directory> [root@whyang ~]#
注意到其中还有auth的配置...
配置文件齐了,启动:
[root@whyang ~]# erl -config inets_httpd18880.config Erlang/OTP 17 [erts-6.4] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false] Eshell V6.4 (abort with ^G) 1>
上面只是加载了配置文件,接下来启动APP inets:
1> application:start(inets).
ok
2>
查看一下APP状态:
2> application:loaded_applications(). [{kernel,"ERTS CXC 138 10","3.2"}, {stdlib,"ERTS CXC 138 10","2.4"}, {inets,"INETS CXC 138 49","5.10.6"}] 3>
有个问题需要注意,httpd模块配置文件中,server_tokens和log_format字段是无效的(经过验证),而且配置文件例子中(比如httpd.conf)中没有server_tokens和log_format字段。
浏览器打开看看!?:
输入用户名和密码,登录:
登录OK:
标签:
原文地址:http://www.cnblogs.com/andypeker/p/4643340.html