Your Own Personal WEB Server

"Нечего делать" - это очень сильный стимул. Иногда человек от нечего делать делает гораздо больше, чем от стимула "надо сделать". Это типа эпиграф такой, хех...

To get start working with YOPS, perform following steps. And remember that these instructions refer to the latest release. There may be some differences in older releases.

STEP 1. Downloading and unpacking

Download YOPS tarball, place downloaded file into your home directory and unpack the archive:


  bzip2 -d yops-yyyy-mm-dd.tar.bz2
  tar xf yops-yyyy-mm-dd.tar

After unpacking, 2 directories should appear in your home, swebs and www. First one contains server sources, and the second this documentation (in docs subdir), configuration file (.conf/config) and empty log file (.log/access.log)

STEP 2. Compiling the server

Before compiling make sure you have libcurl4-openssl-dev package installed on your system. YOPS uses this library for handling URL encoded strings, because i was too lazy to implement that myself :)

Goto swebs directory and type make:


  you@host:~$ cd swebs
  you@host:~/swebs$
  you@host:~/swebs$ make

If you see make output just as shown below then everything is allright and you can proceed to next step, and if not - something went wrong :( In the latter case feel free to contact me


  gcc -O3 -Wall -c -o swebs.o swebs.c
  swebs.c: In function ‘swebs_gen_jobid’:
  swebs.c:886: warning: cast from pointer to integer of different size
  swebs.c:887: warning: cast from pointer to integer of different size
  gcc -O3 -Wall -c -o soket.o soket.c
  gcc -O3 -Wall -c -o utils.o utils.c
  gcc -O3 -Wall -c -o http.o http.c
  gcc -O3 -Wall -c -o main.o main.c
  gcc -o swebs           \
         swebs.o         \
         soket.o         \
         utils.o         \
         http.o          \
         main.o          \
        -lpthread -lcurl -lcrypt
  gcc -Os -Wall -c -o cong.o cong.c
  gcc -o cong cong.o soket.o http.o swebs.o utils.o -lcurl -lcrypt
                                                                                                

STEP 3. Optionally, configuring the server

For now, just skip this step. You can do it later if you want, see below.

STEP 4. Running the server

Type ./swebs to run the server and make sure it's working. In the address line of your favorite browser type


  http://localhost:8080/docs/using.html

You should see same text you are reading just now. Also take a look into .log/access.log file - you'll see something like this:


  127.0.0.1(#7) [date1-date2] "GET /docs/using.html" (152+2362/2362) 200
  127.0.0.1(#8) [date1-date2] "GET /docs/yops.css"   (152+1163/1163) 200
  127.0.0.1(#9) [date1-date2] "GET /docs/yops.png"   (135+76/76)     200

First element in each line of the log is IP address of a client (with sequential number of a request in the same persistent connection, in parentheses), second element contains two dates (request begin-end), third one is HTTP request line sent by the client, fourth one is the number if bytes sent to client (http_header+sent/total) and the last one is HTTP status code.

STEP 5. Writing your own pages

Now you can add your own HTML pages into ~/www directory. When doing this keep in mind the following:

Configuring the server

Configuration is in the .conf/config file. First note you must restart the server in order to changes take effect. Just press ^c to terminate the server, edit config then run the server again.

Following parameters can be configured (some may be unimplemented, in this case the server says "Line # ignored" upon startup):