One place for hosting & domains

      Development

      How to Set Up a Jekyll Development Site on Ubuntu 18.04


      Not using Ubuntu 18.04?


      Choose a different version or distribution.

      Introduction

      If you’re looking to build a static website or blog quickly, Jekyll could be a great solution. An open-source static-site generator written in Ruby, Jekyll allows for quick execution of commands that help manage your site from initial to production deployment, all from your command line. Jekyll is blog-aware, giving priority to categories, posts, and layouts with a range of importers available to import previous blog content. If you need to work offline often, prefer using lightweight editors to web forms for content maintenance, or wish to use version control to track changes to your website, Jekyll could provide you with what you need to accomplish your goals.

      In this tutorial, we will install a Jekyll development site on Ubuntu 18.04 with automatically-generated content. With Jekyll installed, you’ll be able to create a personal site or blog primarily using markdown files and a few Jekyll commands.

      Prerequisites

      To follow this tutorial, you will need:

      Once you’ve completed this prerequisite, you’re ready to install Jekyll and its dependencies.

      Step 1 — Installing Jekyll

      We’ll start by updating our package list to be sure we have the latest information on the newest versions of packages and their dependencies:

      Next, let’s install make and build-essential so that Jekyll’s libraries will compile, and for Ruby and its development libraries to use. We include the y flag here to confirm that yes, we would like to install the packages and avoid the prompt to confirm.

      • sudo apt -y install make build-essential ruby ruby-dev

      When that’s complete, let’s add two lines to our .bashrc file to tell Ruby’s gem package manager to place gems in our user’s home folder. This avoids problems occurring from system-wide installations while also adding the local jekyll command to the user’s PATH.

      Open .bashrc with an editor of your choice, such as nano:

      At the bottom of the file, add the following lines:

      .bashrc

      # Ruby exports
      
      export GEM_HOME=$HOME/gems
      export PATH=$HOME/gems/bin:$PATH
      

      Save and close the file. To activate the exports, run the following:

      When that’s complete, we’ll use gem to install Jekyll itself as well as Bundler, which manages gem dependencies. Note that this may take some time.

      • gem install jekyll bundler

      Next, we’ll make sure that our firewall settings allow traffic to and from Jekyll’s development web server.

      Step 2 — Opening the Firewall

      Let’s check whether the firewall is enabled. If so, we’ll ensure traffic to our site is permitted so we will be able to view our development site in a web browser.

      If you’ve encountered a status showing inactive, run the following commands.

      ufw allow OpenSSH
      sudo ufw enable
      

      This will enable your firewall to run on system startup. You may get the following prompts (confirm with ‘y’ to continue):

      Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
      Firewall is active and enabled on system startup
      

      In our case, only SSH is allowed through:

      Output

      Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6)

      You may have other rules in place or no firewall rules at all depending on how you have set up your firewall. Since only SSH traffic is permitted in this case, we’ll need to open port 4000, the default port for the Jekyll development server:

      Now our firewall rules should include the following:

      Output

      To Action From -- ------ ---- OpenSSH ALLOW Anywhere 4000 ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) 4000 (v6) ALLOW Anywhere (v6)

      Now with the software installed and the necessary port open, we’re ready to create the development site.

      Step 3 — Creating a New Development Site

      From our home directory, we’re using Jekyll’s new command to create scaffolding for a site in a subdirectory called www:

      The jekyll new command initiates a bundle install to install the required dependencies, then automatically installs a theme called Minima. Following a successful installation, you should receive output like the following:

      Output

      New jekyll site installed in /home/sammy/www.

      Jekyll’s new command creates the following directories and files:

      ...
      ├── 404.html
      ├── about.markdown
      ├── _config.yml
      ├── Gemfile
      ├── Gemfile.lock
      ├── index.markdown
      ├── _posts
      │   └── 2020-05-29-welcome-to-jekyll.markdown
      └── _site
      

      These aren’t the actual web site files. They are the source files that Jekyll will use to create the static site. Jekyll relies on specific names, naming patterns, and directory structures to parse the different sources of content and assemble them into a static site. It’s important to use the existing structure and follow Jekyll’s naming conventions when adding new posts and pages.

      Tip: tree is a useful command for inspecting file and directory structures from the command-line. You can install it with the following command:

      To use it, cd into the directory you want and type tree or provide the path to the starting point with tree /home/sammy/www

      Step 4 — Starting Jekyll’s Web Server

      Jekyll’s built-in lightweight web server is tailored to support site development by monitoring the files in the directory and automatically regenerating the static site any time a change is saved.

      Because we are working on a remote server, we’ll specify the host address in order to browse the site from our local machine. If you are working on a local machine, you can run jekyll serve without the host setting and connect with http://localhost:4000.

      • cd ~/www
      • jekyll serve --host=203.0.113.0

      Output of jekyll server

      Configuration file: /home/sammy/www/_config.yml Source: /home/sammy/www Destination: /home/sammy/www/_site Incremental build: disabled. Enable with --incremental Generating... done in 0.645 seconds. Auto-regeneration: enabled for '/home/sammy/www' Server address: http://203.0.113.0:4000/ Server running... press ctrl-c to stop.

      When we invoked jekyll serve, Jekyll parsed the configuration and content files into a new directory, _site and started serving the content in that _site folder:

      ...
      ├── 404.html
      ├── about.markdown
      ├── _config.yml
      ├── Gemfile
      ├── Gemfile.lock
      ├── index.markdown
      ├── _posts
      │   └── 2020-05-29-welcome-to-jekyll.markdown
      └── _site
          ├── 404.html
          ├── about
          │   └── index.html
          ├── assets
          │   ├── main.css
          │   │   ├── main.css.map
          │   └── minima-social-icons.svg
          ├── feed.xml
          ├── index.html
          └── jekyll
              └── update
                  └── 2020
                      └── 05
                          └── 29
                              └── welcome-to-jekyll.html
      

      It also started watching the current directory, www, for changes. As soon as a change to a post or page is saved, the static site will automatically be rebuilt, so it’s important not to make changes directly to files in the _site folder.

      If we leave this terminal open with the development server running in the foreground when working on our site, we’ll receive immediate feedback as we add pages and posts and change content.

      Note: If you’re working with a large site, enabling the --incremental build can speed up the rebuild each time you make a change by only regenerating the files that are changed, but we don’t need it for this small site. You can learn more about this experimental feature on the Jekyll website.

      The site is now available. In a web browser, we can visit it at the server address and port shown in the the output from jekyll serve:

      Screenshot of the Jekyll homepage

      Conclusion

      In this tutorial, we installed Jekyll and created a development site with some automatically-generated content. You can learn more about Jekyll by reading our other tutorials on the subject:



      Source link

      How to Set Up a Jekyll Development Site on Ubuntu 20.04


      Not using Ubuntu 20.04?


      Choose a different version or distribution.

      Introduction

      If you’re looking to build a static website or blog quickly, Jekyll could be a great solution. An open-source static-site generator written in Ruby, Jekyll allows for quick execution of commands that help manage your site from initial to production deployment, all from your command line. Jekyll is blog-aware, giving priority to categories, posts, and layouts with a range of importers available to import previous blog content. If you need to work offline often, prefer using lightweight editors to web forms for content maintenance, or wish to use version control to track changes to your website, Jekyll could provide you with what you need to accomplish your goals.

      In this tutorial, we will install a Jekyll development site on Ubuntu 20.04 with automatically-generated content. With Jekyll installed, you’ll be able to create a personal site or blog primarily using markdown files and a few Jekyll commands.

      Prerequisites

      To follow this tutorial, you will need:

      Once you’ve completed this prerequisite, you’re ready to install Jekyll and its dependencies.

      Step 1 — Installing Jekyll

      We’ll start by updating our package list to be sure we have the latest information on the newest versions of packages and their dependencies:

      Next, let’s install make and build-essential so that Jekyll’s libraries will compile, and for Ruby and its development libraries to use. We include the y flag here to confirm that yes, we would like to install the packages and avoid the prompt to confirm.

      • sudo apt -y install make build-essential ruby ruby-dev

      When that’s complete, let’s add two lines to our .bashrc file to tell Ruby’s gem package manager to place gems in our user’s home folder. This avoids problems occurring from system-wide installations while also adding the local jekyll command to the user’s PATH.

      Open .bashrc with an editor of your choice, such as nano:

      At the bottom of the file, add the following lines:

      .bashrc

      # Ruby exports
      
      export GEM_HOME=$HOME/gems
      export PATH=$HOME/gems/bin:$PATH
      

      Save and close the file. To activate the exports, run the following:

      When that’s complete, we’ll use gem to install Jekyll itself as well as Bundler, which manages gem dependencies. Note that this may take some time.

      • gem install jekyll bundler

      Next, we’ll make sure that our firewall settings allow traffic to and from Jekyll’s development web server.

      Step 2 — Opening the Firewall

      Let’s check whether the firewall is enabled. If so, we’ll ensure traffic to our site is permitted so we will be able to view our development site in a web browser.

      If you’ve encountered a status showing inactive, run the following commands.

      ufw allow OpenSSH
      sudo ufw enable
      

      This will enable your firewall to run on system startup. You may get the following prompts (confirm with ‘y’ to continue):

      Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
      Firewall is active and enabled on system startup
      

      In our case, only SSH is allowed through:

      Output

      Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6)

      You may have other rules in place or no firewall rules at all depending on how you have set up your firewall. Since only SSH traffic is permitted in this case, we’ll need to open port 4000, the default port for the Jekyll development server:

      Now our firewall rules should include the following:

      Output

      To Action From -- ------ ---- OpenSSH ALLOW Anywhere 4000 ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) 4000 (v6) ALLOW Anywhere (v6)

      Now with the software installed and the necessary port open, we’re ready to create the development site.

      Step 3 — Creating a New Development Site

      From our home directory, we’re using Jekyll’s new command to create scaffolding for a site in a subdirectory called www:

      The jekyll new command initiates a bundle install to install the required dependencies, then automatically installs a theme called Minima. Following a successful installation, you should receive output like the following:

      Output

      New jekyll site installed in /home/sammy/www.

      Jekyll’s new command creates the following directories and files:

      ...
      ├── 404.html
      ├── about.markdown
      ├── _config.yml
      ├── Gemfile
      ├── Gemfile.lock
      ├── index.markdown
      ├── _posts
      │   └── 2020-05-29-welcome-to-jekyll.markdown
      └── _site
      

      These aren’t the actual web site files. They are the source files that Jekyll will use to create the static site. Jekyll relies on specific names, naming patterns, and directory structures to parse the different sources of content and assemble them into a static site. It’s important to use the existing structure and follow Jekyll’s naming conventions when adding new posts and pages.

      Tip: tree is a useful command for inspecting file and directory structures from the command-line. You can install it with the following command:

      To use it, cd into the directory you want and type tree or provide the path to the starting point with tree /home/sammy/www

      Step 4 — Starting Jekyll’s Web Server

      Jekyll’s built-in lightweight web server is tailored to support site development by monitoring the files in the directory and automatically regenerating the static site any time a change is saved.

      Because we are working on a remote server, we’ll specify the host address in order to browse the site from our local machine. If you are working on a local machine, you can run jekyll serve without the host setting and connect with http://localhost:4000.

      • cd ~/www
      • jekyll serve --host=203.0.113.0

      Output of jekyll server

      Configuration file: /home/sammy/www/_config.yml Source: /home/sammy/www Destination: /home/sammy/www/_site Incremental build: disabled. Enable with --incremental Generating... done in 0.645 seconds. Auto-regeneration: enabled for '/home/sammy/www' Server address: http://203.0.113.0:4000/ Server running... press ctrl-c to stop.

      When we invoked jekyll serve, Jekyll parsed the configuration and content files into a new directory, _site and started serving the content in that _site folder:

      ...
      ├── 404.html
      ├── about.markdown
      ├── _config.yml
      ├── Gemfile
      ├── Gemfile.lock
      ├── index.markdown
      ├── _posts
      │   └── 2020-05-29-welcome-to-jekyll.markdown
      └── _site
          ├── 404.html
          ├── about
          │   └── index.html
          ├── assets
          │   ├── main.css
          │   │   ├── main.css.map
          │   └── minima-social-icons.svg
          ├── feed.xml
          ├── index.html
          └── jekyll
              └── update
                  └── 2020
                      └── 05
                          └── 29
                              └── welcome-to-jekyll.html
      

      It also started watching the current directory, www, for changes. As soon as a change to a post or page is saved, the static site will automatically be rebuilt, so it’s important not to make changes directly to files in the _site folder.

      If we leave this terminal open with the development server running in the foreground when working on our site, we’ll receive immediate feedback as we add pages and posts and change content.

      Note: If you’re working with a large site, enabling the --incremental build can speed up the rebuild each time you make a change by only regenerating the files that are changed, but we don’t need it for this small site. You can learn more about this experimental feature on the Jekyll website.

      The site is now available. In a web browser, we can visit it at the server address and port shown in the the output from jekyll serve:

      Screenshot of the Jekyll homepage

      Conclusion

      In this tutorial, we installed Jekyll and created a development site with some automatically-generated content. You can learn more about Jekyll by reading our other tutorials on the subject:



      Source link

      How To Install Java Development Kit 11 on Ubuntu 20.04


      Updated by Linode Contributed by Rajakavitha Kodhandapani

      Java is one of the world’s most popular programming languages. Software written in Java can be compiled and run on any system, making Java a versatile platform that can be used to create anything from software to basic web applications. This guide will show you how to install the Open Java Development Kit (OpenJDK) 11 on Ubuntu 20.04.

      OpenJDK is the free and open-source implementation of the Oracle Java Standard Edition (Java SE) Development Kit. OpenJDK and Java SE are equivalent JDKs that include a Java runtime environment (JRE) and tools for developing and compiling Java applications.

      While there are many available versions of OpenJDK, version 11 is the latest Long-Term-Support (LTS) release as of the time of this guide’s publication. For this reason, OpenJDK 11 is the recommended version for developing production applications.

      Before You Begin

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

      2. Complete the sections of our guide on Securing Your Server to create a standard user account, harden SSH access and remove unnecessary network services. This guide will use sudo commands wherever possible, which should be run by a limited, non-root user on your Linode.

      3. Ensure your system is up-to-date:

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

      Install OpenJDK

      1. Install the OpenJDK 11 development kit, which includes OpenJRE 11:

        sudo apt-get install openjdk-11-jdk
        

        Alternatively, if you simply want to run Java applications that you have already downloaded, you can choose to only install OpenJRE 11:

        sudo apt-get install openjdk-11-jre
        

        Note

        While you can run Java applications directly with the JRE, your applications will be compiled every time they are executed. This is generally slower than running applications that have already been compiled into Java bytecode, and may not be suitable for frequent application execution.

      2. Check the version of the JRE to verify that it has been properly installed:

        java -version
        

        As of the time of this publication, this command should return:

          
        openjdk version "11.0.7" 2020-04-14
        OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
        OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)
        
        
      3. If you have chosen to install the full OpenJDK development kit, check the version of the compiler as well:

        javac -version
        

        As of the time of this publication, this command should return:

          
        javac 11.0.7
        
        

      Set Environment Variables

      This section will instruct you on how to set the JAVA_HOME and PATH environment variables to help ensure that your Java applications will run without issue.

      1. Open the ~/.bashrc startup file using the text editor of your choice and add the following definitions at the end of the file:

        ~/.bashrc
        1
        2
        3
        
        # [...]
        export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
        export PATH=$PATH:$JAVA_HOME/bin

        Note

        If you are using a shell other than Bash, such as Zsh, you may need to add these lines in a different startup file instead. In the case of Zsh, this would be the ~/.zshrc file.
      2. Save the changes and exit your text editor.

      3. Reload the ~/.bashrc file:

        source ~/.bashrc
        
      4. Verify that the JAVA_HOME and PATH variables were set correctly:

        echo $JAVA_HOME
        echo $PATH
        

        The JAVA_HOME variable should be set to the directory that contains your OpenJDK installation, and the PATH variable should include the directory that contains the OpenJDK binary files.

      Test the Java Installation (Optional)

      To test your Java installation, write a sample HelloWorld Java application and run it with the JRE.

      1. Open a text editor and add the following lines in a file labeled HelloWorld.java to create a simple function that prints “Hello Java World!”:

        HelloWorld.java
        1
        2
        3
        4
        5
        
        public class HelloWorld {
            public static void main(String[] args) {
                System.out.println("Hello Java World!");
            }
        }
      2. Run the application using the JRE:

        java HelloWorld.java
        

        If the installation has been successful, the output will be:

          
        Hello Java World!
        
        

      If you have installed the full OpenJDK development kit, you can compile your application into a bytecode class file prior to running it for faster execution time.

      1. Compile the application you have written:

        javac HelloWorld.java
        
      2. Confirm that the HelloWorld.class file was written to your current directory:

        ls -l HelloWorld.class
        
      3. Run the compiled HelloWorld function using the JRE:

        java HelloWorld
        

        The output should again be:

          
        Hello Java World!
        
        

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



      Source link