官术网_书友最值得收藏!

  • Drupal 7 First Look
  • Mark Noble
  • 389字
  • 2021-04-13 16:46:23

Command-line installation

Administrators who manage lots of sites or who prefer to work from the command line will be thrilled with the change to make Drupal installable from the command line. If you want to run the installation from the command line, you will need to use the following procedure:

  1. Download Drupal from Drupal.org and copy the files to your server.
  2. Create a PHP script to run the Drupal command line using the following procedure:

    i. Create a file called install.site.php where site is the name of your site. This file should be located in the same directory where your install.php file is located (the root directory for your site).

    ii. Open the install.site.php file in your favorite file editor.

    iii. Enter the following script:

    <?php
    include_once 'install.php';
    
    $settings = array(
      'parameters' => array(
        'profile' => 'default',
        'locale' => 'en',
      ),
      'forms' => array(
        'install_settings_form' => array(
          'driver' => 'mysql',
          'database' => 'my_db_name',
          'username' => 'my_db_username',
          'password' => 'my_db_password',
        ),
        'install_configure_form' => array(
          'site_name' => 'My site',
          'site_mail' => 'admin@example.com',
          'account' => array(
            'name' => 'admin',
            'mail' => 'admin@example.com',
            'pass' => array(
              'pass1' => 'my_site_password',
              'pass2' => 'my_site_password',
            ),
          ),
          'update_status_module' => array(1 => TRUE),
          'clean_url' => TRUE,
        ),
      ),
    );
    install_drupal($settings);
    ?>

    This code is used to configure the installation so Drupal knows what values to use during the installation process to properly configure your site as it is created.

    iv. Modify the values in the above code snippet to match the needs of the site you want to install. You will need to pay special attention to the database information including the database name, username, and password. You should also modify the administrator's password, site name, and so on to match the desired values for your site.

    v. Save the file with all of your changes.

  3. Run the install.site.php file from the command line using the syntax:
    php install.site.php 
    
  4. After the installation completes, you can verify your site and begin configuring it as usual.
  5. After completing the installation, you should back up the install file and either remove it from your site completely or remove access to the file for all users since it contains the login information for User 1.

Although this setup is a little more complicated to run initially, it can be a big time saver if you are installing a large number of sites or want to run an unattended installation.

主站蜘蛛池模板: 海原县| 当涂县| 洛扎县| 新绛县| 永济市| 楚雄市| 纳雍县| 宝兴县| 屯门区| 顺昌县| 靖宇县| 普兰店市| 绍兴县| 四子王旗| 西林县| 田东县| 历史| 新疆| 乌什县| 蓬安县| 曲周县| 黄山市| 麻城市| 农安县| 大英县| 河津市| 新兴县| 二手房| 乐至县| 锦州市| 台江县| 广宗县| 长丰县| 寿光市| 漳州市| 惠安县| 长春市| 和平区| 乌鲁木齐市| 奈曼旗| 遵化市|