slash-lang / slash

A new language for the web
http://slash-lang.org
MIT License
386 stars 22 forks source link

I need a tutorial #47

Open naturalmechanics opened 9 years ago

naturalmechanics commented 9 years ago

Hello

I would like to use this. However, I would need a tutorial, on how to set up a complete environment in my laptop. I am running cherokee to serve to outside world. How do I use slash with it? Do I make a slash page to dump its output to a socket? This can be achined by calling slash-cgi - like here : https://github.com/slash-lang/slash/tree/master/sapi/cgi , and then read it out by cherokee? Or is there a parser module that goes through the page, performs parsing and so on? How are the get / post methods handled? I need some simple directions to get started with this. Thank you.

PS : Current setup :

  1. Cherokee running.
  2. Did not find slash in the official LXLE repos . DOwnloaded the GIT repo using the zip file in the github page.
  3. will get started with installing as soon as I get an heads up from you guys.
vstm commented 9 years ago

Yes, slash-cgi should work with any webserver that supports FastCGI, which is the case with cherokee. This is just a quick step-by-step intro on how it can be done. I have tested it on debian, which should be somewhat similar to LXLE.

First you need to compile slash:

# Install the required development files: 
sudo apt-get install flex libgmp-dev libfcgi-dev ruby
# Install the optional development files: 
sudo apt-get install libpcre3-dev libgcrypt11-dev libyajl-dev libmarkdown2-dev libcurl4-openssl-dev libmysqlclient-dev
# In the directory where you unzipped slash you compile it
./configure --sapi=cgi --sapi=cli
make
sudo make install

By default slash is installed in /usr/local/bin/, so the CGI-binary would be /usr/local/bin/slash-cgi.

So next to the cherokee-configuration. In the cherokee-admin panel go to Information Sources.

Add a new information source. In the nick field you can type in slash and in the Connection field you can put 127.0.0.1:1234. After the source has been added you can set the Type of the "slash" source to "Local interpreter". Now you can enter /usr/local/bin/slash-cgi -b 127.0.0.1:1234 into the Interpreter field. You can use any port instead of 1234, you just have to change it both in the Interpreter and in the Connection field. You could leave the Type as Remote, but then you'd have to start slash yourself.

Now head over to the virtual server (vServers) section, select the server you want to use slash with and go to the "Behavior" tab, and click on Rule Management.

Add a new rule with Rule type "Extension" and in the Extensions-Field simply add sl. After you have clicked on Add the new Rule is automatically opened.

In the Handler tab (which is opened by default) select the "FastCGI" handler. Scroll down to "FastCGI Specific" and select the Round Robin balancer. Now under "Assign Information Sources" you can select the "slash" Information Source you have created earlier. Now save, restart and enjoy.

Now you could also add "index.sl" to the "Directory Indexes" field of the Virtual Server Basics.

Hope that helps, tell me if you're stuck somewhere.

naturalmechanics commented 9 years ago

Hello

Thank you for this, I tried to do this, but it ends with this error:

:(.text+0x259): undefined reference to `sl_get_ptr' /tmp/cceYyCR3.ltrans0.ltrans.o: In function`main': :(.text.startup+0x3f): undefined reference to `sl_static_init' :(.text.startup+0x4e): undefined reference to`sl_init' :(.text.startup+0x64): undefined reference to `sl_gc_set_stack_top' :(.text.startup+0x6c): undefined reference to`sl_environ' :(.text.startup+0x142): undefined reference to `sl_alloc' :(.text.startup+0x1a7): undefined reference to`sl_request_set_opts' :(.text.startup+0x1e0): undefined reference to `sl_response_set_opts' :(.text.startup+0x2d4): undefined reference to`sl_make_array' :(.text.startup+0x30f): undefined reference to `sl_make_cstring' :(.text.startup+0x32a): undefined reference to`sl_array_push' :(.text.startup+0x354): undefined reference to `sl_class_set_const' :(.text.startup+0x4a3): undefined reference to`sl_require_path_prepend' :(.text.startup+0x4ca): undefined reference to `sl_unwind' :(.text.startup+0x639): undefined reference to`sl_to_s_no_throw' :(.text.startup+0x644): undefined reference to `sl_get_ptr' :(.text.startup+0x765): undefined reference to`sl_do_string' :(.text.startup+0x7a5): undefined reference to `sl_get_int' collect2: Fehler: ld gab 1 als Ende-Status zurück (translation : ld returned status 1) Makefile:6: die Regel für Ziel „slash-cli“ scheiterte (the rule for target slash-cli failed) make[1]: **\* [slash-cli] Fehler 1 I am on Archbang, an arch derivative.
vstm commented 9 years ago

Can you try the following:

make clean
AR=gcc-ar make

Does that work?

naturalmechanics commented 9 years ago

Yes, it is installed now, thank you. I will ask a few questions during the test phase.