Today I tried installing YAWS into Ubuntu 10.10. Installation is so easy that apt packages and repositories are ready to work.
First, use the following command to put on the software:
apt-get install yaws yaws-yapp
Then I got configuration files set in /etc/yaws/conf.d/ accompanied with a basis configuration file /etc/yaws/yaws.conf. What located in /etc/yaws/conf.d/ are soft links to correspondent files in /etc/yaws/conf.available/. Note that if you install YAWS in Ubuntu but cannot see any files when trying listing files in the route /etc/yaws/conf.d/, it’s specific privilege restrict, you can use emacs in sudo mode to list folders. There are files including localhost.conf, localhost-ssl.conf, yaws-yapp.conf, and etc. I did not need a web site working on HTTP, and then I deleted /etc/yaws/conf.d/localhost.conf. I need a web site with SSL so I edited /etc/yaws/conf.d/localhost-ssl.conf as below:
<server localhost> port = 443 listen = 0.0.0.0 docroot = /usr/share/yaws # dir_listings = true <ssl> keyfile = /etc/yaws/yaws-key.pem certfile = /etc/yaws/yaws-cert.pem </ssl> </server>
By default it uses its SSL cert- and key- files, and the port 8443. I would like to run it on the well-known port for HTTPS protocol, and then I changed the port number. Note that if the port 443 is bound by another web server and then YAWS, YAWS service won’t be start properly. I have not yet know if it supports virtual directories by tracing symbolic links. Then, when configuration was done, I restart it by using the following command:
service yaws restart
YAWS lets you use “ehtml" to embed Erlang code with YAWS BIFs. Erlang modules can be used either by installing compiled codes in /usr/lib/yaws/ebin/ or by putting Erlang header files *.hrl in /usr/lib/yaws/include/. To install compiled Erlang modules into YAWS, follow these steps:
- Write Erlang programs in *.erl.
- Compile modules by using erlc, and check *.beam files are generated.
- Copy *.beam files to /usr/lib/yaws/ebin/.
- Call those custom functions in ehtml blocks in *.yaws pages.