Quick Nav
See Also
Appweb™ FAQ
If your question is not answered here FAQ, please submit your question to the online community support Forum.
Questions
General Questions
- What web framework should I use for my dynamic web application?
- Can I disable features to minimize memory footprint at run-time?
- How can I upload large files?
- What is the difference between handlers, modules and services?
Building Questions
- Can I replace the PHP library?
- How can I rebuild PHP?
- If I rebuild the source, can I disable features at compile time?
Diagnostic Questions
Embeddded Questions
Answers
What web framework should I use for my dynamic web appliation?
You have several choices: PHP, Ejscript, CGI, EGI and custom handlers.
PHP is a high functionality, web page creation environment. It is suitable for enterprise application development, but is very large. Definitely not for embedded use.
Ejscript is a server-side JavaScript framework that is ideal for creating dynamic web applications. It is compact and fast. Great for embedded, but also good for smaller enterprise apps.
CGI stands for the Common Gateway Interface and it is the legacy extension interface for running external programs to generate dynamic data. It is standard but very slow and cumbersome.
EGI stands for the Embedded Gateway Interface and is unique to Appweb. It is an in-memory replacement for CGI. However, Ejscript is a better choice in most cases.
Custom handlers are loadable Appweb modules, written in C, that add custom request handling logic to Appweb. They are the fastest and most compact request handling mechanism. But they are harder to write and secure.
We recommend using Ejscript for embedded applications and smaller enterprise applications. Use PHP for larger enterprise applications.
The following table may help summarize the differences:
CGI | EGI | Ejscript | PHP | Handler | |
Target Use | Legacy dynamic pages and forms | In-memory form processing | Dynamic embedded web pages and forms | Enterprise web pages and forms | Custom URL processing |
Typical memory footprint | External program | 15K plus form code | 200K plus application code | 2-5MB | Handler code |
Performance | Slow | Very fast form processing | Fast page and form processing | Medium speed but large memory consumption | Fastest possible |
Advantages | Standard in wide-use | Simple fast forms processing | Fast, compact and flexible | Large base of PHP code and developers | Allow any URL handling desired |
Disadvantages | Slow. Limit to forms. Can't design page WYSIWYG | Limit to forms. Can't design page WYSIWYG | Open source, but still specific to Appweb | Large memory footprint | Must build functionality |
Can I disable features to minimize memory footprint at run-time?
Yes. Appweb loads request handlers, scripting engines and other functionality via a run-time module loading mechanism. Via the Appweb configuration file, you can selectively enable the loading of function modules. For example, if you don't require CGI, comment out the "LoadModule cgiHandler" directive.
You need to increase the LimitRequestBody limit in the appweb.conf file. This imposes a maximum upload file size. Some samples have a MAX_FILE_SIZE input field in the HTML form. This however, is an just a hint to the browser and is only processed by some browsers.
Can I replace the PHP library?
Yes, you can replace the Appweb supplied PHP library with either the library from the standard PHP distribution or a custom PHP library of your own building. The Appweb PHP library is not special, it is a simple PHP configuration that omits many features to create the smallest PHP library possible. To do so, replace the PHP library which will be named either: libphp.so, libphp.dylib or php5ts.dll
Building PHP can sometimes be tricky, especially on Windows. We provide snapshots of various packages at http://github.com/embedthis/packages. This URL is a Git repository for PHP, OpenSSL and MatrixSSL with Makefiles to assist those wanting to rebuild these packages.
NOTE:These packages are not supported. They are provides as a service only.
If you are building Ubuntu Linux, you will need to run the following command to get the necessary tools and pre-requisites.
apt-get install build-essential libxml2-dev libdb-dev
To get the PHP package, use the git tool to download the packages:
git clone http://github.com/embedthis/packages. This is a big download, please be patient.
In the php sub-directory you will find a Makefile which has configure settings for PHP on various platforms. This Makefile disables most features to build a minimal PHP configuration. Edit this to suit your configuration.
On Linux, we use the following configuration:
./configure --disable-debug --disable-rpath --disable-cli \ --enable-bcmath --enable-calendar --enable-maintainer-zts \ --enable-embed=shared --enable-force-cgi-redirect --enable-ftp \ --enable-inline-optimization --enable-magic-quotes \ --enable-memory-limit --enable-safe-mode --enable-sockets \ --enable-track-vars --enable-trans-sid --enable-wddx \ --sysconfdir=/etc/appWeb --with-pic --with-exec-dir=/etc/appWeb/exec \ --with-db --with-regex=system --with-pear --with-xml --with-xmlrpc \ --with-zlib
For Windows, we use:
cscript /nologo configure.js \ --without-gd --disable-bcmath --disable-calendar --disable-com-dotnet \ --disable-filter --disable-json --disable-ipv6 --disable-odbc \ --disable-reflection --disable-tokenizer --disable-zlib --disable-ftp \ --enable-embed --enable-zts --without-dom --without-libxml
On MAC OS X, we use the following configuration:
./configure --disable-debug --disable-rpath --enable-bcmath \ --enable-calendar --enable-maintainer-zts --enable-embed=shared \ --enable-force-cgi-redirect --enable-ftp --enable-inline-optimization \ --enable-magic-quotes --enable-memory-limit --enable-safe-mode \ --enable-sockets --enable-track-vars --enable-trans-sid --enable-wddx \ --sysconfdir=/etc/appWeb --with-pic --with-exec-dir=/etc/appWeb/exec \ --with-db --with-regex=system --with-pear --with-xml --with-xmlrpc \ --with-zlib
Once we have a new PHP library, you can reconfigure and build Appweb to use this PHP library. Here is a typical Appweb configure command to use PHP:
./configure -with-php=/dir/to/php
If I rebuild the source, can I disable features at compile time?
Yes. When Appweb is built from source, a single bld.h header controls exactly what features and modules are built into the server. For example, if you don't require HTTP Keep-Alive support and you wish to minimize memory footprint, you can modify the MPR_FEATURE_HTTP_KEEP_ALIVE definition to be 0.
How can I trouble-shoot with trace?
Run appweb or winAppweb with the logging switch "-l". The logging switch takes the following parameters:
appweb -l logName[:logLevel][.maxSize]
Where logLevel is a number between 0 and 9. Zero is the least verbose. To debug HTTP requests, a level of 6 provides the detail of all the request / response exchanges. MaxSize is the maximum size of the log file in MB. When the maximum size is exceeded, the log file will be rotated to logName.old and a new log file will be started.
Appweb is configured by default to run CGI programs. If you do need to modify the CGI configuration, the following may help:
The configuration file directives for CGI are:
AddHandler cgiHandler .cgi .bat .cmd .pl
This instructs Appweb to run the CGI handler for specified file extensions. You can also have CGI be used for URLs that begin with a given prefix. By default there is already a Location block defined for /cgi-bin in the default appweb.conf. Any files under this URL (http://host/cgi-bin/scriptName) will also run as CGI scripts. To run a given interpreter (for example Perl), you can either just include
#!/bin/perlin the first line of your script (replace the /bin/perl path to point to your interpreter), and make sure your script has a .pl extension. Alternatively, you can change the path specified in the ActionProgram directive to point to your perl interpreter.
Here is the list of CGI variables that are defined for Appweb under CGI and EGI:
AUTH_TYPE CONTENT_LENGTH CONTENT_TYPE DOCUMENT_ROOT GATEWAY_INTERFACE HTTP_ACCEPT HTTP_CONNECTION HTTP_HOST HTTP_USER_AGENT PATH_INFO PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST REMOTE_USER REQUEST_METHOD REQUEST_URI SCRIPT_NAME SERVER_ADDR SERVER_HOST SERVER_NAME SERVER_PORT SERVER_PROTOCOL SERVER_SOFTWARE SERVER_URL
What is the difference between handlers and modules?
Modules are just for the basic loading mechanism of shared objects (DLLs). However they also provide a consistent way to handle modules that are statically loaded without much effort on the part of the developers.
Handlers are the work-horses for the HTTP server. They actually process the HTTP requests and have full access to the request and they own its processing.Appweb 2 has about 400K of code and on a VxWorks or uClibc based Linux system, you should be able to build Appweb for a 400-600K memory footprint. It will be larger if you use OpenSSL and much larger if you use PHP (which is 2-4MB). Appweb 3 is a little larger with about 600K of code.
For a minimal footprint on Appweb 3, use
./configure --disable-all ... more options ...
This will disable all possible features but still provide a running web server. Then add selective --enable-option and --with-component switches as required.
This to consider when building small:
- Don't use PHP
- Disable all possible features. In particular, disable the PHP, CGI and EGI modules
- Don't build DEBUG. Use: ./configure --type=release
- Use ./configure --tune=size
- Use MatrixSSL instead of OpenSSL if possible
- Use a small C-Library such as uClibc on embedded Linux systems
The Appweb configure command has switches to specify the build system and the target system that will host Appweb. For example:
./configure --host powerpc-wrs-vxworks --build pentium-pc-windows
When cross compiling, you also need to tell configure about your cross-compilation tool chain. This means the names of your compiler, library archiver and other utilities and flags. The configure program listens to the settings of the AR, CC, NM, RANLIB, STRIP, CFLAGS, IFLAGS and LDFLAGS environment variables and will pass their values into the build system. These will be used to define the cross-compilation tool chain. You can also specify an alternate build tool chain by using the same variables but with a BUILD_ prefix. For example:
DIR=/path/to/cross-tools ; \ AR=$DIR/bin/ar.exe \ CC=$DIR/bin/cc.exe \ LD=$DIR/bin/cc.exe \ NM=$DIR/nm.exe \ RANLIB=$DIR/ranlib.exe \ STRIP=$DIR/strip.exe \ CFLAGS="-I$DIR/include \ ./configure --type=DEBUG --host=arm--linux
For more details, please read: Cross Compilation in the Build Steps guide.
Need more help?
If you have any further questions, please go to the Appweb community support Forum.