Taillieu.Info

More Than a Hobby..

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /customers/3/2/5/taillieu.info/httpd.www/templates/taillieuinfo_joomla3_rev1/functions.php on line 194

DNS-325 HOWTO Build lighttpd

HOWTO Build lighttpd

First, set up your crosscompile toolchain. Download build_lighttpd_pa1.tgz. Extract, edit the file to correct the bug in tar xvfz zips/.tar.gz –> tar xvzf zips/$APP-$APP_VER.tar.gz and then execute.

Quick helper: Also note that you need to create a /zips/ folder (or add it to the above script right after [if ! -f zips ]), otherwise the script breaks

Transfer the result, dns323_lighttpd-1.4.13.tar.gz, to /mnt/HD_a2 and extract it lnx_bin/busybox3 tar xvz -f dns323_lighttpd-1.4.13.tar.gz

Create a file, index.html, located in /mnt/HD_a2/www:

<html>
  <body>
    Hello World from DNS-323
  </body>
</html>

Create a file, lighttpd.conf, located in /mnt/HD_a2/lnx_bin:

server.document-root = "/mnt/HD_a2/www/"
server.port = 3000
mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png"
)

Now, let lighttpd analyze the file using ./lighttpd -t -f lighttpd.conf and if that worked out, start the server using ./lighttpd -D -f lighttpd.conf

Access your server on port 3000, e.g. http://192.168.0.200:3000/index.html

Notes on the application

The default path for the mod_-files are compiled into the application to be /mnt/HD_a2/lnx_bin/lib using the -DLIBRARY_DIR directive. To have the modules in another directory, change the build script or start the server with argumet -m PATH

Note on lighttpd version

Beginning with 1.5.0, lighttpd depends on glib2.

Notes on using port 80 for lighttpd

For fun-plug v0.5 click here and look for Port 80 for fun-plug versions 0.3 & 0.4 see below…

Since the DNS-323 Admin service (webs) uses port 80 in order to use port 80 for lighttpd you'll need to do the following:

  1. Modify ligttpd.conf file to include “server.port = 80”
  2. Stop the lighttpd service
  3. Stop the 'webs' service
  4. Start the lighttpd service

or use the two scripts below and make sure you put them in ./fun_plug.d/start directory with the correct CHMOD settings so they run automatically.

The admin service on your DNS-323 will now be available on port 81. To access: http://192.168.0.200:81

Here's the 'lighttpd.sh' script:

#!/bin/sh
#
# This script was modified by Paul on 2/2/08 as a work around
# in getting the admin website off of port 80 and on to port 81
# It is used in conjuction with admwebs.sh (created) which is
# called from this script. lighttpd.sh stops (via admwebs.sh) the
# web admin service and then starts lighttpd on port 80. The web admin
# now (automatically) starts on port 81 after a few seconds. The admin
# service tests for use on port 80. If it's in use then bumps to the 
# next available port (in this case it's bumped to port 81).
#
# NOTE:
# ./fun_plug.d/etc/lighttpd.conf needs to be configured to use
# port 80
#
# USE "netstat -tln" to verify that both port 80 & 81 are in use.
#

lighttpd_start() {

    # make sure, upload directory exists
    # path must match server.upload-dirs in lighttpd.conf file!
    mkdir -p ${VOL1}/tmp
    chmod 01777 ${VOL1}/tmp

    if [ -x "${SBINDIR}/lighttpd" ]; then
        echo "Stopping WEB admin"
        /mnt/HD_a2/fun_plug.d/start/admwebs.sh stop
        echo "Starting lighttpd... "
        ${SBINDIR}/lighttpd -f ${ETCDIR}/lighttpd.conf 1>/dev/null 2>/dev/null </dev/null
        echo "Starting WEB admin on port 81"
        /mnt/HD_a2/fun_plug.d/start/admwebs.sh start
        echo "done!" 
    else
        echo "ERROR: lighttpd not found or not executable"
    fi
}

lighttpd_stop() {
    killall lighttpd
}


lighttpd_status() {
    if [ -n "$(pidof lighttpd)" ]; then
        echo "running"
    else
        echo "stopped"
    fi
}

case "$1" in
    stop)
        lighttpd_stop
        ;;
    restart)
        lighttpd_stop
        sleep 1
        lighttpd_start
        ;;
    status)
        lighttpd_status
        ;;
    start|'')
        lighttpd_start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|status"
        ;;
esac

Here's the 'admwebs.sh' script:

#!/bin/sh
#
# This script was created by Paul on 2/2/08 as a work around
# in getting the admin website off of port 80 and on to port 81
# It is used in conjuction with lighttpd.sh (also modified) which
# calls this script. When used from lighttpd.sh it stops the
# web admin service then starts lighttpd on port 80. The web admin
# service notices that something is on port 80 and then starts on
# port 81.
#
# NOTE:
# ./fun_plug.d/etc/lighttpd.conf needs to be configured to use
# port 80
#
# NOTE2: (2/14/08)
#  Updated this script to remove "Starting" webs. Apparently
#  if you start webs you will not be able to add users
#  webs is set to automatically restart if the /web/webs service
#  is stopped.
#

admwebs_start() {
    if [ -x "/web/webs" ]; then
#       echo "Starting webs... "
#       /web/webs & > /dev/null
        echo "/webs/webs service will start automatically in 45 sec"
    else
        echo "ERROR: /web/webs not found or not executable"
    fi
}

admwebs_stop() {
    killall webs
}

admwebs_status() {
    if [ -n "$(pidof webs)" ]; then
        echo "running"
    else
        echo "stopped"
    fi
}

case "$1" in
    stop)
        admwebs_stop
        ;;
    restart)
        admwebs_stop
        sleep 1
        admwebs_start
        ;;
    status)
        admwebs_status
        ;;
    start|'')
        admwebs_start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|status"
        ;;
esac

Easy Ways

  • A pre-compiled variant can be found here
  • lighttpd is also included in fonz's fun_plug pack, a comprehensive fun_plug package that's easy to implement and great for first time users. php is a separate package that can be added easily. Instructions are provided.

Lighttpd for Windows Users

if you don't speak linux gibberish:

Before you begin:

Install Putty on your PC: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Install Netscan on your PC: http://www.softperfect.com/products/networkscanner/

Run Netscan. click the Options tab, then the Additional subtab. Click all the buttons. in the box on the bottom type 22, 23, 80, 443, 8080. Click OK.

Click the IP box, then click the range of your network in the box that pops up.

these files must be in these locations in Volume_1 of the DNS-323:

lighttpd.sh in /ffp/start

lighttpd.conf in ffp/etc/examples

these files are installed by default when fun plug runs the first time

Create these folders:

Volume_1/www

Volume_1/www/logs

Volume_1/www/pages

Run Putty. You will get a black box with an octet: # and a green cursor. you will enter the commands below at the green cursor. the octet is shown as a

reference point.

this command will copy the lighttpd configuration file /examples to ffp/etc:

# cd /ffp/etc

# cp examples/lighttpd.conf /ffp/etc/lighttpd.conf

this makes the lighttpd shell file in the /ffp/start directory executeable:

# cd /ffp/start

# chmod +x lighttpd.sh

it will not start if lighttpd.conf is not in /ffp/etc

to manually start lighttpd:

# sh /ffp/start/lighttpd.sh start

If it's running you will see port 8080 open on your DNS-323 when you Start Scanning in Netscan

Lighttpd with SQLite

Update extensions path in php.ini to point to '/ffp/lib/php/extensions/no-debug-non-zts-20 060613/'

Installation of SQLite

Configuration of PHP

  • Add some lines to /ffp/etc/php.ini if you need support for SQL in PHP (Create file if needed):

[PHP]
extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so

  • Restart ligthttpd (As root):

/ffp/start/lighttpd.sh restart

Fun tips on AWS Cloud Computing

Team,

This is a series of Fun tips on Cloud Computing which will be basic for someone who wants to understand Cloud Computing.

  1. Part 1 - Regions, Availability Zones and Edge Points
  2. Part 2 - Cloud Computing Model
  3. Part 3 - Private, Public and Hybrid Cloud
  4. Part 4 Instances
  5. Part 5 - SLA – Service level agreement for SaaS
  6. Part 6 – Purchase options for Instances
  7. Part 7 – Multi-tenancy
  8. Part 8 – Compliances
  9. Part 9 – Cloud Storage
  10. Part 10 – Multicloud
  11. Part 11 – Cloud native
  12. Part 12 – EC2 – Elastic Cloud Computing
  13. Part 13 – Cloud Virtualization
  14. Part 14 – Hypervisors
  15. Part 15 – Compute and Networking Services Series
  16. Part 16 – AWS storage and content delivery

How to fix SD card won't format error

Method 1. Run diskpart to format SD card that won't format

Step 1. Press Windows key and R key at the same time, type cmd in the Run box, hit Enter to open command prompt(cmd.exe).
Step 2. Type diskpart to run Diskpart Utility.
Step 3. Type list disk to list the drives on the computer.
Step 4. Type select disk 1 (The number should be replaced by the exact drive number of your SD card).
Step 5. Type clean to run the clean utility (this will wipe all data on the SD card so make sure you saved a copy or backup of the card data).
Step 6. Type create partition primary to create a new partition on the SD card.
Step 7. Type select partition 1 (it should be the newly created partition on step 6).
Step 8. Type active to make the partition active.
Step 9. Type format fs=ntfs (or format fs=fat32)to format the partition to the desired file system.


 

Part 2: Fix SanDisk SD card won’t format error

#1. Run CHKDSK to fix won’t format SanDisk SD card error

  • Right-click on Start to selectCommand Prompt (Admin) or click Start and type: cmd > click exe to bring up Command Prompt
  • Sign in as an administrator and type: chkdsk E: /f /r and hit Enter; (Replace E: with the drive letter of SanDisk SD card)
  • Exit CMD and enter Disk Management tool, find SD card, right-click on it and select Format volume
  • Reset file system and drive number of the SD card, click OK to confirm the format

#2. Run DiskPart to fix SanDisk Card won’t format error

  • Open Command Prompt by right-clicking Start >Command Prompt (Admin) or search cmd from Start
  • Type: diskpart to bring up DiskPart utility
  • Type: list disk and hit Enter
  • Type: select disk 1and hit Enter (Replace with the drive number of your SD card)
  • Type: clean and hit Enter
  • Type: create partition primary and hit Enter
  • Type: select disk 1and hit Enter (Replace 1 with the drive number of SD card)
  • Type: active to make the SD card partition activate
  • Type:format fs = NTFS or format fs = fat32 and hit Enter
  • Type:assign letter = F
  • After this, type exit to finish the process