One place for hosting & domains

      How to Install Drush on Debian 10


      Updated by Linode

      Written by Linode

      Drush is a command line tool for creating, administrating, and modifying Drupal websites. Command line tools, like Drush, add functionality through additional command packages. Once installed, Drush is as easy to use as any of the basic Linux commands. The name comes from combining the words Drupal and shell. Drush is designed only for Drupal and cannot be used with other content management systems.

      Both new and experienced Drupal users can benefit from learning Drush. Users that have worked with a command line interface before have an advantage, but Drush is an excellent application for beginners, too.

      Before You Begin

      Before installing Drush, ensure that the following prerequisites have been met:

      1. Create a new Linode by following our Getting Started guide. Complete the steps for setting your Linode’s hostname and timezone.
      2. Follow our Securing Your Server guide to create a standard user account, harden SSH access, remove unnecessary network services and create firewall rules for your Linode.
      3. Install and configure a LAMP stack on Debian 10
      4. Make sure that your system is up to date, using:

        sudo apt-get update && sudo apt-get upgrade
        

        Note

        This guide is written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you’re not familiar with the sudo command, you can check our Users and Groups guide.

      Install Git & Composer

      The developers of Drush recommend installing Drush using Composer, a PHP dependency manager. Since the Drush project is hosted on GitHub and controlled with Git, you will also need to install Git. In this section, you will install both dependencies.

      1. Install Git:

        sudo apt-get install git
        
      2. Install Composer:

        curl -sS https://getcomposer.org/installer | php
        
      3. Move the composer.phar file to /usr/local/bin/, so that it can be accessed from any directory:

        sudo mv composer.phar /usr/local/bin/composer
        
      4. Composer has a few PHP dependencies it needs in order to run. Install them on your Debian system:

        sudo apt install php-dom, php-zip, unzip, php-gd, php-mbstring
        

      Install Drush Globally

      Composer is designed to install PHP dependencies on a per-project basis. The steps below will install a global Drush for all projects. If you want to install Drush for a specific system user, skip to the Install Drush for a Limited User Account section.

      1. Create a symbolic link between Composer’s local bin directory, /usr/local/bin/composer, and the system’s bin directory, /usr/bin/:

        sudo ln -s /usr/local/bin/composer /usr/bin/composer
        
      2. Use Git to download – or clone – the GitHub Drush project into a new directory, /usr/local/src/drush:

        sudo git clone https://github.com/drush-ops/drush.git /usr/local/src/drush
        
      3. Update the ownership of your new Drush directory to be your limited user account:

        sudo chown example_user:example_user -R /usr/local/src/drush
        
      4. Change the working directory to your new Drush directory:

        cd /usr/local/src/drush
        
      5. Use Git to checkout the version of Drush that you wish to use. View the GitHub project’s releases page to view all available versions.

        For a different release, replace the version number, 10.2.2, in the following command:

        sudo git checkout 10.2.2
        
      6. Create a symbolic link between the Drush directory in /usr/local/src to /usr/bin, so that the Drush command can be called from any directory:

        sudo ln -s /usr/local/src/drush/drush /usr/bin/drush
        
      7. Now, run the Composer install command:

        composer install
        
      8. Drush has now been installed for all users on your Linode. To verify the installation, check Drush’s version number.

        drush --version
        

        You should see a similar output:

          
        Drush Commandline Tool 10.2.2
            
        

      Install Drush for a Limited User Account

      You may want to install Drush for only certain system users, for example, the site admin or the Apache webserver. This option may be optimal for a shared-hosting environment. Also, this allows individual users to install different versions of Drush and even install separate versions specific to a single project. Ensure you run the commands from the limited user account’s home directory. Before you complete this section, ensure you have completed the steps in the Install Git & Composer section of the guide.

      1. Install Drush using Composer:

        composer require drush/drush
        

        This will install Drush in your ~/vendor/bin/drush directory.

      2. Using the text editor of your choice, edit the user’s .bashrc file to add the vendor directory to your path:

        ~/.bashrc
        1
        2
        
        export PATH="$HOME/vendor/bin:$PATH"
              
      3. Run the source command on the .bashrc file to enable the changes:

        source ~/.bashrc
        
      4. Check to see that Drush was installed successfully:

        drush --version
        

        Note

        You can install the Drush Launcher, a utility to be able to call Drush globally. This program listens on your $PATH and hands control to a site-local Drush that is in the ~/vendor directory.

      Using Drush

      Drush has dozens of commands with hundreds of options. Drush can interface with MySQL, Drupal, Git, and more. Below are a few examples of some useful Drush commands to get you started. Refer to the Drush Commands documentation for more details.

      1. To get started with Drush, run it without any following commands to list the help manual:

        drush
        
      2. View more detailed documentation for a specific command by typing drush help and then the command, for example:

        drush help site-install
        
      3. List many of the specs for your server and website with:

        drush status
        

      More Information

      You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

      This guide is published under a CC BY-ND 4.0 license.



      Source link

      How to Install Drupal using Drush on Debian 10


      Updated by Linode

      Written by Linode

      Drupal is a content management system (CMS) designed for building custom websites for personal and business use. Built for high performance and scalability, Drupal provides the necessary tools to create rich, interactive “community” websites with forums, user blogs, and private messaging. Drupal also has support for personal publishing projects and can power podcasts, blogs, and knowledge-based systems, all within a single, unified platform.

      Drush is a command line tool for creating, administrating, and modifying Drupal websites. Command line tools, like Drush, add functionality through additional command packages. Once installed, Drush is as easy to use as any of the basic Linux commands.

      Before You Begin

      1. Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.

      2. Follow our Securing Your Server guide to create a standard user account, harden SSH access, remove unnecessary network services and create firewall rules for your web server; you may need to make additional firewall exceptions for your specific application.

        Note

        This guide is written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you’re not familiar with the sudo command, visit our Users and Groups guide.

        All configuration files should be edited with elevated privileges. Remember to include sudo before running your text editor.

      3. Install and configure a LAMP stack on Debian 10

      4. Install Composer and Drush on Debian 10

      Download and Prepare Drupal 8

      1. Navigate to your site’s document root. If you installed and configured your Apache server using our LAMP stack on Ubuntu 18.04 guide, your document root should be located in the /var/www/html/example.com/public_html/ directory. Replace example.com with your own document root path’s name.

        cd /var/www/html/example.com
        
      2. Download the Drupal 8 tarball. As of writing this guide, Drupal 8.8.3 is the latest version. See Drupal’s download page for their latest core tarball. Replace 8.8.3 with the version number you wish to download.

        sudo wget http://ftp.drupal.org/files/projects/drupal-8.8.3.tar.gz
        

        Caution

        Ensure that the version number matches the Drupal 8 version you wish to download.

      3. Extract the downloaded tarball’s contents into your site’s document root:

        sudo tar -zxvf drupal-8.*.tar.gz --strip-components=1 -C public_html
        
      4. Drupal depends on a PHP graphics library called GD. Install GD and other dependencies:

        sudo apt-get install php-gd php-xml php-dom php-simplexml php-mbstring
        
      5. Create your Drupal 8 installation’s settings.php file from the default settings file. This file will be configured when you run through Drupal’s automated web configuration. See the Install and Configure Drupal on Debian 10 guide for more details.

        sudo cp /var/www/html/example.com/public_html/sites/default/default.settings.php /var/www/html/example.com/public_html/sites/default/settings.php
        
      6. Enforce trusted hostnames with those that users will access your site from. With the text editor of your choice, edit your settings.php file replacing the regular expression (RegEx) with a pattern that matches your own site’s URL(s).

        /var/www/html/example.com/public_html/sites/default/settings.php
        1
        2
        3
        4
        
        $settings['trusted_host_patterns'] = array(
          '^www.example.com$',
          '^example.com$',
          );

        Note

        trusted_host_patterns also accepts IP addresses or localhost.

      Configure Apache 2.4

      1. Enable Apache’s rewrite module. This module is necessary since Drupal 8 enables Clean URLs by default.

        sudo a2enmod rewrite
        
      2. Specify the rewrite conditions for your Drupal site’s document root in Apache’s configuration file using the text editor of your choice. If you installed and configured your Apache server using LAMP stack on Debian 10 guide, the configuration file for your site is located at /etc/apache2/sites-available/example.com.conf.

        /etc/apache2/sites-available/example.com.conf
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        
        <Directory /var/www/html/example.com/public_html>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
              RewriteEngine on
              RewriteBase /
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
        </Directory>
      3. Change the ownership of your site’s document root from root to www-data. This allows you to install modules and themes, and to update Drupal without being prompted for FTP credentials.

        sudo chown -R www-data:www-data /var/www/html/example.com
        
      4. Restart Apache so all changes are applied.

        sudo systemctl restart apache2
        

      Create a Drupal Website with Drush

      In this section, you will use Drush to install a Drupal site with just a few commands.

      1. Change the working directory to the location of your new Drupal website. The previous guides created a /var/www/html/example.com/public_html directory, where public_html is the document root or the publicly viewable directory. Replace example.com with your own site’s name.

        cd  /var/www/html/example.com/public_html
        
      2. Your Linode is now ready for you to install a Drupal site. In the command below, replace mysql://username:[email protected]/databasename with your own site’s username, password, and database. For example, if you followed the How to Install a LAMP stack on Ubuntu 18.04 your username is webuser, password is password, and the database is webdata. Also, replace --site-name=example.com with your own website’s name.

        drush si standard --db-url=mysql://username:[email protected]/databasename --site-name=example.com
        

        Note

        Although MySQL accepts passwords with a special character, for example an exclamation point, the drush si standard command does not. If you have a special character in your MySQL password, you may need to change it.

        Note

        After the installation is complete, Drush creates a user, named admin, and a random password. An example is pictured below. These credentials are used for the Drupal sign-in page.

        Drush Username Password

      3. Optionally, if you’d like to change the admin’s password, it is best to do so with Drush, rather than sending the password over a non-secure HTTP connection. To update the admin password execute the following command and replace newpass with your new password:

        sudo drush user-password admin user-password=newpass
        

      Setting the Site’s Ownership and Permissions

      In server administration, there are many options for user and group permissions. The directions below create a site owner and a site owner’s group. The Apache user, named www-data, is added to the site owner’s group. Then, read, write, and execute permissions are granted to both the site owner and the site owner’s group.

      1. To create a new user for the site owner position, see the Add a Limited User Account section of the Securing Your Server guide.

      2. From the public_html directory, change ownership of the site to the site owner and group. Replace example_user below with the chosen owner’s username:

        sudo chown -R example_user:example_user sites/default
        
      3. Add Apache’s www-data user to the site owner’s group:

        sudo usermod -a -G example_user www-data
        
      4. Make sure the permissions are set to allow access for the site owner and site owner’s group:

        sudo chmod -R 770 sites/default
        

        Now, www-data, example_user, and any user within the example_user group has read, write, and execute permissions for the entire Drupal site directory tree.

      5. Restart Apache:

        sudo systemctl restart apache2
        
      6. Finally, check the status of the new site:

        drush status
        

        Note

        When installing new files, like a module or theme, make sure the Apache user has access rights. Use the command ls -al to list the file permissions within a directory to determine which permissions are assigned to it.

      Navigate to your site’s domain (or IP address if you did not set up a domain name). Sign-in with the generated username and password to begin creating content for your Drupal site.

      Additional Options

      There are many ways to set up administration for a website. Below are sections explaining some additional options. It’s important to be aware of multi-site setups and additional security measures. The topics below touch on these subjects.

      File Ownership, Permissions, and Security

      The above setup is designed for ease of use. However, there are setups designed for tighter security and other considerations.

      Multi-site Servers

      At a high-level, the steps you will need to follow to begin configuring a Drupal multisite set up are:

      This guide is published under a CC BY-ND 4.0 license.



      Source link

      How to Install Drupal using Drush on CentOS 8


      Updated by Linode

      Written by Linode

      Drupal is a content management system (CMS) designed for building custom websites for personal and business use. Built for high performance and scalability, Drupal provides the necessary tools to create rich, interactive “community” websites with forums, user blogs, and private messaging. Drupal also has support for personal publishing projects and can power podcasts, blogs, and knowledge-based systems, all within a single, unified platform.

      Drush is a command line tool for creating, administrating, and modifying Drupal websites. Command line tools, like Drush, add functionality through additional command packages. Once installed, Drush is as easy to use as any of the basic Linux commands.

      Before You Begin

      1. Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.

      2. Follow our Securing Your Server guide to create a standard user account, harden SSH access, remove unnecessary network services and create firewall rules for your web server; you may need to make additional firewall exceptions for your specific application.

        Note

        This guide is written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you’re not familiar with the sudo command, visit our Users and Groups guide.

        All configuration files should be edited with elevated privileges. Remember to include sudo before running your text editor.

      3. Install and configure a LAMP stack on CentOS 8

      4. Install Composer and Drush on CentOS 8

      5. Install the wget and tar utilities. You will need this in a later section to install the Drupal 8 core.

        sudo yum install wget -y && sudo yum install tar -y
        
      6. In order to work with Drupal 8 and SELinux, you will need to install Python’s policy core utilities, which give you access to useful tools to manage SELinux settings.

        sudo yum install policycoreutils-python-utils -y
        

      Download and Prepare Drupal 8

      1. Navigate to your site’s document root. If you installed and configured your Apache server using our LAMP stack on CentOS 8 guide, your document root should be located in the /var/www/html/example.com/public_html/ directory. Replace example.com with your own document root path’s name.

        cd /var/www/html/example.com
        
      2. Download the Drupal 8 tarball. As of writing this guide, Drupal 8.8.3 is the latest version. See Drupal’s download page for their latest core tarball. Replace 8.8.3 with the version number you wish to download.

        sudo wget http://ftp.drupal.org/files/projects/drupal-8.8.3.tar.gz
        

        Caution

        Ensure that the version number matches the Drupal 8 version you wish to download.

      3. Extract the downloaded tarball’s contents into your site’s document root:

        sudo tar -zxvf drupal-8.*.tar.gz --strip-components=1 -C public_html
        
      4. Drupal depends on a PHP graphics library called GD. Install GD and other dependencies:

        sudo yum install -y php php-{cli,mysqlnd,json,opcache,xml,mbstring,gd,curl}
        
      5. Create your Drupal 8 installation’s settings.php file from the default settings file. This file will be configured when you run through Drupal’s automated web configuration. See the Install and Configure Drupal on CentOS 8 guide for more details.

        sudo cp /var/www/html/example.com/public_html/sites/default/default.settings.php /var/www/html/example.com/public_html/sites/default/settings.php
        
      6. Enforce trusted hostnames with those that users will access your site from. With the text editor of your choice, edit your settings.php file replacing the regular expression (RegEx) with a pattern that matches your own site’s URL(s).

        /var/www/html/example.com/public_html/sites/default/settings.php
        1
        2
        3
        4
        
        $settings['trusted_host_patterns'] = array(
          '^www.example.com$',
          '^example.com$',
          );

        Note

        trusted_host_patterns also accepts IP addresses or localhost.

      Configure Apache 2.4

      1. Enable Apache’s rewrite module. This module is necessary since Drupal 8 enables Clean URLs by default. To enable this module, edit your Apache configuration to include the LoadModule line displayed in the example file below.

        /etc/httpd/conf/httpd.conf
        1
        2
        
        LoadModule rewrite_module modules/mod_rewrite.so
            
      2. Specify the rewrite conditions for your Drupal site’s document root in Apache’s configuration file using the text editor of your choice. If you installed and configured your Apache server using LAMP stack on CentOS 8 guide, the configuration file for your site is located at /etc/httpd/conf.d/example.com.conf.

        /etc/httpd/sites-enabled/example.com.conf
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        
        <Directory /var/www/html/example.com/public_html>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
              RewriteEngine on
              RewriteBase /
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
        </Directory>
      3. Set the SELinux context for your site’s directories in order to read and write to them. This includes your site’s root directory and subdirectories.

        sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/example.com/public_html(/.*)?"
        sudo chcon -Rt public_content_rw_t /var/www/html/example.com/public_html/sites/default/files
        sudo setsebool -P allow_httpd_anon_write=1
        
      4. Change the ownership of your site’s document root from root to apache. This allows you to install modules and themes, and to update Drupal, without being prompted for FTP credentials.

        sudo chown apache:apache -R /var/www/html/example.com/public_html
        
      5. Restart Apache so all your changes are applied.

        sudo systemctl restart httpd
        

      Create a Drupal Website with Drush

      In this section, you will use Drush to install a Drupal site with just a few commands.

      1. Change the working directory to the location of your new Drupal website. The previous guides created a /var/www/html/example.com/public_html directory, where public_html is the document root or the publicly viewable directory. Replace example.com with your own site’s name.

        cd  /var/www/html/example.com/public_html
        
      2. Your Linode is now ready for you to install a Drupal site. In the command below, replace mysql://username:[email protected]/databasename with your own site’s username, password, and database. For example, if you followed the How to Install a LAMP stack on CentOS 8 your username is webuser, password is password, and the database is webdata. Also, replace --site-name=example.com with your own website’s name.

        drush si standard --db-url=mysql://username:[email protected]/databasename --site-name=example.com
        

        Note

        Although MySQL accepts passwords with a special character, for example an exclamation point, the drush si standard command does not. If you have a special character in your MySQL password, you may need to change it.

        Note

        After the installation is complete, Drush creates a user, named admin, and a random password. An example is pictured below. These credentials are used for the Drupal sign-in page.

        Drush Username Password

      3. Optionally, if you’d like to change the admin’s password, it is best to do so with Drush, rather than sending the password over a non-secure HTTP connection. To update the admin password execute the following command and replace newpass with your new password:

        sudo drush user-password admin user-password=newpass
        

      Setting the Site’s Ownership and Permissions

      In server administration, there are many options for user and group permissions. The directions below create a site owner and a site owner’s group. The site owner will be added to the Apache web server’s group, named apache. Then, read, write, and execute permissions are granted to the apache user and group.

      1. To create a new user for the site owner position, see the Add a Limited User Account section of the Securing Your Server guide.

      2. From the public_html directory, change ownership of the site to the apache user and group.

        sudo chown -R apache:apache sites/default
        
      3. Add the example_user to the apache group:

        sudo usermod -a -G apache example_user
        
      4. Make sure the permissions are set to allow access for the site owner and site owner’s group. Replace example.com with your own domain name.

        sudo chmod 774 -R /var/www/html/example.com/public_html
        

        Now, apache, example_user, and any user within the apache group has read, write, and execute permissions for the entire Drupal site directory tree.

      5. Restart Apache:

        sudo systemctl restart httpd
        
      6. Finally, check the status of the new site:

        drush status
        

        Note

        When installing new files, like a module or theme, make sure the Apache user has access rights. Use the command ls -al to list the file permissions within a directory to determine which permissions are assigned to it.

      Navigate to your site’s domain (or IP address if you did not set up a domain name). Sign-in with the generated username and password to begin creating content for your Drupal site.

      Additional Options

      There are many ways to set up administration for a website. Below are sections explaining some additional options. It’s important to be aware of multi-site setups and additional security measures. The topics below touch on these subjects.

      File Ownership, Permissions, and Security

      The above setup is designed for ease of use. However, there are setups designed for tighter security and other considerations.

      Multi-site Servers

      At a high-level, the steps you will need to follow to begin configuring a Drupal multisite set up are:

      This guide is published under a CC BY-ND 4.0 license.



      Source link