How is the best practise create own structure for new client folder?

Discussion in 'Tips/Tricks/Mods' started by buffus, May 30, 2013.

  1. buffus

    buffus New Member

    Hello,

    I'm using now the ISPConfig 3.0.5.2 on Debian Wheezy.

    When I create for new client-> new website, default structure of his folder is:

    HTML:
    cgi-bin/
    log/
    private/
    ssl/
    tmp/
    web/
    - stats
    - .htaccess
    - favicon.ico
    - index.html
    - robots.txt
    webdav/
    But I'd like build the own structure for client automaticaly e.g.

    HTML:
    app/
       libs/
       log/
       temp/
       www/
          - index.php

    How is the best practise on ISPConfig 3.0.5.2 now?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Your structure is not supported by ispconfig, if you want to use that you will have to go trough all code inside the directory /usr/local/ispconfig/ and adjust all oaths and then adjust all config files and templates that yre used on a ispconfig server for websites.
     
  3. buffus

    buffus New Member

    Thank you. It is very laborious.

    Or how to add only e.g. folder1/lib.php to private folder automaticaly?

    /var/www/clients/client1/web1/private/folder1/lib.php
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    The best way to do it in a upgrade safe way is to write a small ispconfig server plugin that subscribes for the "web_domain_insert" event. You custom plugin should have a name that is after "apache2" in alphabet to ensure that your plugin is run after the original apache2 plugin, name it e.g. "customapache2_plugin.inc.php" and put it in /usr/local/ispconfig/server/plugins-available and then activate it by adding a symlink in plugins-enabled directory. I recommend to take a look at the structure of the apache2 plugin to see how your plugin can subscribe to a event.
     
  5. buffus

    buffus New Member

    Thank you. I have this code and symlink in plugins-enabled is created.

    But not working (It doesn't create the directory test.). What is wrong please?

    PHP:
    <?php

    class customapache2_plugin
    {
        public 
    $plugin_name 'customapache2_plugin';
        public 
    $class_name 'customapache2_plugin';

        
    /**
        This function is called when the plugin is loaded
        */
        
    function onLoad() {
            global 
    $app;

            
    //    Register for the events
            
    $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'add_dir_test');
        }


        function 
    add_dir_test($event_name,$data) {
            global 
    $app;

            
    //    Create folder test
            
    if(!is_dir($data['new']['document_root'].'/test')) $app->system->mkdirpath($data['new']['document_root'].'/test');
        }
    }

     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    The dode looks fine. Did you try to enable the debug loglevel, deactivate the server.sh cronjob and then run server.sh manually as root user?
     
  7. buffus

    buffus New Member

    Thank You. Here is my debug log, when I try to create aaa.aa site (mkdir "test" failed...):

    Code:
    02.06.2013-20:17 - DEBUG - Set Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock
    02.06.2013-20:17 - DEBUG - Found 1 changes, starting update process.
    02.06.2013-20:17 - DEBUG - Calling function 'ssl' from plugin 'apache2_plugin' raised by event 'web_domain_insert'.
    02.06.2013-20:17 - DEBUG - Calling function 'insert' from plugin 'apache2_plugin' raised by event 'web_domain_insert'.
    02.06.2013-20:17 - DEBUG - Adding the user: web34
    02.06.2013-20:17 - DEBUG - Creating symlink: ln -s /var/www/clients/client1/web34/ /var/www/aaa.aa
    02.06.2013-20:17 - DEBUG - Creating symlink: ln -s /var/www/clients/client1/web34/ /var/www/clients/client1/aaa.aa
    02.06.2013-20:17 - DEBUG - exec: chown -R web34:client1 /var/www/clients/client1/web34/web
    02.06.2013-20:17 - DEBUG - exec: chown web34:client1 /var/www/clients/client1/web34/web
    02.06.2013-20:17 - DEBUG - exec: usermod --groups sshusers web34 2>/dev/null
    02.06.2013-20:17 - DEBUG - Creating fastcgi starter script directory: /var/www/php-fcgi-scripts/web34/
    02.06.2013-20:17 - DEBUG - Creating fastcgi starter script: /var/www/php-fcgi-scripts/web34/.php-fcgi-starter
    02.06.2013-20:17 - DEBUG - Writing the vhost file: /etc/apache2/sites-available/aaa.aa.vhost
    02.06.2013-20:17 - DEBUG - Creating symlink: /etc/apache2/sites-enabled/100-aaa.aa.vhost->/etc/apache2/sites-available/aaa.aa.vhost
    02.06.2013-20:17 - DEBUG - Apache status is: 1
    02.06.2013-20:17 - DEBUG - Calling function 'restartHttpd' from module 'web_module'.
    02.06.2013-20:17 - DEBUG - Apache online status after restart is: 1
    02.06.2013-20:17 - DEBUG - Calling function 'add_dir_test' from plugin 'customapache2_plugin' raised by event 'web_domain_insert'.
    02.06.2013-20:17 - DEBUG - mkdir failed: //var/www/clients/client1/web34/test
    02.06.2013-20:17 - DEBUG - chmod failed: //var/www/clients/client1/web34/test : 493
    02.06.2013-20:17 - DEBUG - Processed datalog_id 86
    02.06.2013-20:17 - DEBUG - Remove Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock
    My server is VPS by this tutorial.
     
  8. buffus

    buffus New Member

    My problem is the double slash in the path //var/www/clients/...

    PHP:
    ...
    $app->system->mkdirpath($data['new']['document_root'].'/test');
    ...
    generates a log

    Code:
    ...
    DEBUG - mkdir failed: //var/www/clients/client1/web34/test
    ...

    How can I remove the one slash, please?
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Check your path settings in ISPConfig under System > Server config, the double slash must be in one of the paths there.
     
  10. buffus

    buffus New Member

    I found double slashes. I have set the default path from installation.

    But add this code helped me:

    PHP:
    ...
    $app->system->web_folder_protection($data['new']['document_root'],false);
       ...
       
    $app->system->mkdirpath($data['new']['document_root'].'/test');
       ...
    $app->system->web_folder_protection($data['new']['document_root'],true);
    ...
    Test directory is created correctly now.


    Thank you very much for your effort, till!
     

Share This Page