Changeset 10045

Show
Ignore:
Timestamp:
09/06/06 11:07:39 (2 years ago)
Author:
bergius
Message:

This is the first working version. See http://www.midgard-project.org/documentation/using-midgard-with-plesk/ for docs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/tools/plesk/README.txt

    r10044 r10045  
    2828 
    2929Next you need to add Midgard configuration details to Apache configuration. For this, run the supplied `midgardize-vhost.php` script. 
     30 
     31For example, if you have just added a website "www.example.net" into your Plesk server, you need to run the following to Midgardize it: 
     32 
     33    # php /usr/share/midgard/plesk/midgardize-vhost.php -n www.example.net 
     34     
     35Run `php /usr/share/midgard/plesk/midgardize-vhost.php -h` for more options. 
     36 
     37The `midgardize-vhost.php` script will do the following: 
     38 
     39* Generate Midgard-specific `vhost.conf` file for the website 
     40* Symlink MidCOM static files (images and CSS) under the host document root 
     41* Register the Midgard settings into Plesk using the `websrvmng --reconfigure-vhost` command 
     42 
     43Next you can restart Apache and create the site using the Midgard Site Wizard. 
  • trunk/src/tools/plesk/midgardize-vhost.php

    r10044 r10045  
    2727        'default' => '/usr/local/psa', 
    2828    ), 
     29    'midgard_rootfile' => array 
     30    ( 
     31        'desc'    => 'Path to Midgard root file', 
     32        'max'     => 1, 
     33        'min'     => 0, 
     34        'default' => '/usr/lib/apache2/modules/midgard-root.php', 
     35    ), 
    2936    'hostname' => array 
    3037    ( 
     
    4047        'desc'    => 'Midgard configuration file', 
    4148        'max'     => 1, 
    42         'min'     => 1
     49        'min'     => 0
    4350        'default' => 'midgard', 
    4451    ), 
     
    4653 
    4754// Load the console library 
    48 ini_set('include_path', '..:/opt/local/lib/php4'); 
     55ini_set('include_path', ini_get('include_path') . ':/opt/local/lib/php4'); 
    4956require_once 'Console/Getargs.php'; 
    5057 
     
    8289// Check that we can write to the Virtual Host configuration directory 
    8390$vhost_confdir = get_merged_value('vhost_directory', $args, $config) . '/' . get_merged_value('hostname', $args, $config) . '/conf/'; 
     91$vhost_docdir = get_merged_value('vhost_directory', $args, $config) . '/' . get_merged_value('hostname', $args, $config) . '/httpdocs/'; 
    8492if (!file_exists($vhost_confdir)) 
    8593{ 
    8694    die("Plesk virtual host configuration directory '{$vhost_confdir}' was not found. Have you created the host in Plesk yet?\n"); 
    8795} 
    88  
    8996if (!is_writable($vhost_confdir)) 
    9097{ 
    9198    die("Cannot write to Plesk virtual host configuration directory '{$vhost_confdir}'. Please check your settings or run as root.\n"); 
     99} 
     100 
     101// Check that the midgard-root.php file is available 
     102$midgard_rootfile = get_merged_value('midgard_rootfile', $args, $config); 
     103if (!file_exists($midgard_rootfile)) 
     104{ 
     105    die("Midgard root file '{$midgard_rootfile}' was not found. Have you installed Midgard properly?\n"); 
    92106} 
    93107 
     
    150164} 
    151165 
     166// Generate the vhost settings 
    152167$vhost_settings  = "MidgardEngine on\n"; 
     168$vhost_settings .= "MidgardRootFile {$midgard_rootfile}\n"; 
    153169$vhost_settings .= "MidgardDatabase {$midgard_configuration['Name']} {$midgard_configuration['Username']} {$midgard_configuration['Password']}\n"; 
    154170$vhost_settings .= "MidgardBlobDir {$midgard_configuration['Blobdir']}\n"; 
     
    165181// TODO: MidgardRootFile, MidgardDefaultRealm 
    166182 
    167 echo "Save the following setup to file {$vhost_confdir}vhost.conf:\n\n{$vhost_settings}\n"; 
    168 echo "And then run:\n" . get_merged_value('psa_directory', $args, $config) . "/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=" . get_merged_value('hostname', $args, $config) . "\n"; 
     183// Save them to a vhost.conf file 
     184$conf = fopen("{$vhost_confdir}vhost.conf", 'w'); 
     185fwrite($conf, $vhost_settings); 
     186fclose($conf); 
    169187 
    170 // TODO: Save file and run /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=<domain_name> 
     188// Symlink midcom-static under the docroot 
     189$php_web_dir = str_replace("\n", '', @shell_exec('pear config-get web_dir')); 
     190exec("ln -s {$php_web_dir} {$vhost_docdir}midcom-static"); 
     191 
     192// Register the vhost.conf file with Plesk 
     193exec(get_merged_value('psa_directory', $args, $config) . "/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=" . get_merged_value('hostname', $args, $config)); 
     194 
     195echo "Configuration has been saved to {$vhost_confdir}vhost.conf and registered for Plesk.\n"; 
    171196?>