Ring CGI Error on ubuntu 17.04 , appache2

267 views
Skip to first unread message

Salama Ashoush

unread,
Oct 9, 2017, 8:53:15 AM10/9/17
to ring...@googlegroups.com
Hello Mahmoud
this log from my appache error.log

AH01215: (8)Exec format error: exec of '/var/www/cgi-bin/hw.ring' failed: /var/www/cgi-bin/hw.ring
[Mon Oct 09 14:38:09.742225 2017] [cgi:error] [pid 4312] [client 127.0.0.1:54338] End of script output before headers: hw.ring


here is my steps:
  1. configure appache to run cgi scripts and test it with other scripts like perl 
  2. created a file with this code in my cgi-bin dir:
#!/usr/bin/ring -cgi
See "content-type : text/html" +nl+nl+
"Hello World!" + nl


when try to run the code with ring from the terminal it runs and output the text 

extra : i wonder if there any other way or plans for web development rather than cgi  ( built in server like python or other web languages )  

Mahmoud Fayed

unread,
Oct 10, 2017, 9:06:35 PM10/10/17
to The Ring Programming Language
Hello Salama

Follow the steps in this tutorial
http://watanydev.blogspot.com.eg/2016/02/tutorial-how-to-configure-xampp-to.html

Be sure that the scripts are executable (Permission)

Greetings,
Mahmoud

Salama Ashoush

unread,
Oct 10, 2017, 9:51:34 PM10/10/17
to ring...@googlegroups.com
Hello Mahmoud
i am not working with Xampp , i have apache2 installed on my ubuntu system and it is working with other cgi scripts like perl , bash , ... etc 
here is my cgi configuration
<IfModule mod_alias.c>
<IfModule mod_cgi.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>

<IfModule mod_cgid.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>
<IfDefine ENABLE_USR_LIB_CGI_BIN>
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
AddHandler cgi-script .cgi .ring
<Directory "/var/www/cgi-bin">
AllowOverride None
DirectoryIndex index.cgi index.html index.ring
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
</IfDefine>
</IfModule>

Mahmoud Fayed

unread,
Oct 12, 2017, 6:04:22 AM10/12/17
to The Ring Programming Language
Hello Salama

Follow the next steps from the documentation
http://ring-lang.sourceforge.net/doc1.5.4/web.html#configure-the-apache-web-server

Greetings,
Mahmoud
Message has been deleted

Salama Ashoush

unread,
Oct 12, 2017, 10:16:58 AM10/12/17
to ring...@googlegroups.com
Hello Mahmoud

Finally i found the solution
here is my steps:
  1. configure Apache server to run cgi scripts /etc/apache2/conf-enabled/serve-cgi-bin.conf 
     
  1. <IfModule mod_cgi.c>
                Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>


    <IfModule mod_cgid.c>
               Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>
         
    <IfDefine ENABLE_USR_LIB_CGI_BIN>
           ScriptAlias /cgi-bin/ /var/www/cgi-bin/
           AddHandler cgi-script .cgi .ring
           
    <Directory "/var/www/cgi-bin">

  1.              AllowOverride All

  1.              DirectoryIndex index.cgi index.html index.ring
                 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                 Require all granted
             
  1. </Directory>
    </IfDefine>
    </IfModule>


  2. make sure you cgi folder has the right owner  
    sudo chown $USER:www-data /var/www/cgi-bin/

  3. create .ring file in your cgi folder and give it execute permissions
    sudo chmod 755 hw.ring

  4. write your code with this shebang on top of the file
    #!/usr/bin/env ring

  5. hello world test 
    #!/usr/bin/env ring
    see
    "content-type: text/html"+nl+nl
    see
    "hello world!" + nl

  6. if you need to use web lib copy the file to you cgi folder and give it execute permissions the load it to your code and have fun
    #!/usr/bin/env ring

    Load "weblib.ring"
    Import System.Web

    New Page
    {
            Text("Hello World!")
    }
  7. go to
    localhost/cgi-bin/yourfile.ring
    to test your code
thanks mahmoud ,
i hope someday ring will have built in web-server it will be very nice

Best Regards

Mahmoud Fayed

unread,
Oct 12, 2017, 10:58:32 PM10/12/17
to The Ring Programming Language
Hello Salama

I agree with you, We should have a Web Server + Advanced Web Framework in the future.

Keep up the good work :D

Greetings,
Mahmoud
Reply all
Reply to author
Forward
0 new messages