0

All the Drupal documentation I can find has a step of "going to a browser and continuing installation there".

How can I perform these steps from my command line?

I am trying to have a site where I can fire up an AWS instance and install Drupal etc by command line.

4
  • I don't what "an AWS instance" is, but you're aware that you can (should) browse to the public URL of the website-to-be? (Like anyone who goes to that URL will be able to continue the installation.)
    – Arjan
    Oct 7, 2009 at 19:53
  • 1
    Amazon Web Services.
    – Nissan Fan
    Oct 7, 2009 at 22:22
  • Hmmm, I figured it couldn't be that... Then I just don't understand the question. :-)
    – Arjan
    Oct 8, 2009 at 7:56
  • Out of curiosity, why is browser installation not an option? Drupal is a web framework so presumably you will need to have web access to it at some point. Why not do the standard installation with the browser? May 11, 2010 at 16:46

7 Answers 7

4

You want to use Drush's provision script.

Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

2

It's a little pain to install drupal from curl due to all the different redirects the install script makes. You also need to read and write cookies at exact moments. However: I have made a curl script which will install drupal from the command line :) Note: Only tested with drupal-6.x, php5 and the php curl extension.

As a site note before doing this, you should really consider using the drush site-install command!

This was tested on drupal-6.20 with PHP 5.3. Druapl 7 needs to have Javascript enabled as far as I can see. And therefor will not install from curl! You should also note that correct files for settings.php and the file folder needs to be set in order to make this work (otherwise we will get errors and curl will not compleate!)

First we add a curl class.

<?php

// class found on php.net
// http://php.net/manual/en/book.curl.php

class mycurl {
     protected $_useragent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1';
     protected $_url;
     protected $_followlocation;
     protected $_timeout;
     protected $_maxRedirects;
     protected $_cookieFileLocation = './cookie.txt';
     protected $_post;
     protected $_postFields;
     protected $_referer ="http://www.google.com";

     protected $_session;
     protected $_webpage;
     protected $_includeHeader;
     protected $_noBody;
     protected $_status;
     protected $_binaryTransfer;
     public    $authentication = 0;
     public    $auth_name      = '';
     public    $auth_pass      = '';

     public function useAuth($use){
       $this->authentication = 0;
       if($use == true) $this->authentication = 1;
     }

     public function setName($name){
       $this->auth_name = $name;
     }
     public function setPass($pass){
       $this->auth_pass = $pass;
     }

     public function __construct($url,$followlocation = true,$timeOut = 30,$maxRedirecs = 4,$binaryTransfer = false,$includeHeader = true,$noBody = false)
     {
         $this->_url = $url;
         $this->_followlocation = $followlocation;
         $this->_timeout = $timeOut;
         $this->_maxRedirects = $maxRedirecs;
         $this->_noBody = $noBody;
         $this->_includeHeader = $includeHeader;
         $this->_binaryTransfer = $binaryTransfer;

         $this->_cookieFileLocation = dirname(__FILE__).'/cookie.txt';

     }

     public function setReferer($referer){
       $this->_referer = $referer;
     }

     public function setCookiFileLocation($path)
     {
         $this->_cookieFileLocation = $path;
     }

     public function setPost ($postFields)
     {
        $this->_post = true;
        $this->_postFields = $postFields;
     }

     public function setUserAgent($userAgent)
     {
         $this->_useragent = $userAgent;
     }

     public function createCurl($url = 'nul')
     {
        if($url != 'nul'){
          $this->_url = $url;
        }

         $s = curl_init();

         curl_setopt($s,CURLOPT_URL,$this->_url);
         curl_setopt($s,CURLOPT_HTTPHEADER,array('Expect:'));
         curl_setopt($s,CURLOPT_TIMEOUT,$this->_timeout);
         curl_setopt($s,CURLOPT_MAXREDIRS,$this->_maxRedirects);
         curl_setopt($s,CURLOPT_RETURNTRANSFER,true);
         curl_setopt($s,CURLOPT_FOLLOWLOCATION,$this->_followlocation);
         curl_setopt($s,CURLOPT_COOKIEJAR,$this->_cookieFileLocation);
         curl_setopt($s,CURLOPT_COOKIEFILE,$this->_cookieFileLocation);

         if($this->authentication == 1){
           curl_setopt($s, CURLOPT_USERPWD, $this->auth_name.':'.$this->auth_pass);
         }
         if($this->_post)
         {
             curl_setopt($s,CURLOPT_POST,true);
             curl_setopt($s,CURLOPT_POSTFIELDS,$this->_postFields);

         }

         if($this->_includeHeader)
         {
               curl_setopt($s,CURLOPT_HEADER,true);
         }

         if($this->_noBody)
         {
             curl_setopt($s,CURLOPT_NOBODY,true);
         }
         /*
         if($this->_binary)
         {
             curl_setopt($s,CURLOPT_BINARYTRANSFER,true);
         }
         */
         curl_setopt($s,CURLOPT_USERAGENT,$this->_useragent);
         curl_setopt($s,CURLOPT_REFERER,$this->_referer);

         $this->_webpage = curl_exec($s);
         $this->_status = curl_getinfo($s,CURLINFO_HTTP_CODE);
         curl_close($s);

     }

   public function getHttpStatus()
   {
       return $this->_status;
   }

   public function __tostring(){
      return $this->_webpage;
   }
}

And now we create the script with the curl class.

<?php

include_once "curl.inc";

// your site
$site_url = 'http://drupal';

// profile
$profile = 'default';

// locale
$locale = 'en';

// database
$db_path = 'drupal';

// database user
$db_user = 'root';

// database pass
$db_pass = 'password';

// database host
$db_host = 'localhost';

// name of site
$site_name = 'site_name';

// site email
$site_mail = '[email protected]';

// admin account name
$account_name = 'admin';

// admin account email
$account_mail = '[email protected]';

// admin account pass
$account_pass = 'admin1234';

// date time zone
$date_default_timezone = '-39600';

// use clean url.
$clean_url = '1';

// update status module
$update_status_module = '1';

// end of settings
 // create a url for curling db settings
$url_str = "db_path=$db_path&";
$url_str.= "db_user=$db_user&";
$url_str.= "db_pass=$db_pass&";
$url_str.= "db_host=$db_host&";
$url_str.= "db_prefix=&";
$url_str.= "db_port=&";
$url_str.= "op=Save and continue" . "&";
$url_str.= "form_id=install_settings_form";
$url_str = urlencode($url_str);

$url = "$site_url/install.php?profile=$profile";
$curl = new mycurl($url, true);
$curl->createCurl();
echo $curl;

$url = "$site_url/install.php?profile=$profile&locale=$locale";
$curl = new mycurl($url, true);
$curl->setPost($url_str);
$curl->createCurl();
echo $curl;

$url = "$site_url/install.php?profile=$profile&locale=$locale&op=do_nojs&id=1";

$curl = new mycurl($url, true);
$curl->setPost($url_str);
$curl->createCurl();
echo $curl;

$url = "$site_url/install.php?profile=$profile&locale=$locale&op=finished&id=1";

$curl = new mycurl($url, true);
$curl->setPost($url_str);
$curl->createCurl();
echo $curl;


// set settings for loading database with site base settings
$url_str = "site_name=$site_name&";
$url_str.= "site_mail=$site_mail&";
$url_str.= "account[name]=$account_name&";
$url_str.= "account[mail]=$account_mail&";
$url_str.= "account[pass][pass1]=$account_pass&";
$url_str.= "account[pass][pass2]=$account_pass&";
$url_str.= "date_default_timezone=$date_default_timezone&";
$url_str.= "clean_url=$clean_url&";
$url_str.= "form_id=install_configure_form&";
$url_str.= "update_status_module[1]=$update_status_module";


$url = "$site_url/install.php?profile=default&locale=en";
$curl = new mycurl($url, true);
$curl->setPost($url_str);
$curl->createCurl();
echo $curl;

die();
?>

Install Drupal with cURL

1

You could script out the steps of the URL using cURL.

1
  • How does one do that exactly? Nov 5, 2011 at 3:42
0

The working Curl script can be found here: http://www.os-cms.net/content/article/view/1

0

Feel free to check out drush_site_install6 drush module available here: http://drupal.org/project/drush_site_install6

0

You could use the extension called Densite. This will do it for 6.x and 5.x - test only on ubuntu though.

The link to installing drupal with curl is broken.

Installing Drupal 6 using the Command Line with Drush and Twill

0

What about using Lynx text browser?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .