Python cgi scripts .py not work 403

Discussion in 'Installation/Configuration' started by Ripeed, Dec 12, 2014.

  1. Ripeed

    Ripeed Member

    I am done:( I need to run .py on my ISPconfig 3 server by perfect server tutorial.

    I check set up by http://www.howtoforge.com/embedding-python-in-apache2-with-mod_python-debian-etch.

    I have one name.domain.tld. I see 403 error. (index.py)
    I have one other testing in there test_cgi.py
    Code:
    #!/usr/bin/env python
    
    import cgi
    cgi.test()
    
    This give me an 404 error.

    My seting in ispconfig apache directives are:
    Code:
    <Directory /var/www/clients/client1/web1/web>
      Options +ExecCGI
      AllowOverride All
      DirectoryIndex index.py
      AddHandler cgi-script .cgi .py
      PythonHandler mod_python.publisher
      PythonDebug on
      Order allow,deny
      Allow from all
    </Directory>
    
    VHosts file is:
    Code:
    <Directory /var/www/name.domain.tld>
                    AllowOverride None
                                    Order Deny,Allow
                    Deny from all
                    </Directory>
    
    <VirtualHost *:80>
                                            DocumentRoot /var/www/name.domain.tld/web
    
                    ServerName name.domain.tld
                    ServerAdmin [email protected]
    
                    ErrorLog /var/log/ispconfig/httpd/name.domain.tld/error.log
    
                    Alias /error/ "/var/www/name.domain.tld/web/error/"
                    ErrorDocument 400 /error/400.html
                    ErrorDocument 401 /error/401.html
                    ErrorDocument 403 /error/403.html
                    ErrorDocument 404 /error/404.html
                    ErrorDocument 405 /error/405.html
                    ErrorDocument 500 /error/500.html
                    ErrorDocument 502 /error/502.html
                    ErrorDocument 503 /error/503.html
    
                    <IfModule mod_ssl.c>
                    </IfModule>
    
                    <Directory /var/www/name.domain.tld/web>
                                    # Clear PHP settings of this website
                                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                                                    SetHandler None
                                    </FilesMatch>
                                    Options +FollowSymLinks
                                    AllowOverride All
                                                                    Order allow,deny
                                    Allow from all
                                                    </Directory>
                    <Directory /var/www/clients/client1/web1/web>
                                    # Clear PHP settings of this website
                                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                           SetHandler None
                                    </FilesMatch>
                                    Options +FollowSymLinks
                                    AllowOverride All
                                                                    Order allow,deny
                                    Allow from all
                                                    </Directory>
    
    
    
                    <IfModule mod_python.c>
                            <Directory /var/www/name.domain.tld/web>
                                    <FilesMatch "\.py$">
                                            SetHandler mod_python
                                    </FilesMatch>
                                    PythonHandler mod_python.publisher
                                    PythonDebug On
                            </Directory>
                    </IfModule>
    
                    # cgi enabled
            <Directory /var/www/clients/client1/web1/cgi-bin>
                                                    Order allow,deny
                            Allow from all
                                            </Directory>
                    ScriptAlias  /cgi-bin/ /var/www/clients/client1/web1/cgi-bin/
                    <FilesMatch "\.(cgi|pl)$">
                            SetHandler cgi-script
                    </FilesMatch>
                    # suexec enabled
                    <IfModule mod_suexec.c>
                            SuexecUserGroup web1 client1
                    </IfModule>
                    # php as fast-cgi enabled
            # For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
                    <IfModule mod_fcgid.c>
                                    IdleTimeout 300
          ProcessLifeTime 3600
                                    # MaxProcessCount 1000
                                    DefaultMinClassProcessCount 0
                                    DefaultMaxClassProcessCount 100
                                    IPCConnectTimeout 3
                                    IPCCommTimeout 600
                                    BusyTimeout 3600
                    </IfModule>
                    <Directory /var/www/name.domain.tld/web>
                                    <FilesMatch "\.php[345]?$">
                                            SetHandler fcgid-script
                                    </FilesMatch>
                                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
                                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php3
                                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php4
                                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php5
                                    Options +ExecCGI
                                    AllowOverride All
                                                                    Order allow,deny
                                    Allow from all
                                                    </Directory>
                    <Directory /var/www/clients/client1/web1/web>
                                    <FilesMatch "\.php[345]?$">
                                            SetHandler fcgid-script
                                    </FilesMatch>
                                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
                                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php3
                                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php4
                                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php5
                                    Options +ExecCGI
                                    AllowOverride All
                                                                    Order allow,deny
                                    Allow from all
                                                    </Directory>
    
    
                    # add support for apache mpm_itk
                    <IfModule mpm_itk_module>
                            AssignUserId web1 client1
                    </IfModule>
    
                    <IfModule mod_dav_fs.c>
                    # Do not execute PHP files in webdav directory
                            <Directory /var/www/clients/client1/web1/webdav>
                                    <ifModule mod_security2.c>
                                            SecRuleRemoveById 960015
                                            SecRuleRemoveById 960032
                                    </ifModule>
                                    <FilesMatch "\.ph(p3?|tml)$">
                                            SetHandler None
                                    </FilesMatch>
                            </Directory>
                            DavLockDB /var/www/clients/client1/web1/tmp/DavLock
                            # DO NOT REMOVE THE COMMENTS!
                            # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                            # WEBDAV END
                    </IfModule>
    
    <Directory /var/www/clients/client1/web1/web>
      Options +ExecCGI
      AllowOverride All
      DirectoryIndex index.py
      AddHandler cgi-script .cgi .py
      PythonHandler mod_python.publisher
      PythonDebug on
      Order allow,deny
      Allow from all
    </Directory>
    </VirtualHost>
    
    And error apache log:
    Code:
    [Fri Dec 12 13:26:51 2014] [error] [client IP] (13)Permission denied: Can't open directory for index: /var/www/name.domain.tld/web/
    
    Cant' anyone please give me right advice? Thanks a lot!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

  3. Ripeed

    Ripeed Member

  4. till

    till Super Moderator Staff Member ISPConfig Developer

    In your custom apache directive, try this directory path:

    /var/www/name.domain.tld/web

    instead of:

    /var/www/clients/client1/web1/web
     
  5. Ripeed

    Ripeed Member

    Nope, that didnt work. One chage made. When I called name.domain.tld I haved 403 now I get 404.

    I read somethink about SElinux. Can be it? And I try to set web security to medium in icpconfig.
     
    Last edited: Dec 12, 2014
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, thats better. Please post the exact 404 error message from log file.
     
  7. Ripeed

    Ripeed Member

    Thanks Till, here is it:
    Code:
    [Fri Dec 12 15:27:13 2014] [error] [client IP] (13)Permission denied: Can't open directory for index: /var/www/name.domain.tld/web/
    
    Its same as before.
     
  8. Ripeed

    Ripeed Member

    Still cant find solution, I get an notice now:
    Code:
    [Fri Jan 09 12:02:42 2015] [notice] mod_python (pid=26364, interpreter='sub.domain.tld'): Importing module '/var/www/sub.domain.tld/web/index.py'
    
     
  9. Ripeed

    Ripeed Member

    Still dont get a soliton. After browsig some threds still dont have no idea. :( Anyone?
     

Share This Page