One place for hosting & domains

      Debian

      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 and Configure the Caddy Web Server on Debian 10


      Updated by Linode

      Contributed by
      Linode

      Caddy is a fast, open-source, and security-focused web server written in Go. Caddy includes modern features such as support for virtual hosts, minification of static files, and HTTP/2. Caddy is also the first web-server that can obtain and renew SSL/TLS certificates automatically using Let’s Encrypt.

      Before You Begin

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

      2. Complete the sections of our Securing Your Server guide to create a standard user account, harden SSH access, and remove unnecessary network services.

      3. Register (purchase) your site’s domain name and follow our DNS Manager Overview guide to point the domain to your Linode.

      4. Update your system:

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

      Install Caddy

      1. Install Caddy. This will install Caddy version 1.0.4. along with the hook.service plugin, which gives you access to a systemd unit file that you can use to manage Caddy as a systemd service. See their downloads page for more information on available Caddy versions.

        curl https://getcaddy.com | bash -s personal hook.service
        

        Caddy will be installed to your /usr/local/bin/caddy directory.

        Note

        To learn about Caddy licensing, please read their blog post on the topic. In 2017, commercial use of Caddy and their binaries required a license, however, they have recently updated their licensing and commercial licenses are no longer required for their use.

      Add Web Content

      In this section, you will create the necessary directories to host your website files, set their correct permissions, and add a basic index file to your example site.

      Note

      Throughout this section, replace all instances of example.com with your own domain.

      1. Set up a document root for your website. A document root is the directory where your website files are stored.

        sudo mkdir -p /var/www/example.com
        
      2. Change your site’s document root to be owned by the www-data user.

        sudo chown -R www-data:www-data /var/www/example.com
        
      3. Create a test index page for your site. Replace example.com with your own domain.

        sudo touch /var/www/example.com/index.html
        
      4. Add the example html to your site’s index.

        sudo echo '<!doctype html><head><title>Caddy Test Page</title></head><body><h1>Hello, World!</h1></body></html>' | sudo tee /var/www/example.com/index.html
        

      Configure the Caddyfile

      Now that you have your website’s document root set up with example content, you are ready to configure Caddy to serve your website files to the internet. This section will create a basic Caddy configuration, which will automatically enable HTTPS using Let’s Encrypt.

      1. Create a directory to store Caddy’s configuration files:

        sudo mkdir -p /etc/caddy
        
      2. Update the directory’s owner to be the web server user, www-data.

        sudo chown -R www-data:www-data /etc/caddy
        
      3. Using the text editor of your choice, create and edit the Caddyfile to serve your example site. The Caddyfile is Caddy’s main configuration file. Replace example.com with your own domain.

        /etc/caddy/Caddyfile
        1
        2
        3
        4
        
        example.com {
            root /var/www/example.com
        }
              
      4. Install Caddy as a systemd service:

        sudo caddy -service install
        
      5. Start the Caddy service:

        sudo systemctl start caddy
        
      6. Verify that the service is active:

        sudo systemctl status caddy
        

        You should see a similar output:

          
        ● caddy.service - Caddy's service
           Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled)
           Active: active (running) since Thu 2020-03-05 14:56:45 EST; 9s ago
         Main PID: 19505 (caddy)
            Tasks: 10 (limit: 4659)
           CGroup: /system.slice/caddy.service
                   └─19505 /usr/local/bin/caddy
        
        Mar 05 14:56:45 example_hostname systemd[1]: Started Caddy's service.
        Mar 05 14:56:45 example_hostname caddy[19505]: Activating privacy features... done.
        Mar 05 14:56:45 example_hostname caddy[19505]: Serving HTTP on port 2015
        Mar 05 14:56:45 example_hostname caddy[19505]: http://:2015
        
        
      7. Tell Caddy where to look for your Caddyfile, replace [email protected] with your email address:

        caddy -agree -conf /etc/caddy/Caddyfile -email [email protected] &
        

        Caddy will automatically serve your site over HTTPS using Let’s Encrypt.

          
        Activating privacy features...
        
        2020/03/05 13:31:25 [INFO] acme: Registering account for [email protected]
        2020/03/05 13:31:25 [INFO] [example.com] acme: Obtaining bundled SAN certificate
        2020/03/05 13:31:26 [INFO] [example.com] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz-v3/3180082162
        2020/03/05 13:31:26 [INFO] [example.com] acme: Could not find solver for: tls-alpn-01
        2020/03/05 13:31:26 [INFO] [example.com] acme: use http-01 solver
        2020/03/05 13:31:26 [INFO] [example.com] acme: Trying to solve HTTP-01
        2020/03/05 13:31:26 [INFO] [example.com] Served key authentication
        2020/03/05 13:31:26 [INFO] [example.com] Served key authentication
        2020/03/05 13:31:26 [INFO] [example.com] Served key authentication
        2020/03/05 13:31:36 [INFO] [example.com] Served key authentication
        2020/03/05 13:31:40 [INFO] [example.com] The server validated our request
        2020/03/05 13:31:40 [INFO] [example.com] acme: Validations succeeded; requesting certificates
        2020/03/05 13:31:41 [INFO] [example.com] Server responded with a certificate.
        done.
        
        Serving HTTPS on port 443
        https://example.com
        
        Serving HTTP on port 80
        http://example.com
            
        
      8. Open a web browser and visit your domain. You should see the contents of the index.html page that you created in Step 4 of the Add Web Content section.

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



      Source link

      How to Install Docker CE on Debian 10


      Updated by Linode Written by Linode

      These steps install Docker Community Edition (CE) using the official Debian repositories. To install on another distribution, or to install on Mac or Windows, see the official installation page.

      1. Remove any older installations of Docker that may be on your system:

        sudo apt remove docker docker-engine docker.io
        
      2. Make sure you have the necessary packages to allow the use of Docker’s repository:

        sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg
        
      3. Add Docker’s GPG key:

        curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
        
      4. Verify the fingerprint of the GPG key:

        sudo apt-key fingerprint 0EBFCD88
        

        You should see output similar to the following:

          
        pub   rsa4096 2017-02-22 [SCEA]
              9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
        uid           [ unknown] Docker Release (CE deb) 
        sub   rsa4096 2017-02-22 [S]
        
        
      5. Add the stable Docker repository:

        sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
        

        Note

        If you get an E: Package 'docker-ce' has no installation candidate error, this is because the stable version of Docker is not yet available. Therefore, you will need to use the edge / test repository.

        sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable edge test"
        
      6. Update your package index and install Docker CE:

        sudo apt update
        sudo apt install docker-ce
        
      7. Add your limited Linux user account to the docker group:

        sudo usermod -aG docker $USER
        

        Note

        After entering the usermod command, you will need to close your SSH session and open a new one for this change to take effect.

      8. Check that the installation was successful by running the built-in “Hello World” program:

        docker run hello-world
        

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



      Source link