Pages

Saturday, April 6, 2013

The SMILE as a Content Web Server

I wanted to configure the SMILE to serve static content from the micro-SD card. It was fairly simple.

First, I installed nginx on the SMILE. I then mounted the SD card.

Finally, I had to configure nginx to serve content from the card (mounted as /media/sdcard), which is what this post is about.

The main configuration file is /etc/nginx/nginx.conf. First, we'll change the port on which nginx listens. The default port is 80, but this is already being used by the SMILE software. We can disable the SMILE software, and we'll talk about it in an upcomign post. But in the meantime, let's just change the nginx port. So we'll change the following line:
listen       80;
into
listen       8080;
The next change will be the location of the documents. The default root directory for the content is /usr/share/nginx/html. We have two options here. Either edit the nginx.conf file to change the directory, or add a soft link from /usr/share/nginx/html to /media/sdcard. For the first method, you'll need to change the nginx.conf line
root   /usr/share/nginx/html;
into
root   /media/sdcard;
The second method involves first deleting (or renaming) the /usr/share/nginx/html directory, then adding a soft link instead. Here's how to about this path:
cd /usr/share/nginx/
mv html html.orig
ln -s /media/sdcard/ html
That's it! You can now go to http://10.1.0.1:8080 (assuming you're connected wirelessly to the SMILE), and assuming you have an index.html (or index.htm) in your SD card's top directory, you should see it now in your browser. If yo're getting a 403 error, it means you probably don't have an index.html file on the SD card.

Running nginx is simple - you basically type nginx at the shell prompt:
root@SMILEplug:~# nginx
In case nginx is already running, you can issue the following command  to reload the configuration file:

root@SMILEplug:~# nginx -s reload

No comments:

Post a Comment