Installing Livecode Server in cgi-bin[SOLVED]

Discussion in 'Programming/Scripts' started by jjsjjs, Oct 19, 2019.

  1. jjsjjs

    jjsjjs Member

    Hello,
    i hope i'm posting in the correct forum section and that someone has some insight.
    Although i have Livecode Community Server running ok for tests in Xampp on WIndows.
    Installing or getting it to work on VPS Ubuntu 18.04 server with Apache is a bit more difficult. Getting either a 501 or a 403 error, so it seems like i'm progressing a bit.
    So i have the Perfect Ubuntu server with ispconfig running and want to use Livecode next to PHP. PHP is a great language, but so is Livecode also.
    But following this http://lessons.livecode.com/m/4070/l/36652-how-do-i-install-livecode-server-on-linux-with-apache and also the pre-last comment, and also following this http://lessons.livecode.com/m/4070/l/36655-how-do-i-install-livecode-server-with-apache-via-htaccess, i still do not have it working.
    The instructions on those links seem not exactly for the current versions of Apache.
    I'm having trouble which conf file to alter exactly: so it tried Apache2.conf and 100-mywebsite.com.vhost and also this one /etc/apache2/sites-enabled/000-default.conf.
    Which file is best to alter in this case?
    And in which cgi-bin folder should i put the server files?
    I've putted it here: /var/www/clients/client0/web1/web/cgi-bin/livecode-community-server (i added this cgi-bin folder in the web folder)
    here: /var/www/clients/client0/web1/cgi-bin/livecode-community-server
    and here: /usr/lib/cgi-bin (as was written in one of the comments in above install lessons links)
    Neither seem to be working, but that's maybe because not the correct conf file is altered.

    So in fact it's a cgi based server and files have the extension lc instead of html or php, but best it's to compare with php files.

    Thanks for any help on this.

    Jerry
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

  3. jjsjjs

    jjsjjs Member

    Thank you Taleman.
    I though this could be an appropriate section to post because of scripting.

    Yes ISPconfig is working ok.
    But LC server not yet.
    Just like php is called in scripts <?php scriptblabla ?>, Livecode is called similair <?lc scriptblabla ?>

    Which conf file is best to alter and redirect lc files to get to the engine?

    Thanks!
    *edit* here is the info about the server:

    Code:
    ##### SERVER #####
    IP-address (as per hostname): ***.***.***.***
    [WARN] could not determine server's ip address by ifconfig
    [INFO] OS version is Ubuntu 18.04.3 LTS
    
    [INFO] ISPConfig is installed.
    
    ##### ISPCONFIG #####
    ISPConfig version is 3.1.15
    
    
    ##### VERSION CHECK #####
    
    [INFO] php (cli) version is 7.2.19-0ubuntu***.***.***.***
    
    ##### PORT CHECK #####
    
    
    ##### MAIL SERVER CHECK #####
    
    [WARN] I found no "submission" entry in your postfix master.cf
    [INFO] this is not critical, but if you want to offer port 587 for smtp connecti
    ons you have to enable this.
    
    ##### RUNNING SERVER PROCESSES #####
    
    [INFO] I found the following web server(s):
            Apache 2 (PID 4027)
    [INFO] I found the following mail server(s):
            Postfix (PID 1371)
    [INFO] I found the following pop3 server(s):
            Dovecot (PID 930)
    [INFO] I found the following imap server(s):
            Dovecot (PID 930)
    [INFO] I found the following ftp server(s):
            PureFTP (PID 1300)
    
    ##### LISTENING PORTS #####
    (only           ()
    Local           (Address)
    [anywhere]:993          (930/dovecot)
    [anywhere]:995          (930/dovecot)
    [localhost]:10023               (1194/postgrey)
    [localhost]:10024               (1458/amavisd-new)
    [localhost]:10025               (1371/master)
    [localhost]:10026               (1458/amavisd-new)
    [localhost]:10027               (1371/master)
    [localhost]:11211               (918/memcached)
    [anywhere]:110          (930/dovecot)
    [anywhere]:143          (930/dovecot)
    [anywhere]:465          (1371/master)
    [anywhere]:21           (1300/pure-ftpd)
    ***.***.***.***:53              (921/named)
    [localhost]:53          (921/named)
    ***.***.***.***:53              (617/systemd-resolve)
    [anywhere]:22           (970/sshd)
    [anywhere]:25           (1371/master)
    [localhost]:953         (921/named)
    *:*:*:*::*:993          (930/dovecot)
    *:*:*:*::*:995          (930/dovecot)
    *:*:*:*::*:10024                (1458/amavisd-new)
    *:*:*:*::*:10026                (1458/amavisd-new)
    *:*:*:*::*:3306         (1119/mysqld)
    [localhost]10           (930/dovecot)
    [localhost]43           (930/dovecot)
    *:*:*:*::*:8080         (4027/apache2)
    *:*:*:*::*:80           (4027/apache2)
    *:*:*:*::*:8081         (4027/apache2)
    *:*:*:*::*:465          (1371/master)
    *:*:*:*::*:21           (1300/pure-ftpd)
    *:*:*:*::*:53           (921/named)
    *:*:*:*::*:22           (970/sshd)
    *:*:*:*::*:25           (1371/master)
    *:*:*:*::*:953          (921/named)
    *:*:*:*::*:443          (4027/apache2)
    
    ##### IPTABLES #####
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination
    f2b-sshd   tcp  --  [anywhere]/0            [anywhere]/0            multiport dports 22
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination
    
    Chain f2b-sshd (1 references)
    target     prot opt source               destination
    REJECT     all  --  ***.***.***.***      [anywhere]/0            reject-with icmp-port-unreachable
    REJECT     all  --  ***.***.***.***         [anywhere]/0            reject-with icmp-port-unreacha
    ble
    REJECT     all  --  ***.***.***.***       [anywhere]/0            reject-with icmp-port-unreachabl
    e
    RETURN     all  --  [anywhere]/0            [anywhere]/0
     
    Last edited: Oct 20, 2019
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    What show commands
    Code:
    ls -lh /var/www/clients/client0/web1/web/
    ls -lh /var/www/clients/client0/web1/cgi-bin
    If you at all care about posting readable text, do post code and listings in CODE tags.
    You showed two installation instructions. They seem to be two distict ways to install livecode, so you should do only one of them. If you have followed both, the installation may be messed up.
    As for the apache directives, add them in ISPConfig Panel website Options -tab. This way the affect only one website, so you do not break everything on your host. More info on this in ISPConfig manual. If you do not what to do it this way, show what is now in the apache configuration files you modified (show in CODE tags, please).
     
  5. jjsjjs

    jjsjjs Member

    Thank you.
    This is what the commands show:
    Code:
     ls -lh /var/www/clients/client0/web1/web/
    total 128K
    drwxr-xr-x 2 web1 client0 4.0K Mar 24  2019 error
    -rwxr-xr-- 1 web1 client0 7.2K Mar 24  2019 favicon.ico
    -rw-r--r-- 1 root root     250 Oct 18 20:55 hello.lc
    -rw-r--r-- 1 root root     121 Oct 19 14:31 htaccess.txtlc
    -rwxr-xr-- 1 web1 client0  539 Mar 24  2019 index.html
    -rw-r--r-- 1 root root     70K Mar 24  2019 logo.png
    drwxr-xr-x 2 root root    4.0K Oct 10 17:19 som_ext_sft
    drwxr-xr-x 2 root root    4.0K Sep 15 15:33 somwebbuy
    drwxr-xr-x 3 root root     12K Oct 15 19:29 somtifs
    drwxr-xr-x 3 root root    4.0K Mar 24  2019 som
    -rwxr-xr-- 1 web1 client0   14 Mar 24  2019 robots.txt
    drwxr-xr-x 9 web1 client0 4.0K Oct 20 00:03 stats
    Code:
    ls -lh /var/www/clients/client0/web1/cgi-bin
    total 23M
    drwxr-xr-x 2 root root 4.0K Oct 19 13:56 drivers
    drwxr-xr-x 2 root root 4.0K Oct 19 13:56 externals
    -rw-r--r-- 1 root root  23M Jul 30 21:02 livecode-community-server
    yes the .htaccess way prevented the loading of hello.lc, so i renamed it.
    Still the code is not executed
    But i tried the .htaccess way too as it did the trick with xammp (after altering some conf files as i remember)

    First i tried this in apache2.conf:
    Code:
    <Directory "/var/www/">
    
    Options Indexes FollowSymLinks MultiViews
    
    AllowOverride None
    
    Order allow,deny
    
    allow from all
    
    AddHandler livecode-script .lc
    
    Action livecode-script /livecode-cgi/livecode-server
    
    </Directory>
    
    <Directory "<path to LiveCode Server folder>">
    
    Options ExecCGI
    
    Order allow,deny
    
    Allow from all
    
    </Directory>
    
    ScriptAlias /livecode-cgi/livecode-server "<path to LiveCode Server folder>/livecode-server"
    But i removed it. (of course with the correct paths)

    Now in file /etc/apache2/sites-enabled/000-default.conf :
    Code:
    <VirtualHost *:80>
       # The ServerName directive sets the request scheme, hostname and port that
       # the server uses to identify itself. This is used when creating
       # redirection URLs. In the context of virtual hosts, the ServerName
       # specifies what hostname must appear in the request's Host: header to
       # match this virtual host. For the default virtual host (this file) this
       # value is not decisive as it is used as a last resort host regardless.
       # However, you must set it for any further virtual host explicitly.
       #ServerName www.example.com
    
       ServerAdmin webmaster@localhost
       DocumentRoot /var/www/html
      
       AddHandler livecode-script .lc
       Action livecode-script /var/www/clients/client0/web1/cgi-bin/livecode-community-server
      
       # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
       # error, crit, alert, emerg.
       # It is also possible to configure the loglevel for particular
       # modules, e.g.
       #LogLevel info ssl:warn
    
       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
    
       # For most configuration files from conf-available/, which are
       # enabled or disabled at a global level, it is possible to
       # include a line for only one particular virtual host. For example the
       # following line enables the CGI configuration for this host only
       # after it has been globally disabled with "a2disconf".
       Include conf-available/serve-cgi-bin.conf    #this line is uncommented by me as described in the comments at the insallation instruction for LC server
    </VirtualHost>
    
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
    So you actually mean to put this:
    Code:
     AddHandler livecode-script .lc
       Action livecode-script /var/www/clients/client0/web1/cgi-bin/livecode-community-server
    into the menioned tab in ispconfig, correct?
     
  6. jjsjjs

    jjsjjs Member

    i added this to the options tab:
    Code:
    <Directory /var/www/clients/client0/web1/cgi-bin>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    AddHandler livecode-script .lc
    Action livecode-script /var/www/clients/client0/web1/cgi-bin/livecode-community-server
    </Directory>
    
    <Directory /var/www/clients/client0/web1/cgi-bin>
    Options ExecCGI
    Order allow,deny
    Allow from all
    </Directory>
    
    ScriptAlias /livecode-cgi/livecode-community-server "/var/www/clients/client0/web1/cgi-bin/livecode-community-server"
    and removed all i added to the conf files. (i made backups)

    uncommenting or (re)-commenting this line:
    Code:
    Include conf-available/serve-cgi-bin.conf
    in 000-default.conf seems thus far not of any influence

    So the hello.lc is loading and showing the normal html code but is not yet executing the lc code.
     
  7. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Fix owner of website files, the cgi-bin subtree should be owner and group owner the website owner and client.
    Code:
    chown -R -web1:client0 /var/www/clients/client0/web1/cgi-bin
    Make livecode program executable:
    Code:
    chmod a+x /var/www/clients/client0/web1/cgi-bin/livecode-community-server
    
    It is better to copy and edit website files as the website owner. If you do that as root, you have to remember to chown them.
    After the above fixes, try again and read http access and error logs for clues if it still does not work.
     
  8. jjsjjs

    jjsjjs Member

    I see i forgot to add a client(as i am the only one i thought i did not need one) anyway client0 is changed to client1.
    i always upload via WinSCP as root indeed.
    I did all the above (the - before web1 with the chown command creates an error, so left it out)
    also chmod it.
    Also changed the apache thing on th eoptions tab to match client1
    restarted apache, did not help, then restarted the server,did also not help.

    the only error in the log file i see is this:
    Code:
    phpmyadmin: Failed to load /var/lib/phpmyadmin/config.inc.php Check group www-data has read access and open_basedir restrictions.
    now in the lesson of installing LC server there is also mentioned to load i386 drivers but i don't think i need them right, because i use the 64 LC server and the Linux server is also 64 bits.
     
  9. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Is the livecode-community-server 32-bit? If yes, you have to install 32 runtime libraries. I do not know what OS you have, so do not know how to do that.
     
  10. jjsjjs

    jjsjjs Member

    i have the 64bits version in the cgi-bin folder and server is running on Ubuntu 18.04 64 bits
     
  11. jjsjjs

    jjsjjs Member

    I tried another thing, i removed the apache directives from the website options tab, and tried it first in 000-default.conf but that does nothing but error 404.
    Then i removed that, and added the apache directives to mywebsite.com.vhost. i noticed it has the same effect as adding it to the website options tab.
    It loads the page but does not execute the lc script part.
    Any other suggestions i could check or test?
    Thanks!
     
  12. jjsjjs

    jjsjjs Member

  13. jjsjjs

    jjsjjs Member

    Yes!! got it running finally, never give up.
    So got 2 choices which both work: alter 2 scripts on the server or alter 1 script and add a piece to ISPconfig website-->option tab
    I tested them both and work ok now pfeew!

    First i added a folder cgi-bin into /var/www/clients/client1/web1/web/ so i'm not using the cgi-bin which is already in web1, and copied the LC server into it

    i added this to 000-default.conf which is in etc/lib/apache2/sites-available (make a backup of the file first)
    You need this else either choice below will not work:
    Code:
    AddHandler livecode-script .lc
       Action livecode-script /cgi-bin/livecode-community-server
    Then added this to mywebsite.nl.vhost (which is also in etc/lib/apache2/sites-available)(make a backup first) just before the rewrite part in both the 80 and 443 (http/https) section:
    Or the other choice is when using ISPconfig add this to the website-->options tab into the Apache directives
    Code:
       #livecodeserver#
    <Directory /var/www/clients/client1/web1/web/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    AddHandler livecode-script .lc
    Action livecode-script /livecode-cgi/livecode-community-server
    </Directory>
    
    <Directory /var/www/clients/client1/web1/web/cgi-bin>
    Options ExecCGI
    Order allow,deny
    Allow from all
    </Directory>
    
    ScriptAlias /livecode-cgi/ /var/www/clients/client1/web1/web/cgi-bin/
    ###############
    But most important here was the ScriptAlias which was pointing to the wrong dir and does not need quotes and neither the lc-community-server at the end
    I blindly copied it from the LC lessons, but examining the vhost script which also contains directives to perl and apache it becomes clear it's not correct
    .htaccess altering is not needed

    then sudo service apache restart in Putty terminal
    and run a test lc script like https://mywebsite.com/hello.lc

    Probably there will be a better way but it works
     

Share This Page