HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=27)
-   -   Python on ISPconfig3 server (http://www.howtoforge.com/forums/showthread.php?t=57243)

Ripeed 10th May 2012 17:51

Python on ISPconfig3 server
 
Hi gurus, need help. I have working solution with ispconfig 3. About 30 web pages on server and etc.

When I try some test if python work like this:

Code:

def index(req):
  return "Test successfil";

Results is in browser: Test successful.

But when I try some webpage more complicated or script based on python then page visualization stops on the python code and than nothing.

I think somethings wrong with showing python.

Any ideas? Thanks for help. :confused:

Ripeed 23rd May 2012 10:22

This is that script that does not work on server.
Its OK until starts call

Code:

include_once("./php_adlinks/adlinks.inc.php");
          echo adlinks_zobrazitListu("utf-8","curl");

Than the page is like without styles and the code of page ends until i call that.

Code:

<?

       
        define("SEO_LISTA_GETAD","http://adlinks.effectix.com/getad/getad.py?");
       

        function adlinks_zobrazitListu($encoding = "utf-8",$gettype = "fopen") {
                $RURL = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
                $RURL = trim($RURL,"/");
                $RURL_ENCODED = urlencode($RURL);
                $data = "";
                switch ($gettype) {
                        case "fopen":
                                @$fp = fopen(SEO_LISTA_GETAD."q=$RURL_ENCODED", "r");
                                if (!$fp) {
                                      @$fp = fopen(SEO_LISTA_GETAD."t=links&amp;q=$RURL_ENCODED", "r");
                            }
                            if ($fp) {
                                              while(!feof($fp)) {
                                            $data .= fread($fp, 2048);
                                              }
                                              fclose($fp);
                            }
                            break;
                        case "curl":
                                $curl = curl_init();
                                curl_setopt($curl, CURLOPT_URL, SEO_LISTA_GETAD."q=$RURL_ENCODED");
                                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                                $data = curl_exec($curl);
                                $info = curl_getinfo($curl);
                                curl_close($curl);
                                if ($info['http_code'] == 307) {
                                        $curl = curl_init();
                                        curl_setopt($curl, CURLOPT_URL, SEO_LISTA_GETAD."t=links&amp;q=$RURL_ENCODED");
                                        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                                        $data = curl_exec($curl);
                                        curl_close($curl);
                                }
                                break;
                        case "file_get_contents":
                                $data = file_get_contents(SEO_LISTA_GETAD."q=$RURL_ENCODED");                               
        $pos = strpos($http_response_header[0], "307");
    if ($pos === true) {
                                        $data = file_get_contents(SEO_LISTA_GETAD."t=links&amp;q=$RURL_ENCODED");
                                }
                                break;
                }
                if ($data != "") {
                        switch ($encoding) {
                                      case "windows-1250":
                                              $data = iconv("utf-8",$encoding,$data);
                                      break;
                                      case "iso-8859-2":
                                              $data = iconv("utf-8",$encoding,$data);
                                      break;
                                      default:
                                      break;
                              }
                              return $data;
            }
        }
?>


till 23rd May 2012 10:52

This script is php and not python.

Ripeed 23rd May 2012 10:57

Thanks, I know that but with:

define("SEO_LISTA_GETAD","http://adlinks.effectix.com/getad/getad.py?");

I call .py and thats python... and on this its stops...

It works on old server and when I moved it on new server with debian and ISPconfig3 its not work:(

till 23rd May 2012 11:04

With that php code you load a external URL, it does not matter in which programming language a external script is coded that you load with curl as you will get html back. So you dont execute a local python script here and you dont need python support on your server.

My guess is that you just dont have the php curl module installed. Install it with:

apt-get install php5-curl

and restart apache.

Ripeed 24th May 2012 15:04

Till, you have right, but when I try to update some package to install that feature it makes me trouble like this: Thread

till 24th May 2012 15:20

Check the apache error.log (/var/log/apache/error.log) for errors, especiall for vlogger errors.

Ripeed 24th May 2012 15:32

:confused:
I am very confused about that:

/var/log/apache2/error.log
Code:

[Thu May 24 10:27:41 2012] [error] [client CENSORED] PHP Notice:  Undefined index: on_after_update in /usr/local/ispconfig/interface/lib/classes/plugin.inc.php on line 139
[Thu May 24 10:27:41 2012] [error] [client CENSORED] PHP Notice:  Undefined index: dns:on_after_update in /usr/local/ispconfig/interface/lib/classes/plugin.inc.php on line 139
[Thu May 24 10:27:41 2012] [error] [client CENSORED] PHP Notice:  Undefined index: dns:dns_soa:on_after_update in /usr/local/ispconfig/interface/lib/classes/plugin.inc.php on line 139
[Thu May 24 10:27:51 2012] [error] [client CENSORED] PHP Notice:  Undefined index: on_after_insert in /usr/local/ispconfig/interface/lib/classes/plugin.inc.php on line 139
[Thu May 24 10:27:51 2012] [error] [client CENSORED] PHP Notice:  Undefined index: dns:on_after_insert in /usr/local/ispconfig/interface/lib/classes/plugin.inc.php on line 139
[Thu May 24 10:27:51 2012] [error] [client CENSORED] PHP Notice:  Undefined index: dns:dns_txt:on_after_insert in /usr/local/ispconfig/interface/lib/classes/plugin.inc.php on line 139
[Thu May 24 10:28:02 2012] [notice] caught SIGTERM, shutting down
[Thu May 24 10:32:30 2012] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu May 24 10:32:30 2012] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu May 24 10:32:30 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Thu May 24 10:32:30 2012] [notice] Digest: generating secret for digest authentication ...
[Thu May 24 10:32:30 2012] [notice] Digest: done
Use of uninitialized value $DBI_DUMP in alarm at /usr/local/ispconfig/server/scripts/vlogger line 538.
[Thu May 24 10:32:30 2012] [error] python_init: Python version mismatch, expected '2.6.5+', found '2.6.6'.
[Thu May 24 10:32:30 2012] [error] python_init: Python executable found '/usr/bin/python'.
[Thu May 24 10:32:30 2012] [error] python_init: Python path being used '/usr/lib/python2.6/:/usr/lib/python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-dynload'.
[Thu May 24 10:32:30 2012] [notice] mod_python: Creating 8 session mutexes based on 256 max processes and 0 max threads.
[Thu May 24 10:32:30 2012] [notice] mod_python: using mutex_directory /tmp
[Thu May 24 10:32:30 2012] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu May 24 10:32:30 2012] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu May 24 10:32:30 2012] [notice] Apache/2.2.16 (Debian) DAV/2 mod_fcgid/2.3.6 PHP/5.3.3-7+squeeze9 with Suhosin-Patch mod_python/3.3.1 Python/2.6.6 mod_ruby/1.2.6 Ruby/1.8.7(2010-08-16) mod_ssl/2.2.16 OpenSSL/0.9.8o configured -- resuming normal operations
[Thu May 24 10:33:48 2012] [error] [client CENSORED] PHP Notice:  Undefined variable: html_server in /usr/local/ispconfig/interface/web/monitor/show_sys_state.php on line 237
[Thu May 24 10:33:48 2012] [error] [client CENSORED PHP Notice:  Undefined index: nezn\xc3\xa1m\xc3\xbd in /usr/local/ispconfig/interface/web/monitor/show_sys_state.php on line 255
[Thu May 24 10:33:48 2012] [error] [client CENSORED] PHP Notice:  Undefined index: info in /usr/local/ispconfig/interface/web/monitor/show_sys_state.php on line 256

Do you see from that something what I can repair?

Ripeed 24th May 2012 17:50

If I change something in ISPconfig then I must kill Apache2 and start IT. :(

Help very appreciated :confused:

till 24th May 2012 18:15

Try to find out what you changed or installed which causes thes e apache instabilitys and then undo these steps. According to the error log something in the python installation is broken:

Python version mismatch, expected '2.6.5+', found '2.6.6'

so if you dont need python on that server then you should consdier to remove mod_python.


All times are GMT +2. The time now is 00:15.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.