Posts Tagged web server

Turn on the web server service on macOS

Apache webserver is shipped with all macOS version. The newer macOS version no longer provides user interface to control the webserver. Geeks who know Linux can turn on and off the webserver easily through the command line client. The following article on Apple community provides a step by step tutorial to do this.

Setting up a local web server on macOS 10.13 “High Sierra”

After you follow the above article to turn on your webserver. You can find the all software is up to date and ready to use. The latest PHP version is 7.1.7.


Tags: , , , , ,

Let Python work with Apache2

Python is very good language with efficient execution and clean code. It will be nice to write server side scripts in Python. A simply search of the internet, ended the following use information.

The original information was from the following page:

Install the packagelibapache2-mod-wsgi, then issue sudo a2enmod wsgi to enable it.

Just as a quick example to get it running, stuff something like this in your /etc/apache2/sites-enabled/default:

WSGIScriptAlias /test /path/to/python/ 

And in the file /path/to/python/

def application(environ, start_response):     start_response('200 OK', [('Content-Type', 'text/plain')])     return "Hello World" 

After re-starting Apache2, any request to /test will turn into a call of application() in your python file.

For further reading, look into WSGI (WebServer Gateway Interface), the way Python integrates with web-servers.

Bonus / Update:

Python (unsurprisingly) has a small WSGI server in the standard library for testing. If you add this in the bottom of your file, you can run it as any old executable for testing purposes, and then let Apache take over for production:

if __name__ == '__main__':     from wsgiref.simple_server import make_server     httpd = make_server('', 8080, application)     print "Serving on http://localhost:8080"     httpd.serve_forever()

Tags: , , ,

Online Notetaker – an ASP web application

I use internet a lot. You might be, too. Do you have a need to write something down when you are online and want to access it later on? I do. That is why that I wrote this web application. I call it Online NoteTaker because it is running under Web server IIS 4.0/5.0. Although you can use it locally if your computer has IIS server installed. And to run Online NoteTaker properly in your server, your server must have Microsoft Access 2000 or later version installed because Online NoteTaker use Access database to store all data.

Online NoteTaker is a password-protected web application. You can use it if and only if you sign up a account. And when you sign up an account, please remember your password firmly because it is encrypted and stored. Nobody can get back your password in case you forget it.

Every user has his/her unique ID that will be used to identify the notes. You can record and browse your notes anywhere at home, in office, or on travel. Notes from you are inaccessible to others. So do not worry about that you notes will disclose some of your private information to the public. No matter where you enter your notes, you can retrieve then through internet.

Click the link at the bottom of this page to download a copy of Online NoteTaker. To install it, just make a new directory under your web root directory, and unzip files to that directory. Then you can use your browser to use it. For local use, just enter “http://localhost//notes/” (I assuming that the directory you make is notes) to the address bar of your browser. For remote use, enter the host name and directory to use it. If you want to get a feeling of it, see a demo here – The following shows a couple of screen shots.


I will thank your for using my Online NoteTaker. If you have questions and comments, please leave your comments.

This ASP web application was developed several years ago. It happens that I find a good web server that provide ASP + ACCESS combination. The best thing is it is free. My server is running linux and Apache2 web server. I cannot run it on my own server. Too bad. If I have time, I will rewrite it in PHP + MySQL environments.

Download Online NoteTaker here –


Tags: , , , ,

Create an MS Access database by ASP VBScript

I’ve been dreaming of creating MS Access databases through VBScript for ASP server for a long time.  But I did not know how to create AutoNumber field. I spent two nights at home to write this vbscrip because I got a bad cold and did not go to office. At the beginning, I tried to use ADO functions to fullfil this goal. I failed. Until the last moment when I almost gave up. I read the SQL help in Access thoroughly and found the following information for data type in equivalent ANSI SQL Data Types of Microsoft Jet SQL reference.

data type
Microsoft Jet
SQL data type
Synonym Microsoft SQL
Server data type
Not supported COUNTER (See Notes) AUTOINCREMENT (See Notes)
INTERVAL Not supported Not supported
Not supported TEXT  (See Notes) LONGTEXT, LONGCHAR, MEMO, NOTE, NTEXT (See Notes) TEXT

That is very important information. Now I know the SQL data type for autonumber is counter/AUTOINCREMENT. I created a SQL query in Access and tried it to see whether it works. That is true it worked well. Then I modified my creating database class and tested through internet. Perfect. It works. Here I list the source code for this class and the testing code. To be noticed, the meta database was created under MS Access 2000. So you need use MS Access 2000 to run the demo code. But you can create your meta database in MS Access 97/2000/XP, then you can use this class under these environments.

Option Explicit

Public DBName
Public MetaDBName
Public MetaTableName
Private Conn, MetaConn
Private RS
Private SQL
Private TableName(10)
Private NumTables

Private Sub Class_Initialize()
MetaDBName = "OFC.MDB"
DBName = "test.mdb"
MetaTableName = "tblMeta"
End Sub

Private Sub Class_Terminate()
End Sub

' get table names
Private sub GetTableName
dim i
sql = "SELECT distinct myTableName FROM " & MetaTableName & ";"
Set rs= Server.CreateObject("ADODB.Recordset") sql, MetaConn, 1, 1
' the array, TableName, is predifined that has 10 elements
' if the actual number of tables greater than 10
' redim the array to accommodate more table name
if rs.recordcount > 10 then redim TableName(rs.recordcount)
i = 1
do while not (rs.eof or rs.bof)
i = i + 1
NumTables = i -1
set rs=nothing
End Sub

' Create a new database
Public Sub NewDB
Dim appAccess, dbs
Dim strDB
dim i,j

' Initialize string to database path.
strDB = server.mappath(DBNAME)
' Create new instance of Microsoft Access.
Set appAccess = CreateObject("Access.Application.9")
' Open database in Microsoft Access window.
appAccess.NewCurrentDatabase strDB
' Get Database object variable.
Set dbs = appAccess.CurrentDb

' Create tables according to definitions in META DataBese
for i = 1 to NumTables
' Create new table.
sql = "SELECT distinct * FROM " & MetaTableName & " WHERE mytablename= '" & TableName(i) & "';"
Set rs= Server.CreateObject("ADODB.Recordset") sql, MetaConn, 1, 1
SQL = "CREATE TABLE " & TableName(i) & " ("
j = 1
do while not (rs.eof or rs.bof)
' create SQL command
if j > 1 then SQL = SQL + ", "
SQL = SQL + rs("myFieldName") + " " + rs("myFieldType") + " "
if rs("myFieldSize")<>0 then SQL = SQL + "(" + cstr(rs("myFieldSize")) +")"
if rs("myPrimarykey") then SQL =SQL + " Primary key "
' move to next record
j = j + 1
SQL = SQL + ");"
set rs=nothing
dbs.Execute SQL
' close the new created database
set dbs = Nothing
Set appAccess = Nothing
End Sub

Private Sub OpenMetaDB
dim ConnStr
connstr = "DBQ="+server.mappath(MetaDBName)+";defaultdir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set MetaConn=server.createobject("ADODB.Connection") connstr
End Sub

Private Sub CloseMetaDB
set MetaConn = nothing
End Sub

Public Sub OpenDB
Dim ConnStr
connstr = "DBQ="+server.mappath(DBName)+";defaultdir=;DRIVER={Microsoft Access Driver (*.mdb)};Username=;Password=;"
set conn=server.createobject("ADODB.Connection") connstr
End Sub

Public Sub CloseDB
set conn = nothing
End Sub

End Class
MyOFCDB.DBName = "test1.mdb"
Test1.mdb has been created successfully in your web server.

Download source code –dbcreate


Tags: , , , , ,

User guide of NSLU2 file/web server

1. Introduction
2. Installation and configuration
3. FTP server
4. Web server
5. SSH server
6. Port forwarding

1. Introduction

Currently more and more families subscribe broadband Internet services, either Cable or DSL. In general, every family has more than one computer. To share hardware and software resources at home, such as hard drive, photos, music, software and so on, a dedicated computer as a file and/or web server has to run all the time, at least during the day time. More people are willing to have their own private web server running within their LANs. The problem is that a dedicated computer is not an energy- and cost-efficient solution. How can we obtain a more reasonable solution of a file and/or web server at home? A smart and practical solution of absolutely cost-efficient, energy saving and private file and/or web server is provided here for home networks. Linksys has a product called Network Storage Link for USB 2.0 Disk Drives (NSLU2). This device has two USB ports that you can plug external hard drives or flash drives. It provides a basic platform to create a cost-efficient and energy saving file and/or web server. The second component we need is a flash drive with 1 GB or more storage capacity. The third component is a customized firmware that allows us to install and configure software in a NSLU2 device. In the public domain, a user community called nslu2-linux-org makes enormous efforts to develop alternative firmware for NSLU2 devices. Unfortunately, a large group of people are not familiar with Linux and do not have experience to flash NSLU2 devices with the newly developed UNSLUG firmware.

Here is a customized NSLU2 with web server, file server, ftp server, and SSH server installed (see Figure 1). The customized system use FTP client to transfer and manage all files on the web server. In addition, usage of the web server is summarized and every 6 hours by Webalizer application. You can view the daily and monthly usage of your web server. By browsing these daily updated web pages you can easily monitor how your web server is used. If you like, you can make your web server available in the Internet by configuring your router properly. As a plus, you still can plug another external hard drive (formatted in NTFS Windows format) to the device and share it in your home network. This user manual describes how to use its web/ftp/ssh servers. You can evaluate the efficiency and speed of the web server by visiting It was constructed by the exactly same method. Plus, you can learn basic Linux commands by SSHing into the NSLU2 because a customized Linux operation system is running on it.

Figure 1. Components of the NSLU2 file/web server

Back to Content

2. Installation and configuration
A. Plug the Flash Drive

NSLU2 has two USB ports. You should plug the flash drive to the Disk 2 port at all the time. Do not try to plug it to Disk 1 port. The Disk 1 port is prepared for a NTFS format USB drive. So make sure that the flash drive is plugged into the Disk 2 port. The flash drive was formatted to Linux EXT3 format. It is totally different from the Windows partition formats (such as FAT16/32, NTFS). So do not try read and write files to your flash drive on any Windows PC.

B. Connect the device to your router and find its IP address

Use a RJ45 Ethernet cable to connect your device to your router. Since the default IP address of the device is set to dynamic, you can get its IP address in the clients table of your router. A sample client table could look like Figure 2. In this case, the IP address of the Linksys device (named LKG7E5076, your device will have different name) is

Figure 2. Sample clients table in a router

C. Use web interface

The Linksys NSLU2 default username (admin) and password (admin) for the web interface are preserved. We recommend you to change the password to something meaningful to you. That will increase the security of the server if you expose it to the Internet.

Figure 3. The home page of the NSLU2 web interface
Use your web browser to visit the IP address ( that is shown in the client table of your router. The home page of the NSLU2 will show up (see Figure 3). In the page, you can see the following important information:

Server nameLKG7E5076
Firmware version:V2.3R63-uNSLUng-6.8-beta
IP address192.168.2.4
USB port 1:Not installed (that means nothing is plugged in this port)
USB port 2:Ready, 729MB (94% Free) (This tells us that there is a disk attached to this port. The data partition has 729MB space of which 94% is free)

At the bottom of this page, you can find one line of message like ‘uNSLUng status: Unslung to disk 2, /dev/sda1’. That tells us the filesystem of the flash drive is running.

D. Change IP address setting

Through the web interface of the Linksys NSLU2, you can change the IP address configuration of the device. The following picture shows the web pages used to do the work. The customized NSLU2 server comes with dynamic IP address because you can easily find it in your LAN. Once you connect the device to your router, the first thing you need do is to change the IP address to a fixed one according your LAN setting. Please refer your router’s manual and NSLU2 original manual to do it. Figure 4 shows the current IP address setting and Figure 5 shows the changed setting.

Figure 4. The interface used to set the IP address of the NSLU2 device

Figure 5. Set a fixed IP address

Back to Content

3. FTP server

The customized device has FTP server enabled. Any normal account created through the NSLU2 web interface can connect to the FTP server remotely. To create a user account or change the password of existing accounts, please follow the NSLU2 original user guide. Figure 6 shows a sample view after connected to the NSLU2 device through the admin account. That is why I emphasize that you have to change the password of the admin account if you plan to expose your server to the Internet. An FTP account is set specifically for web server. Both the user name and password of the account are wwwroot.

Figure 6. A sample view of FTP server of the NSLU2 in a FTP client

Back to Content

4. Web server

There are two threads of thttpd web server running in the customized NSLU2. The web interface of the NSLU2 device is running on port 80. The user web server is running on port 8080. After you connect your device to your network and determine its IP address, you can look at the web server running at port 8080. Launch your web browser and enter to visit the user web server. Figure 7 shows the default web page for the user web server of the customized NSLU2. Please pay attention the above URL link. Since the default http port (80) is used for NSLU2’s web interface, we have to indicate the port that a web server is running for the user web server space. The port information is important for port forwarding, too. The default web page (index.html) on the user web server should be overwritten or deleted if you use a different file, such as index.htm. You can upload all files of your website through any FTP clients. The username and password for your web server are wwwroot. All web pages should be uploaded to wwwroot directory (see Figure 8). To share your web server through the Internet, you have to configure your router. Add the server IP address and the port 8080 to the forwarding IP list (see the port forwarding section for detail).

Figure 7. The default page for the user web server of the customized NSLU2

Figure 8. The initial FTP client window after connected the FTP server

Back to Content

5. SSH server

An SSH server is running in the customized NSLU2 device. That allows you log in the server and do configuration and install new packages. PuTTY is a free telnet/SSH client. You can use it to connect to any telnet server and SSH server. The following two links have PuTTY client program for downloading.


Figure 9 shows a typical PuTTY configuration window. Every time the program is started, the window will pop up first. What you can do is type your server’s IP address in the Host name (or IP address) textbox and select the protocol type. If you use a telnet server, please select Telnet radio button, the port number will automatically change to 21. If you use an SSH server, please select SSH radio button, the port number will automatically change to 22. Click Open button to connect to the server. If this is your first time to log on this SSH server, an alert window will pop up first (see Figure 10). What you can do is to click Yes button to continue. Then a terminal window will pop up (See Figure 11). Within this window, you can enter the root username (root) and password (uNSLUng) to log in the device. You can always login as root. We suggest that you create a new user for normal maintenance of NSLU2.

Figure 9. A typical PuTTY configuration window

Figure 10. A security warning window when you connect to the SSH server first time

Figure 11. The normal terminal window after you log in the device

Back to Content

6. Port forwarding

If you are intending to expose your servers to the Internet, you have to study your router’s user manual and find a way to set port forwarding. Table 1 lists the port and protocol of different servers running in the NSLU2. They are useful when you set port forwarding in your router.

Table 1 Port information of different services for access from the Internet

Server Port LAN IP Protocol
FTP 21 Your device IP address TCP
HTTP 8080 Your device IP address TCP
SSH 22 Your device IP address TCP

The port forwarding function is different from router to router. Here we give two examples of port forwarding based on a USR 5461 router and an ActionTec DSL modem (see Figure 12 and Figure 13). For detail steps you should check the user guide of your router.

Figure 12 Port forwarding section in a USR 5461 router

Figure 13 Port forwarding section in ActionTec DSL modem

Back to Content



Tags: , , , , , , , ,