readme.txt 2022-05-19 The files for this update are in: "2022-05-03-AC0XL-Pi-B-Plus-1-2". For a couple of months I have been working on trying to get the "thttpd" install easier for 3rd or 4th graders to be able to make their own World Wide Web server. After I finished the "2022-04-18-AC0XL-Pi-400-thttpd-install.txt" I thought of trying some smaller versions, but all of the new Raspberry Pi's are out of stock. So I dug through some of my boxes and found a couple of older Pi's. One was a Raspberry Pi B Rev 2.0 with 512 MB RAM that runs at 700 MHz (697.95 BogoMIPS), with two USB ports and a full sized SD card slot. This one ran pretty hot, but it probably did not help that it was about 98 degrees F. inside my trailer. The specs show that model does use a lot more power, thus the extra heat. Another one I found is the Raspberry Pi Model B Plus Rev 1.2 with 512 MB RAM running at 700 MHz (697.96 BogoMIPS), and the same processor. It has four USB ports and a microSD card with a push-push slot. This one ran cool even at the same inside temperature. The question was, "Will this pi run "thttpd" since the "Chromium Web Browser" was VERY SLOW! running with the new Raspberry Pi OS. I actually compiled and ran "thttpd" on the Pi B Plus, but when it came time to test to see if thttpd was running, Chromium just did not want to start, so I installed ELinks so I could see if thttpd was showing up on "localhost". Actually the first time I ended up just using my Android phone and typing in the IP Address and it was there! "2022-04-30-AC0XL-Pi-B-Plus-install.txt" is a copy of the second install, to have a record of how long it takes to do the install and tests and then install my 42 GB of online web data on the Pi B Plus (AC0XL-Pi-B-Plus-1-2-web-size.txt -- 44,016,524,750 bytes in /home/local/www/users/) and then do a "wget" and see how long it takes to copy the web site to a 1 TB hard drive on my Pi 400 using ethernet cables to my gigabit router that also has my web site running and some other android devices and an ONN Roku TV (with 3 HDMI ports) for the Pi B Plus monitor. AC0XL-Pi-B-Plus-1-2-web-size.txt -- 44,016,524,750 bytes in /home/local/www/users/, the first test 05/03/2022 ran 8638 seconds = 5,095,685 bytes/second average served from the Raspberry Pi B Plus version 1.2 running thttpd as a World Wide Web server! The second test 05/07/2022 I added "--http-keep-alive" to "wget" which I believe could have caused it to run a little slower even though it is the built in default. The second test ended up with 44,016,524,750 bytes in 8911 seconds = 4,939,572 bytes/second average. My internet speed is 2Mb/sec down and 1Mb/sec up which would be 250,000 bytes/sec down and 125,000 bytes/sec up. This is roughly 40 times faster than my internet upload speed! from a lowly Raspberry Pi B Plus!!! The third test I ran was from my Raspberry Pi 4B which is actively serving with AC0XL-www-Pi-4B-2022-05-14-web-size.txt showing 44,023,600,182 bytes in /home/local/www/users/. AC0XL-www-Pi-4B-2022.05.14-log shows wget started at: "192.168.1.187 - - [13/May/2022:15:10:00 +0000] "GET / HTTP/1.1" 200 25000 "" "Wget/1.21"", and ended: "192.168.1.187 - - [13/May/2022:15:32:59 +0000] "GET /ac0xl/www/2009-GreenRiver.UT/greenriverutah.com/archives/pics/album/res/javascript.js HTTP/1.1" 403 0 "http://192.168.1.2/ac0xl/www/2009-GreenRiver.UT/greenriverutah.com/archives/pics/album/index.html" "Wget/1.21"". So 23 minutes times 60 seconds = 1380 seconds. 44.023,600.182 bytes in 1380 seconds = 31,901,160 bytes/second, from a Pi 4B Gigabit ethernet port to a Gigabit router that is also serving my live WWW connection, then to a Pi 400 Gigabit ethernet port. I did see a few connections made from the outside during the wget. This is about 255.20928 times faster than my upload speed!!! Think of "thttpd" as the bullet proof skeleton web server, raw data (files which are read-only) are the meat on the bones, and HTML is the skin covering the meat, which does contain "POST" and might open a vulnerability since it is a write, with CGI being the bells and whistles, which contain programs that could easily contain vulnerabilities. Out of the box "thttpd" is safe because it is read-only, whereas a "LAMP" install (Linux, Apache, MySQL, and PHP) out of the box might last a few days, if not just a few hours when exposed to the World Wide Web and the attacks that are all of the time happening! ************************************************* CGI Author Vangie Beal September 1, 1996 Updated on: February 10, 2022 Common Gateway Interface Common Gateway Interface is an interface specification for transferring information between WWW servers and external databases and information sources known as CGI programs (sometimes referred to as scripts). The specifics of how the script is executed is determined by the server. A CGI program is any program designed to accept and return data that conforms to the CGI’s specification and is the most common way for web servers to interact dynamically with users. History of Common Gateway Interface specifications In 1993, The National Center for Supercomputing Applications (NCSA) developed standards in 1993 to interface with servers, like HTTP, to execute any external program, and developers accepted it as a standard for web servers. In 1997 NCSA formed a team—including Rob McCool, the author of NCSA HTTPd Web Server, and Ken Coar—and they formally defined CGI, which is specified in RFC 3875: “The Common Gateway Interface, or CGI, is a standard for external gateway programs to interface with information servers such as HTTP servers.” Common Gateway Interface features The following are some of the most significant features of CGI that attracts developers to generate dynamic web content: Highly compatible with all web browsers. Written in a simple and clear scripting language like Perl or C. Can easily interface with HTML. For example, when a user fills out a form on a Web page and submits it, it needs to be processed by an application program. The Web server passes the form information to a small application program that then processes the data and sends a confirmation message back. This passing of data back and forth between the server and application is the CGI; it works as a mechanism that is part of the Hypertext Transfer Protocol (HTTP). Common Gateway Interface advantages Being a powerful data exchanging mechanism between the servers and the external databases, CGI web technology possesses the following advantages to users: Users can perform advanced tasks much easier by using CGI instead of using other programming languages like Java. It is easy to use an existing code rather than writing a new code from scratch. CGI programs are language-independent; therefore, they can be written in any language. Counters and codes based on CGI are available to perform simple tasks. Common Gateway Interface disadvantages Although CGI provides enough flexibility and versatility to run applications on a server, it has some disadvantages: Page loading incurs overhead, as it needs to call on a new process each time an HTTP request is initiated, and it uses significant server memory. Therefore, CGI scripts are not suitable for high-traffic web pages. The process of data caching between page loads is normally slow under CGI. Though CGI has a huge codebase, it is mostly in Perl and is not suitable for developing client-side applications. Scripts take a lot of processing time, as they need to create a separate process each time an HTTP request is initiated. Another disadvantage is that a new process is started each time a script is executed. For busy websites, this can noticeably slow down the server. Using the server’s API, such as ISAPI or NSAPI, can be more efficient but difficult to implement. Another popular solution is using Java’s servlets. Common Gateway Interface alternatives Due to some disadvantages like processing time and slow data caching processes, the use of CGI is falling. Here are some alternatives to CGI: ASP Active Server Pages (ASP) is a web technology based on Internet Information Services (IIS) developed by Microsoft to develop dynamic web pages and quickly respond to the request initiated from HTML forms. ASP scripts are performed on the server, and it also contains HTML, XML, and text. While compared with CGI, ASP is simple, secure, and fast. PHP Hypertext Preprocessor, popularly known as PHP, is a server-side open-source scripting language. Like ASP and CGI, PHP scripts are performed on the server, and it comprises scripts, text, and HTML tags. PHP also supports several databases, including Oracle, Solid, MySQL, etc. CFML ColdFusion Markup Language (CFML) lets developers build dynamic web pages based on HTML. When a browser requests data in CFML, its application server automatically pre-processes the request. Therefore, it’s a fast and feasible way to develop dynamic pages that can link with any database. FastCGI FastCGI is an extended version of CGI; however, it’s simple, fast, and more secure than CGI. The main purpose of FastCGI is to reduce the overhead of using CGI by allowing a separate server to handle more HTTP requests. ************************************************* After a few preliminaries, the process is to compile the "thttpd" source code which is four easy steps: 1. "make clean", 2. ".configure", 3. "make". and 4. "sudo make install" which in total took 5 minutes and 31 seconds! Moving the files to where they are supposed to be and adding the other necessary items that thttpd needs took another 45 minutes and 15 seconds to get to the first test to see if everything up to this point is working right. Almost all of this is copy and paste into the terminal and then enter it. One will have to add a user (category or header item) that needs a password, other than that it is just copy the command and paste it. The first test is to see if your web site is at "localhost". I spent an hour at this point trying to get Chromium to come up and finally resorted to my Android phone and checked that the site was working, clicking on the first user and seeing if it opened and then clicking on "../" to see if it went back up one level. The solution: install "ELinks" then it is just "elinks http://localhost/" # when this is entered in a terminal it should bring up the web site at localhost within a couple of seconds. Another three and a half minutes to kill thttpd, then look at the logs and add some other files on the web site. Eight and a half minutes brings us to the next test, will it auto start? frank@AC0XL-Pi-B-Plus-1-2:/etc $ sudo ./rc.local ### sudo (Starting thttpd from rc.local, REMEMBER the sudo!!!!!!) My IP address is 192.168.1.90 Starting thttpd. thttpd frank@AC0XL-Pi-B-Plus-1-2:/etc $ frank@AC0XL-Pi-B-Plus-1-2:/etc $ Checking out the new things on the web site this time using the IP Address, then checking if log-rotate works. Check out the log files, check if the "man" pages work, and add some new entries to the log by going to the web site and clicking on items from different computers or even phones. By this time it was time for me to go to bed. The computer can be shut down and when it is turned back on thttpd should be running by the time the desktop appears, as seen by its PID Numbers in "ps -e", (thttpd_wrapper, thttpd). "thttpd_wrapper" will restart "thttpd" in 10 seconds if it ever quits! pi@AC0XL-Pi-400:~ $ # The beauty of loading "thttpd" to "/home/local/sbin/" is that one can just copy the complete "/home/" directory and all of your web site will be backed up. There is no need to worry about all of the other system files that are under "/usr/" that the computer will need to change if a different OS is installed! pi@AC0XL-Pi-400:~ $ pi@AC0XL-Pi-400:~ $ # I will load some of my web site so one can get a feel of what will be required when moving your web site to new hardware. pi@AC0XL-Pi-400:~ $ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 115G 94G 17G 86% / devtmpfs 1.7G 0 1.7G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 759M 996K 758M 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock /dev/mmcblk0p1 253M 31M 222M 12% /boot tmpfs 380M 32K 380M 1% /run/user/1000 /dev/sda1 253M 112M 141M 45% /media/pi/system-boot /dev/sda2 917G 560G 321G 64% /media/pi/writable ### These are the steps I used to build my back-up of my Pi-400 since that was the only other 128GB microSD card I had and just copied the /home/ directory from my Pi-4B web server to a 1TB hard drive. I also needed some extra space so I copied the 32G0SD directory to a directory called "pulled" and copied my e-mail files ".thunderbird" there too. To rebuild Thunderbird, one just needs to install Thunderbird and skip the setup page, Then copy the old dot file (cp -av .thunderbird to ~/ ) which will put your old thunderbird files back in your home directory. ( cp -iav .thunderbird to your back-up media. Install Thunderbird, and open it, but do not run the setup, but delete it. Then replace the .thunderbird file in your home directory with your back-up copy with cp -av .thunderbird ~/ (leave the "i" off so you do not have to answer all of the over-write questions)). # ### I just listed the commands that I used. # df -h ### Check for space used and free space in drives. # cd /media/pi/writable/ ### Change to new drive that will be the backup drive. # ls -al ### Check that you are where you need to be, space for backup. # sudo mkdir AC0XL-Pi-400 ### sudo - make directory for the backup. # cd *400 ### Change to the backup directory. # sudo mkdir 2022-04-08 ### sudo - date the directory for the backup. # cd 2022-04-08/ ### Change to the backup date directory. # sudo cp -iav /home/ . ### sudo - sudo copy all the files in /home/ to here, they do have different owners so you need sudo. # du -hd2 ### Do a check of the backup to make sure everything is there that you want. If you use du -bd2 the count will be in bytes. # df -h ### Do another check on how much free space is left. # # pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ sudo cp -iav /home . ### Making a backup for the web server. ### /home/pi (printout text skipped) pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ du -hd2 ### A listing of my back-up for my new copy for the Pi 400. and the Pi 4B web server. 8.1G ./pulled/.thunderbird 35G ./pulled/32G-SD 43G ./pulled 24K ./home/music 24K ./home/documents 24K ./home/pictures 24K ./home/delinquent-accounts 49G ./home/pi 1.4M ./home/local 24K ./home/va 24K ./home/searles-sav-on-propane 24K ./home/notices 24K ./home/memes 24K ./home/downloads 24K ./home/rome 24K ./home/ac0xl 24K ./home/freedom 24K ./home/videos 49G ./home 91G . pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 115G 94G 17G 86% / devtmpfs 1.7G 0 1.7G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 759M 996K 758M 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock /dev/mmcblk0p1 253M 31M 222M 12% /boot tmpfs 380M 32K 380M 1% /run/user/1000 /dev/sda1 253M 112M 141M 45% /media/pi/system-boot /dev/sda2 917G 560G 321G 64% /media/pi/writable pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ ### This is with the new microSD card set up and copied the "pulled" files back to the new card. ### cd /media/pi/writable/AC0XL-Pi-400/2022-04-08 pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08 $ cd pulled pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08/pulled $ sudo cp -iav 32G-SD ~/ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-Pi-400/2022-04-08/pulled $ sudo cp -iav .thunderbird ~/ pi@AC0XL-Pi-400:~ $ du -hd2 /home 24K /home/music 24K /home/pictures 152K /home/local/www 1.2M /home/local/sbin 60K /home/local/man 1.4M /home/local 360K /home/pi/.local 38G /home/pi/32G-SD 4.0K /home/pi/Pictures 4.0K /home/pi/Music 40M /home/pi/.mozilla 368K /home/pi/.config 4.0K /home/pi/Templates 64K /home/pi/Desktop 112K /home/pi/.pp_backup 112M /home/pi/RP2040 4.0K /home/pi/Documents 8.3G /home/pi/.thunderbird 1.3G /home/pi/.cache 4.0K /home/pi/Videos 35M /home/pi/Bookshelf 4.0K /home/pi/Public 3.0G /home/pi/Downloads 20M /home/pi/freedom 51G /home/pi 24K /home/ac0xl 24K /home/va 24K /home/notices 24K /home/downloads 24K /home/documents 24K /home/videos 24K /home/searles-sav-on-propane 24K /home/rome 24K /home/delinquent-accounts 24K /home/memes 24K /home/freedom 51G /home pi@AC0XL-Pi-400:~ $ # The safest way is to go to your destination and then copy from your source so you do not wipe out your source! "cp -iav (source) . (here)". In this case I will eliminate the "v" so I do not get a multitude of lines that will over flow my printout. # This is copying from the backup file to a new drive (microSD card). pi@AC0XL-Pi-400:~ $ pi@AC0XL-Pi-400:~ $ cd /media/pi/writable/AC0XL-www-Pi-4B/2022-04-08/home/ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-www-Pi-4B/2022-04-08/home $ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-www-Pi-4B/2022-04-08/home $ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-www-Pi-4B/2022-04-08/home $ ls -al total 84 drwxr-xr-x 17 root root 4096 Feb 5 19:19 . drwxr-xr-x 4 root root 4096 Apr 8 18:21 .. drwxr-xr-x 16 ac0xl www 4096 Feb 10 16:54 ac0xl drwxr-xr-x 4 delinquent-accounts www 4096 Feb 6 11:39 delinquent-accounts drwxr-xr-x 3 documents www 4096 Feb 6 11:41 documents drwxr-xr-x 13 downloads www 4096 Feb 6 11:45 downloads drwxr-xr-x 10 freedom www 4096 Feb 6 11:55 freedom drwxr-xr-x 5 root root 4096 Feb 5 17:11 local drwxr-xr-x 3 memes www 4096 Feb 6 11:59 memes drwxr-xr-x 4 music www 4096 Feb 6 12:01 music drwxr-xr-x 4 notices www 4096 Feb 6 12:04 notices drwxr-xr-x 21 pi pi 4096 Apr 8 00:40 pi drwxr-xr-x 4 pictures www 4096 Feb 6 12:07 pictures drwxr-xr-x 50 rome www 20480 Feb 6 12:16 rome drwxr-xr-x 4 searles-sav-on-propane www 4096 Feb 6 12:18 searles-sav-on-propane drwxr-xr-x 4 va www 4096 Feb 6 12:20 va drwxr-xr-x 9 videos www 4096 Feb 11 17:02 videos pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-www-Pi-4B/2022-04-08/home $ pi@AC0XL-Pi-400:/media/pi/writable/AC0XL-www-Pi-4B/2022-04-08/home $ The rest is in "2022-04-18-AC0XL-Pi-400-thttpd-install.txt" around line 5625. Around line 8585 the discussion starts into setting up a router so your site will be visible on the "World Wide Web". ************************************************* The benchmark test system for thttpd, last updated 12jul98, was a 297MHz Ultra Sparc with 256MB RAM / 512MB swap running Solaris 2.6, otherwise totally quiescent. RLIMIT_NOFILE is 256 soft / 1024 hard, and v.v_maxup is 3941. UltraSPARC-Architecture.txt Last Updated : 22 Mar, 2022 UltraSPARC Architecture belongs to the SPARC (Scalable Processor Architecture) family of processors. This architecture is suitable for wide range of microcomputers and supercomputers. UltraSPARC is example of RISC (Reduced Instruction Set Computer). UltraSPARC architecture: Memory: Memory consists of 8 bit-bytes. Two consecutive bytes form a halfword, four bytes form a word, eight bytes form a doubleword. UltraSPARC programs operates on Virtual Address Space (264 bytes). Virtual Address Space is divided into pages and these pages are stored in the physical memory or on disk. Registers: UltraSPARC architecture include a large file of registers that have more than 100 general purpose registers. Any procedure can access only 32 registers only. The SPARC hardware uses window into registers file to manage all the operations of different procedures. Beside these register files, UltraSPARC also uses Program Counter, code register, and other control registers. Data Formats: Integers are stored as 8-, 16-, 32-, or 64-bit Binary numbers. Characters are represented using 8-bit ASCII codes. Floating points are represented using three different formats namely single-precision format, double-precision format, quad-precision format. Instruction Formats: SPARC architecture use three basic instruction formats. All the instructions are of 32-bit long and first two bits are used to identify which format is being used. Format 1- Used for Call instruction. Format 2- Used for branch instructions. Format 3- Used by all the remaining instructions like register load and store. Where, n=Indirect mode, i=Immediate addressing, x=Index addressing, b=Base addressing, p= Program counter, e=Exponential addressing Addressing Modes: Operands in memory are addressed using one of the following three modes: Mode Target address(TA) calculation PC-relative TA=(PC) + displacement Register indirect TA=(register) + displacement with displacement Register indirect TA=(register-1) + (register-2) indexed PC-relative is used only for branch instructions. Instruction Set: This architecture have less number of instructions as compared to CISC machines. The only instructions that access memory are load and stores. All other instructions operates on register only. Instruction execution on a SPARC system is pipelined which means while one instruction is executed next one is being fetched from memory and decoded. Input and Output: Communication between I/O devices and SPARC operation are accomplished through memory. Input and Output can be performed with the regular instruction set of the computer, and no special I/O instructions are needed. ************************************************* It appears the UltraSPARC comes set up for 32 bit operation: Next, it is needed to tell the system to ignore old CPU warnings. Log in as root. Start a text editor, from GUI or use vi (if you know key functions :) ), and open file: /platform/sun4u/boot.conf Sometimes this "sun4u" may be different according to your platform (e.g. sun4m for SPARCStation 20). Now find and uncomment the line: ALLOW_64BIT_KERNEL_ON_UltraSPARC_1_CPU=true If it is not present, type it manually but in Solaris 7 it should be present, but commented (# as first character). Now save the file, reboot and you have a 64-bit system. It appears the UltraSparc IIi 300 MHz processing four operations per clock cycle should have a BogoMIPS of around 1200. "thttpd" was designed and optimized for computers with limited resources. On the second run of "wget" I added "--http-keep-alive" which is the default, thinking that might remove the "Connection: close" in the wget "logfile.txt" file, but it is probably just an indicator that the file was downloaded to completion, and caused "wget" to take longer. The second run took a little longer, (02:28:31 or 8911 seconds vs. 8638 seconds) to download the 42 GB (AC0XL-Pi-B-Plus-1-2-web-size.txt -- 44,016,524,750 bytes in /home/local/www/users/) on the "thttpd" web server running on a Raspberry Pi B Plus computer running at 700 MHz with 512 MB RAM connected to my Gigabit router with an ethernet cable then with an ethernet cable to my Raspberry Pi 400 onto a USB 3.0 1 TB hard drive. The router also has my Raspberry Pi 4B with 4 GB RAM running my website, several Android computers, and a Wal-Mart ONN Roku TV which was being used for the monitor for the Pi B Plus, since it has three HDMI ports. The extra 273 seconds could have been from just other activity on the router or the added "--http-keep-alive". That still leaves a through put of at least 5 MB/sec which is probably 40 times faster than my current 1 megabit/sec upload rate! A 32-bit OS is limited to less than 2 gigabytes in "thttpd" while a 64-bit OS is basically unlimited, with no changes being made in thttpd! The second run is adding almost one gigabyte to "freedom" but for now I think it is necessary to see some of what is possible with "thttpd" since it was designed for computers with limited resources. "wget" is adding the index.html and index.html.orig files. Since "thttpd" is bullet proof out of the box and is simple to configure, I feel it would be ideal for students who might not be interested in robotics, but more interested in a web server that reaches the world, and not just their local home environment! If the Wi-Fi ports on the Raspberry Pi Zero W and 2W are similar in speed to the ethernet Port on the Raspberry Pi B Plus then the Pi Zero W should work great for a thttpd WWW server limited to files less than 2 GB since it is only 32-bits, and the Pi Zero 2W with four cores and 64-bits should be FANTASTIC! Your own World Wide Website for pennies!