Forlinx Posted 21 hours ago Report Posted 21 hours ago In the management and interaction of embedded devices, the application based on Web mode has become the mainstream. This kind of server not only occupies small resources and runs efficiently, but also can dynamically generate page content according to actual needs. For users, they can realize the remote management, status monitoring and function control of embedded devices only through the commonly used Web browser, without installing additional software or complex configuration. BOA is a lightweight, efficient, and embedded Web server known for its minimal resource consumption and straightforward configuration. It is particularly suited for devices with limited memory and processing capabilities, providing essential Web functionalities. This article describes how to port the boa server on the FET-MX9352-C platform. How to Compile Source Code? Download address: http://www.boa.org/ 1. Install dependent libraries sudo apt-get install bison flex Unzip the source code in Ubuntu $ tar xvf boa-0.94.14rc21.tar cd boa-0.94.14rc21/ Modify the boa source code Modify src/compat.h find #define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff Modify to #define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff Otherwise, an error occurs: util.c:100:1: error: pasting "t" and "->" does not give a valid preprocessing token make: *** [util.o] error 1 Modify src/log.c find if (dup2(error_log, STDERR_FILENO) == -1) { DIE("unable to dup2 the error log"); } Modify to /*if (dup2(error_log, STDERR_FILENO) == -1) { DIE("unable to dup2 the error log"); }*/ Otherwise, an error occurs: log.c:73 unable to dup2 the error log:bad file descriptor Modify src/boa.c find if (passwdbuf == NULL) { DIE(”getpwuid”); } if (initgroups(passwdbuf->pw_name, passwdbuf->pw_gid) == -1) { DIE(”initgroups”); } Modify to #if 0 if (passwdbuf == NULL) { DIE(”getpwuid”); } if (initgroups(passwdbuf->pw_name, passwdbuf->pw_gid) == -1) { DIE(”initgroups”); } #endif Otherwise, an error occurs: boa.c:211 - getpwuid: No such file or directory Set environment variables and compile . /opt/fsl-imx-xwayland/6.1-mickledore/environment-setup-armv8a-poky-linux ./configure --host=arm-linux make aarch64-poky-linux-strip src/boa At this point, the boa has been cross-compiled Expected file path examples/boa. conf and SRC/boa 2. Modify boa.conf vi boa.conf (1) Group modification Modify Group nogroup to Group root (2) User modification Modify User nobody to User root (3) Modify DocumentRoot DocumentRoot /var/www (4) Modify ScriptAlias ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ (5) ServerName settings Modify #ServerName www.your.org.here ServerName www.your.org.here Otherwise, an error will occur “gethostbyname::No such file or directory 3. Compile the test file Unzip the source code in Ubuntu tar xvf cgi_app.tar.gz cd cgi_app/ Clean up the files make clean Set environment variables and compile . /opt/fsl-imx-xwayland/6.1-mickledore/environment-setup-armv8a-poky-linux $CC -o app.cgi cgi_app.c cJSON/cJSON.c Generate app.cgi 4.Arrange to the development board To create the directory, enter the following command on the development board. mkdir /usr/lib/cgi-bin mkdir /var/www mkdir /etc/boa mkdir /usr/lib/cgi-bin/ Table of ContentsPut app.cgi in the /usr/lib/cgi-bin/ directory Put index.html, xmlhttpreq.js to /var/www/ folder Put boa.conf in the/etc/boa/directory Place boa in the/usr/bin/directory Place the mime. Types in the/etc/directory Modify permissions chown root:root /var/www/* chown root:root /usr/lib/cgi-bin/app.cgi chmod o+x /usr/lib/cgi-bin/app.cgi chmod o+r /usr/lib/cgi-bin/app.cgi Turn off the original network services Because 9352 self-started lighttpd services, ps aux | grep http can see his process ID. To disable the startup of the Lighttpd service, vi /lib/systemd/system/lighttpd.service change line 8 and 9 to #ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf #ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf Create a log file Vi/etc/autorun. sh Write this in mkdir/var/log/boa and restart Start the boa by entering the following command on the development board. boa The computer and the development board are directly connected through the network cable, and the computer opens the browser to access the IP of the development board. http://192.168.0.232/ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.