Listing Directories and CGI

Discussion in 'Server Operation' started by vestport4, May 13, 2012.

  1. vestport4

    vestport4 New Member

    Hello, Running ISPCONFIG3 on 64 bit centos 5.8 Final

    Having problems configuring my system to list directories in

    Code:
    "/var/www/mydomain.com/web/files/"
    and running cgi in
    Code:
    /var/www/mydomain.com/web/files/cgi/
    I check /etc/httpd/conf/sites-enabled/mysite.com.vhost and noticed several of similar listings for the directory like:

    Code:
         <Directory /var/www/mydomain.com/web>
            AddHandler fcgid-script .php .php3 .php4 .php5
            FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
            Options +ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
            <Directory /var/www/clients/client1/web1/web>
            AddHandler fcgid-script .php .php3 .php4 .php5
            FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
            Options +ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    
    
    
    <Directory /var/www/mydomain.com/web>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
    
            # ssi enabled
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Options +Includes
     </Directory>
     <Directory /var/www/clients/client1/web1/web>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
    
            # ssi enabled
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Options +Includes
     </Directory>
    
    
     <Directory /var/www/mydomain.com/web>
            AddHandler fcgid-script .php .php3 .php4 .php5
            FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
            Options +ExecCGI
            AllowOverride All
            Order allow,deny

    A few questions:

    First: Does one entry with the same path just keep over writing the other?

    Second: Can I back this file up and regenerate a default file without blowing away the domain & web files etc.

    Third: Is it safe to edit directly (with a backup of course)?

    Fourth: Will anything overwrite this file automatically in the future (updates)?


    Tried apache directives from the ISPCONFIG console and no luck. Also, tried apache directives for a different domain to try to +Indexes etc. and no luck. In fact on the other domain after /etc/init.d/httpd restart I don't even see the updates in the .vhost file.

    Also, just wanted to mention that NO I don't have any .htaccess file in these directories.

    I do however have Joomla installed. Not sure if that is a deal breaker or need to chmod special permissions.




    Here is the entire .vhost file for the domain in question below:

    <Directory /var/www/myhost.com>
    AllowOverride None
    Order Deny,Allow
    Deny from all
    </Directory>

    <VirtualHost *:80>
    DocumentRoot /var/www/myhost.com/web

    ServerName myhost.com
    ServerAlias www.myhost.com
    ServerAlias renrealtors.myhost.com
    ServerAlias mail.myhost.com
    ServerAlias mls.myhost.com
    ServerAlias admin.myhost.com
    ServerAlias office.myhost.com
    ServerAlias preforeclosures.myhost.com
    ServerAlias joomla.myhost.com
    ServerAlias shortsales.myhost.com
    ServerAdmin webmaster@myhost.com

    ErrorLog /var/log/ispconfig/httpd/myhost.com/error.log

    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 503 /error/503.html

    <Directory /var/www/myhost.com/web>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

    # ssi enabled
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    Options +Includes
    </Directory>
    <Directory /var/www/clients/client1/web1/web>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

    # ssi enabled
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    Options +Includes
    </Directory>

    <IfModule mod_ruby.c>
    <Directory /var/www/clients/client1/web1/web>
    Options +ExecCGI
    </Directory>
    RubyRequire apache/ruby-run
    #RubySafeLevel 0
    <Files *.rb>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
    </Files>
    <Files *.rbx>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
    </Files>
    </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/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl
    # suexec enabled
    SuexecUserGroup web1 client1
    # Clear PHP settings of this website
    <FilesMatch "\.ph(p3?|tml)$">
    SetHandler None
    </FilesMatch>
    # php as fast-cgi enabled
    <IfModule mod_fcgid.c>

    # SocketPath /tmp/fcgid_sock/

    # IdleTimeout n (3600 seconds)
    # An idle fastcgi application will be terminated after IdleTimeout sec
    onds.
    IdleTimeout 3600

    # ProcessLifeTime n (7200 seconds)
    # A fastcgi application will be terminated if lifetime expired, even no error is detected.
    ProcessLifeTime 7200

    # MaxProcessCount n (1000)
    # The max count of total fastcgi process count.
    # MaxProcessCount 1000

    # DefaultMinClassProcessCount n (3)
    # The minimum number of fastcgi application instances for any one fastcgi application.
    # Idle fastcgi will not be killed if their count is less than n
    # Set this to 0, and tweak IdleTimeout
    DefaultMinClassProcessCount 0

    # DefaultMaxClassProcessCount n (100)
    # The maximum number of fastcgi application instances allowed to run for
    # particular one fastcgi application.
    DefaultMaxClassProcessCount 100
    # IPCConnectTimeout n (3 seconds)
    # The connect timeout to a fastcgi application.
    IPCConnectTimeout 8

    # IPCCommTimeout n (20 seconds)
    # The communication timeout to a fastcgi application. Please increase this
    # value if your CGI have a slow initialization or slow respond.
    IPCCommTimeout 360

    # BusyTimeout n (300 seconds)
    # A fastcgi application will be terminated if handing a single request
    # longer than busy timeout.
    BusyTimeout 300

    </IfModule>
    <Directory /var/www/myhost.com/web>
    AddHandler fcgid-script .php .php3 .php4 .php5
    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
    Options +ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    <Directory /var/www/clients/client1/web1/web>
    AddHandler fcgid-script .php .php3 .php4 .php5
    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
    Options +ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^renrealtors.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/files/renrealtors/$1 [L]
    RewriteCond %{HTTP_HOST} ^mail.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com:8080/webmail/$1 [R,L]
    RewriteCond %{HTTP_HOST} ^mls.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/files/mls/$1 [L]
    RewriteCond %{HTTP_HOST} ^admin.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com:8080/$1 [L]
    RewriteCond %{HTTP_HOST} ^office.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/files/office/$1 [L]
    RewriteCond %{HTTP_HOST} ^preforeclosures.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/files/preforeclosures/$1 [L]
    RewriteCond %{HTTP_HOST} ^joomla.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/administrator/$1 [L]
    RewriteCond %{HTTP_HOST} ^shortsales.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.vesport.com/files/preforeclosures/$1 [L]

    # add support for apache mpm_itk
    <IfModule mpm_itk_module>
    AssignUserId web1 client1
    </IfModule>

    <IfModule mod_dav_fs.c>
    # DO NOT REMOVE THE COMMENTS!
    # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
    # WEBDAV BEGIN
    # WEBDAV END
    </IfModule>


    </VirtualHost>



    <IfModule mod_ssl.c>
    ###########################################################
    # SSL Vhost
    ###########################################################

    <VirtualHost *:443>
    DocumentRoot /var/www/myhost.com/web

    ServerName myhost.com
    ServerAlias www.myhost.com
    ServerAlias renrealtors.myhost.com
    ServerAlias mail.myhost.com
    ServerAlias mls.myhost.com
    ServerAlias admin.myhost.com
    ServerAlias office.myhost.com
    ServerAlias preforeclosures.myhost.com
    ServerAlias joomla.myhost.com
    ServerAlias shortsales.myhost.com
    ServerAdmin webmaster@myhost.com

    ErrorLog /var/log/ispconfig/httpd/myhost.com/error.log

    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 503 /error/503.html

    SSLEngine on
    SSLCertificateFile /var/www/clients/client1/web1/ssl/myhost.com.crt
    SSLCertificateKeyFile /var/www/clients/client1/web1/ssl/myhost.com.key

    <Directory /var/www/myhost.com/web>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

    # ssi enabled
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    Options +Includes
    </Directory>
    <Directory /var/www/clients/client1/web1/web>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

    # ssi enabled
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    Options +Includes
    </Directory>

    # 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/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl
    # ssi enabled
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    # suexec enabled
    SuexecUserGroup web1 client1
    # Clear PHP settings of this website
    <FilesMatch "\.ph(p3?|tml)$">
    SetHandler None
    </FilesMatch>
    # php as fast-cgi enabled
    <IfModule mod_fcgid.c>
    # SocketPath /tmp/fcgid_sock/
    # IdleTimeout n (3600 seconds)
    # An idle fastcgi application will be terminated after IdleTimeout seconds.
    IdleTimeout 3600

    # ProcessLifeTime n (7200 seconds)
    # A fastcgi application will be terminated if lifetime expired, even no error is detected.
    ProcessLifeTime 7200

    # MaxProcessCount n (1000)
    # The max count of total fastcgi process count.
    # MaxProcessCount 1000

    # DefaultMinClassProcessCount n (3)
    # The minimum number of fastcgi application instances for any one fastcgi
    application.
    # Idle fastcgi will not be killed if their count is less than n
    # Set this to 0, and tweak IdleTimeout
    DefaultMinClassProcessCount 0

    # DefaultMaxClassProcessCount n (100)
    # The maximum number of fastcgi application instances allowed to run for
    # particular one fastcgi application.
    DefaultMaxClassProcessCount 100

    # IPCConnectTimeout n (3 seconds)
    # The connect timeout to a fastcgi application.
    IPCConnectTimeout 8

    # IPCCommTimeout n (20 seconds)
    # The communication timeout to a fastcgi application. Please increase this
    # value if your CGI have a slow initialization or slow respond.
    IPCCommTimeout 360

    # BusyTimeout n (300 seconds)
    # A fastcgi application will be terminated if handing a single request
    # longer than busy timeout.
    BusyTimeout 300
    </IfModule>
    <Directory /var/www/myhost.com/web>
    AddHandler fcgid-script .php .php3 .php4 .php5
    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
    Options +ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    <Directory /var/www/clients/client1/web1/web>
    AddHandler fcgid-script .php .php3 .php4 .php5
    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
    Options +ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^renrealtors.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/files/renrealtors/$1 [L]
    RewriteCond %{HTTP_HOST} ^mail.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com:8080/webmail/$1 [R,L]
    RewriteCond %{HTTP_HOST} ^mls.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/files/mls/$1 [L]
    RewriteCond %{HTTP_HOST} ^admin.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com:8080/$1 [L]
    RewriteCond %{HTTP_HOST} ^office.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/files/office/$1 [L]
    RewriteCond %{HTTP_HOST} ^preforeclosures.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/files/preforeclosures/$1 [L]
    RewriteCond %{HTTP_HOST} ^joomla.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/administrator/$1 [L]
    RewriteCond %{HTTP_HOST} ^shortsales.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.vesport.com/files/preforeclosures/$1 [L]

    # add support for apache mpm_itk
    <IfModule mpm_itk_module>
    AssignUserId web1 client1
    </IfModule>

    <IfModule mod_dav_fs.c>
    # DO NOT REMOVE THE COMMENTS!
    # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
    # WEBDAV BEGIN
    RewriteCond %{HTTP_HOST} ^preforeclosures.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/files/preforeclosures/$1 [L]
    RewriteCond %{HTTP_HOST} ^joomla.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.myhost.com/administrator/$1 [L]
    RewriteCond %{HTTP_HOST} ^shortsales.myhost.com [NC]
    RewriteRule ^/(.*)$ https://www.vesport.com/files/preforeclosures/$1 [L]

    # add support for apache mpm_itk
    <IfModule mpm_itk_module>
    AssignUserId web1 client1
    </IfModule>

    <IfModule mod_dav_fs.c>
    # DO NOT REMOVE THE COMMENTS!
    # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
    # WEBDAV BEGIN
    # WEBDAV END
    </IfModule>


    </VirtualHost>
    </IfModule>






    Thanks in advance for any replies.


    Art
     
    Last edited: May 13, 2012
  2. falko

    falko Super Moderator Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    You must place CGI files in the cgi-bin directory.

    Same directives will overwrite each other, the rest justs adds up.

    ISPConfig will overwrite your changes if you edot the file directly, therefore you should use the Apache Directives field. You can also define a custom vhost template by copying /usr/local/ispconfig/server/conf/vhost.conf.master to the /usr/local/ispconfig/server/conf-custom/ directory. You can then modify /usr/local/ispconfig/server/conf-custom/vhost.conf.master to your needs, and ISPConfig will use that one instead of /usr/local/ispconfig/server/conf/vhost.conf.master.
     
  3. vestport4

    vestport4 New Member

    Hello Falko,

    When you say place cgi files in the cgi-bin directory. Does it make a difference that it is actually named cgi-bin? I mean I know that is traditional or whatever but as long as there is +ExecCGI and AddHandler cgi-script .cgi
    AddHandler cgi-script .pl it cgi files should be able to go anywhere no?

    Or are you saying that .cgi files cannot be run on the virtual host and need to be in the main /cgi-bin/directory of the host that handles all the virtual domains?

    Part of the problem is that I can't even do a directory listing like I use to be able to do in non-cgi directories on ISPCONFIG2. Like when I would:

    Code:
    http://www.mydomain.com/files/
    I would see:

    Code:
    file1
    file2
    file3
    Now all I get is an error.

    The only way I can see a file is if I actually know what it is like:

    Code:
    http://www.mydomain.com/files/file1
    I cannot do a directory listing even with Options +Indexex. I figured that this is one and the same problem why I can't use my cgi files.

    Do apache directives take precedence over the .vhost files or rather is there anything in the .vhost files that would overwrite apache directives preventing me from running cgi and listing directories?

    Below are my apache directives that I have been trying with no luck:

    Code:
    <Directory /var/www/clients/client1/web1/files/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>
    
    <Directory /var/www/clients/client1/web1/files/cgi/
    AddHandler cgi-script .cgi .pl
    Options FollowSymLinks +ExecCGI 
    </Directory>
    I used this with and without a + on Indexes and no luck

    After changes I would:

    Code:
    /etc/init.d/httpd restart
    and wait a few secs for changes to take effect.

    Am I doing something wrong?


    Thanks for advice about where to keep files and overwrites. Now I know how to handle that once I get directory listings and cgi working right.


    Thanks,


    Art
     
  4. falko

    falko Super Moderator Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    By default cgi files work only in the main /cgi-bin directory. But of course you can define your own location for CGI scripts with the Apache Directives.
     

Share This Page