Newb: Need to understand the fundamentals...

Discussion in 'Installation/Configuration' started by Slowhand, Jun 4, 2009.

  1. Slowhand

    Slowhand New Member

    Hi,

    Sorry if this is very basic..

    Am I right in thinking that Ispc uses the structure in /var/www as a template and clones it to any other sites it creates?

    In other words, if I install phpmyadmin in /var/www/phpmyadmin, then every new site will also have access to phpmyadmin in nameofnewsite/www/phpmyadmin?

    Same with webmail etc?

    Thanks :)

    Slowhand
     
  2. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    No that's not correct. Website document roots are in /var/www/clients/clientx/...
    If you need a symlink vor webmail in each website use this plugin:
    http://www.howtoforge.com/forums/showthread.php?t=34917

    You could easily duplicate that plugin and modify it for phpmyadmin symlink.
     
  3. Slowhand

    Slowhand New Member

    Croydon,

    That was quick... Thanks for your reply.

    Funnily enough I *just* installed the plugin you linked to before writing my original post :)

    I haven't looked at it but I imagine modifying the script will be *way* over my head... :)

    So, in that case, let me rephrase my original question:
    If I install phpmyadmin in /var/www/phpmyadmin, then every new site will also have access to phpmyadmin in /var/www/clients/clientx/phpmyadmin?

    It sounds as if the answer is no...

    In which case this post confuses me:
    (From http://www.howtoforge.com/forums/showthread.php?t=34047)

    Code:
    Hi,
    i am Oliver, the "programmer" of the phpmyadmin link inside ISPC3.
    
    if you click on such a link, i am looking for the SERVER, the database is running at (for example server #1). Then i am looking in the server-configuration for the "name", this server has (for example s001.muv-server.com). Then i create a link to the phpmyadmin at this server.
    
    means (for this example)
    
    http://s001.muv-server.com/phpmyadmin
    
    this means, you only have to "create" a working phpmyadmin under your server (NOT under EVERY doamain!).
    
    if your server is called s1.myserver.com than you need a pypmyadmin under s1.myserver.com -> thats all.
    
    by the way. If you are using SSL with ISPC3, you must have a ssl certificate for your server too -> httpS://s1.myserver.com
    
    if you have any more question->feel free to ask!
    
    Olli
    
    My brain hurts... too old for this :)

    Slowhand
     
  4. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Sorry, but you're quote has nothing to do with this ;)

    I did a second plugin that does the same for phpmyadmin as the other does for webmail.

    Code:
    /usr/local/ispconfig/server/plugins-available/pma_symlink_plugin.inc.php
    and create a symlink in plugins-enabled
    Code:
    ln -s /usr/local/ispconfig/server/plugins-available/pma_symlink_plugin.inc.php /usr/local/ispconfig/server/plugins-enabled/pma_symlink_plugin.inc.php
    Please note: the symlink is automatically removed / not created if suphp is enabled for this website as suphp doesn't allow symlinks outside the docroot.


    PHP:
    <?php

    /*
    Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
    All rights reserved.
    Modification (c) 2009, Marius Cramer, pixcept KG 

    Redistribution and use in source and binary forms, with or without modification,
    are permitted provided that the following conditions are met:

        * Redistributions of source code must retain the above copyright notice,
          this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        * Neither the name of ISPConfig nor the names of its contributors
          may be used to endorse or promote products derived from this software without
          specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */

    class pma_symlink_plugin {
        
        var 
    $plugin_name 'pma_symlink_plugin';
        var 
    $class_name 'pma_symlink_plugin';
        
        var 
    $action;
        
        
    //* This function is called during ispconfig installation to determine
        //  if a symlink shall be created for this plugin.
        
    function onInstall() {
            global 
    $conf;
            
            if(
    $conf['services']['web'] == true) {
                return 
    true;
            } else {
                return 
    false;
            }
            
        }
        
            
        
    /*
             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,'insert');
            
    $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
        }
        
        function 
    insert($event_name,$data) {
            global 
    $app$conf;
            
            
    $this->action 'insert';
            
    // just run the update function
            
    $this->update($event_name,$data);
        }
        
        function 
    update($event_name,$data) {
            global 
    $app$conf;
            
            if(
    $this->action != 'insert'$this->action 'update';
            
            if(
    $data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
                
                
    $old_parent_domain_id intval($data["old"]["parent_domain_id"]);
                
    $new_parent_domain_id intval($data["new"]["parent_domain_id"]);
                
                
    // If the parent_domain_id has been chenged, we will have to update the old site as well.
                
    if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
                    
    $tmp $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
                    
    $data["new"] = $tmp;
                    
    $data["old"] = $tmp;
                    
    $this->action 'update';
                    
    $this->update($event_name,$data);
                }
                
                
    // This is not a vhost, so we need to update the parent record instead.
                
    $tmp $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
                
    $data["new"] = $tmp;
                
    $data["old"] = $tmp;
                
    $this->action 'update';
            }
            
            if(
    $data["new"]["document_root"] == '') {
                
    $app->log("document_root not set",LOGLEVEL_WARN);
                return 
    0;
            }
            
            
    $symlink true;
            if(
    $data["new"]["php"] == "suphp"$symlink false;
            elseif(
    $data["new"]["php"] == "cgi" && $data["new"]["suexec"] == "y"$symlink false;
            elseif(
    $data["new"]["php"] == "fast-cgi" && $data["new"]["suexec"] == "y"$symlink false;
            
            
            if(!
    is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
            if(
    $symlink == false) {
                if(
    is_link($data["new"]["document_root"]."/web/phpmyadmin")) exec("rm -f ".$data["new"]["document_root"]."/web/phpmyadmin");
            } else {
                if(!
    is_link($data["new"]["document_root"]."/web/phpmyadmin")) exec("ln -s /var/www/phpmyadmin ".$data["new"]["document_root"]."/web/phpmyadmin");
                else 
    exec("ln -sf /var/www/phpmyadmin ".$data["new"]["document_root"]."/web/phpmyadmin");
            }
        }
        

    // end class

    ?>
     
  5. Slowhand

    Slowhand New Member

    Croydon,

    Was just looking at the plugin...

    If I called the plugin
    Code:
    phpmyadmin_symlink_plugin
    and did a search & replace for
    Code:
    webmail_symlink_plugin
    and replaced it with
    Code:
    phpmyadmin_symlink_plugin
    and the same with
    Code:
    /web/webmail
    Replacing it with
    Code:
    /web/phpmyadmin
    Would that work?

    Would be a useful technique for all sorts of things ;-)

    Let me know

    Slowhand
     
  6. Slowhand

    Slowhand New Member

    Arghhhh,

    Why doesn't it? :)

    Isn't it about giving each site access to phpmyadmin?

    Thanks for the new plugin!

    Slowhand
     
  7. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Yes and no. It redirects the user to the main server url/phpmyadmin not to mydomain.com/phpmyadmin.
     
  8. Slowhand

    Slowhand New Member

    Croydon,

    Got it :)

    I can see my technique for adapting your plugin wasn't quite right... ;-)

    Edit: Actually... was it right?

    Shouldn't be messing with stuff like this...

    Thanks again :)

    Slowhand
     
    Last edited: Jun 4, 2009
  9. Slowhand

    Slowhand New Member

    One last thing (yeah right...)

    Croydon,

    Is it Ok to symlink the installation of phpmyadmin to /var/www?

    (Ubuntu installs it in /usr/shared I think)

    Will your plugin still work?

    Is it a secure thing to do?

    Slowhand
     
  10. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    In my opinion: yes
    ln -s /usr/share/phpmyadmin /var/www/phpmyadmin works for me.
    But be sure users need to log in and are not automatically logged in as root ;)
     
  11. Slowhand

    Slowhand New Member

    Croydon,

    Thanks for that. :)

    Going to have to lie down now...

    Slowhand
     
  12. Slowhand

    Slowhand New Member

    Croydon,

    Sorry...

    Would it be better/safer to use a 'hard' link?

    Or not relevant?

    As a newb I'm trying very hard to be as secure as possible...

    Slowhand
     
  13. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    I would not use hard links.
     
  14. Slowhand

    Slowhand New Member

    Croydon,

    In all that we lost sight of my original question: :)

    If I install <something> in /var/www/something, then every new site will also have access to <something> in /var/www/clients/clientx/something?

    The reason I ask is that I would like to figure out how to serve things like phpmyadmin behind https. Seems silly not to...

    Slowhand
     
  15. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    No it is not. /var/www/something is accessible through the MAIN host of ispc only as far as i know.
    That's why I created the 2 plugins for phpmyadmin and webmail symlink.

    Sure, it depends on the operating system and installed packages and so on (some packages create aliases in the apache config).
     
  16. Slowhand

    Slowhand New Member

    Croydon,

    Trying to get my head around this...

    If I wanted to provide an https folder for every site created using ISPc, would I have to set it up in /var/www and then adapt your plugin for the https folder?

    Then place the symlink for phpmyadmin in the https folder?

    Was my search & replace technique correct btw?
     
  17. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Ok, it seems to me we talked about different things :)
    I just wanted to create webmail and phpmyadmin urls for all websites.

    There is no option in ispc3 (yet) to give a separate folder for https. As soon as you enable ssl (https) for a website the same url is reachable through https and http.
    Maybe this could be a feature request for later releases.
     
  18. Slowhand

    Slowhand New Member

    Croydon,

    We're not really talking about separate things. I just want to refine the setup :)

    Would a version of your new plugin be a way to create an https folder in an ISPc site?

    Slowhand
     
  19. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    No, the plugin is really only for a symlink (no matter if https or http).
    What you need is rewriting of the vhost config.
     
  20. Slowhand

    Slowhand New Member

    Croydon,

    Sorry to be dim...

    I'm confused about your second version of the plugin then. Would I have to install webmail in /usr/share/? Not /var/www/?

    Slowhand
     

Share This Page