One place for hosting & domains

      DigitalOcean

      How To Use the WordPress One-Click Install on DigitalOcean


      Introduction

      WordPress is one of the most popular content management and blog platforms in the world, allowing you to create and manage website content efficiently.

      This tutorial will share all the details you need to get your WordPress site set up using the WordPress 1-Click App.

      Software Included

      In addition to the features installed in a regular Ubuntu 20.04 Droplet, the WordPress 1-Click image also includes the following components:

      • Apache: The most widely used web (HTTP) server.

      • MySQL: A commonly used open-source relational database.

      • PHP: PHP language support.

      These components create the LAMP stack, a group of open source software typically installed together to enable a server to host dynamic websites like WordPress. The term LAMP is an acronym that represents the configuration of a Linux operating system with an Apache web server, with site data stored in a MySQL database and dynamic content processed by PHP.

      To improve security, the following additional components are included:

      • UFW: A program to simplify the management of a firewall.
      • fail2ban: A service that automatically updates your firewall configuration to block attackers.

      In this tutorial, we’ll create a WordPress 1-Click Droplet, then explain how to set up your WordPress site, configuring the domain and sharing information on how to access the MySQL database.

      Step 1 — Creating A WordPress Droplet

      To create a WordPress Droplet from the 1-Click App page, press the Create WordPress Droplet button:

      Create WordPress Droplet

      This takes you to the Create Droplets page, where you can customize your settings before creating your WordPress Droplet. How to Create your First Droplet describes each choice in detail. Below, we’ll highlight key settings:

      Choose an image:

      If not already set, you’ll need to switch from the Distributions tab to the Marketplace tab:

      Choose image tab

      Once there, WordPress 5.5.1 on Ubuntu 20.04 should be automatically selected. If not, click “WordPress 5.5.1 on Ubuntu 20.04” to select it as the image.

      Once the image is highlighted, you can accept the defaults or adjust settings according to your use case. We recommend the following changes:

      Choose a plan:

      Choose the size you need here — WordPress One-Click Droplets require 1GB of RAM or more.

      Add block storage:

      Learn more about block storage and add this to your droplet based on your use case.

      Choose a datacenter region:

      Generally, choose the data center closest to your user base.

      Select additional options:

      We recommend selecting Monitoring, a free service that will help you follow Droplet resource usage over time. You may also want to consider enabling automated backups. You can enable this now or anytime in the future.

      Choose a hostname:

      You can make it easier to identify the Droplet by naming it “WordPress,” or naming it after the site you plan to host.

      When you’ve made your choices, click Create Droplet.

      Once the Droplet is created, its address will be displayed:

      Copy address

      Click the address to copy it to your clipboard. In the next step, we’ll use this to view the WordPress site.

      Step 2 — Checking the Placeholder Page

      Open a web browser and paste the Droplet’s IP address into the location bar to visit your new site. Until you log in with SSH, the following page will appear:

      Before logging in with SSH

      This security measure has been put in place to protect the initial configuration of WordPress, in which the administrative user is set up.

      You can safely leave the installation in this state until you are ready to configure WordPress.

      Step 3 — Accessing the Droplet via SSH to Enable Configuration

      To remove the placeholder web page, you’ll first need to connect to the Droplet via SSH. Once you connect, it’s important to complete the WordPress configuration promptly. Until you do, anyone who finds your site could create the administrative user and password.

      To begin, you’ll connect directly to the server from the command line— you’ll need to complete this task once in order to configure WordPress. If you haven’t used a terminal program like SSH or PuTTY before, check out How To Connect To Your Droplet with SSH.

      When you’re ready, open a terminal on your computer and log into your Droplet as root (or your administrative user) via SSH with this command (substitute with your Droplet’s IP address):

      • ssh root@droplet.ip.address

      After the first successful SSH login, you’re ready to set your administrative password and configure WordPress.

      Note:
      You will be prompted to enter your administrative details on the terminal after logging in via SSH or temporary password. You can follow the terminal instructions to finish configuring WordPress, or use the graphical user interface configuration process that’s explained in the next step.

      Step 4 — Configuring WordPress

      After WordPress installation has been enabled by logging into the Droplet via SSH, visit the Droplet’s IP address in a web browser. You should see the following page:

      Screenshot showing the WordPress logo and a list of language

      Follow the on-screen prompts to select the language, give the site a name, and configure its administrative user. Be sure to set a strong password for added security.

      Once you have completed the initial configuration, you can log in as the administrative user you just created and continue to set up your site.

      Step 5 — Configuring a Domain

      To use a domain name instead of the IP address of your Droplet, follow the steps in How To Set Up a Host Name with DigitalOcean or set up a domain name with your own DNS provider. Either way you connect your domain name to your WordPress Droplet, once it resolves using DNS, you will need to update the WordPress configuration to use the domain.

      Log in to your WordPress admin panel at http://DROPLETIPADDRESS/wp-admin using the admin account you created earlier. Click on General under Settings in the navigation bar on the left-hand side of the page. Here, you will see several options you can configure for your site. Update the WordPress Address (URL) and Site Address (URL) fields to reflect your new domain name and click Save Changes.

      Configure to use domain name

      You can customize your site’s appearance, install plugins for added functionality, or create a new post or a page.

      Step 6 — Locating Logins and Passwords

      Additional details of your installation are provided in the MOTD (Message of the Day) which is displayed when you log into your Droplet via SSH:

      -------------------------------------------------------------------------------
      Welcome to DigitalOcean's One-Click WordPress Droplet.
      To keep this Droplet secure, the UFW firewall is enabled.
      All ports are BLOCKED except 22 (SSH), 80 (HTTP), and 443 (HTTPS).
      -------------------------------------------------------------------------------------
      

      If you need to access your MySQL database server you can find your MySQL root user password in the /root/.digitalocean_password file with the following command:

      • cat /root/.digitalocean_password

      Output

      root_mysql_pass="c404aed5e912278adb4EXAMPLE9782f390286d706a9c4f72" wordpress_mysql_pass="619863e454cEXAMPLE15be13d9730db5c0a52ad6a4d2491a"

      Copy the password, located inside the quotation marks on the line that begins root_mysql_pass. Next run the mysql command with the -u flag to specify a user (root) and the -p flag to be prompted for the password as follows:

      mysql -u root -p
      

      When prompted, paste in the password you copied.

      If you prefer to use a graphical user interface, follow the tutorial How To Install and Secure phpMyAdmin on Ubuntu 18.04.

      Conclusion

      Your WordPress site should be up and running. You can enhance its security by following our Initial Server Setup guide to give sudo privileges to your user, lock down root login, and take other steps to make your Droplet ready for production.



      Source link

      How To Deploy a React Application to DigitalOcean App Platform


      The author selected Creative Commons to receive a donation as part of the Write for DOnations program.

      Introduction

      DigitalOcean’s App Platform is a Platform as a Service (PaaS) product that lets you configure and deploy applications from a source repository. After configuring your app, DigitalOcean will build and deploy the application on every change, giving you the benefit of a full web server and deployment pipeline with minimal configuration. This can be a quick and efficient way to deploy your React applications, and if you are using React to build a site with no backend, you can use App Platform’s free tier.

      In this tutorial, you’ll deploy a React application to the DigitalOcean App Platform using the free Starter tier. You’ll build an application with Create React App, push the code to a GitHub repository, then configure the application as a DigitalOcean app. You’ll connect the app to your source code and deploy the project as a set of static files.

      By the end of this tutorial, you’ll be able to configure a React application to deploy automatically on every push to the main branch of a GitHub repository.

      Prerequisites

      Step 1 — Creating a React Project

      In this step, you’ll create a React application using Create React App and build a deployable version of it.

      To start, create a new application using Create React App on your local machine. In a terminal, run the command to build an application called digital-ocean-app:

      • npx create-react-app digital-ocean-app

      The npx command will run a Node package without downloading it to your machine. The create-react-app script will install all of the dependencies and will build a base project in the digital-ocean-app directory. For more on Create React App, check out the tutorial How To Set Up a React Project with Create React App.

      The code will download the dependencies and will create a base project. It may take a few minutes to finish. When it is complete, you will receive a success message. Your version may be slightly different if you use yarn instead of npm:

      Output

      Success! Created digital-ocean-app at your_file_path/digital-ocean-app Inside that directory, you can run several commands: npm start Starts the development server. npm build Bundles the app into static files for production. npm test Starts the test runner. npm eject Removes this tool and copies build dependencies, configuration files and scripts into the app directory. If you do this, you can’t go back! We suggest that you begin by typing: cd digital-ocean-app npm start Happy hacking!

      Now that you have a base project, run it locally so you can test how the project will appear on the server. First, change into the directory:

      Run the project using the npm start script:

      When the command runs, you’ll receive output with the URL for the local development server:

      Output

      Compiled successfully! You can now view digital-ocean-app in the browser. Local: http://localhost:3000 On Your Network: http://192.168.1.110:3000 Note that the development build is not optimized. To create a production build, use npm build.

      Open a browser to http://localhost:3000 and you’ll find your project:

      React project template running locally

      Stop the project by typing either CTRL+C or ⌘+C in the terminal.

      Now that you have a working React application, you can push the code to a GitHub repository.

      Step 2 — Pushing the Code to GitHub

      To deploy your app, App Platform retrieves your source code from a hosted code repository. In this step, you will push your React app code to a GitHub repository so that App Platform can access it later.

      Log in to your GitHub account. After you log in, create a new repository called digital-ocean-app. You can make the repository either private or public:

      New GitHub repository page

      Create React App automatically initializes your project with git, so you can set up to push the code directly to GitHub. First, add the repository that you’d like to use with the following command:

      • git remote add origin git@github.com:your_name/digital-ocean-app.git

      Next, declare that you want to push to the main branch with the following:

      Finally, push the code to your repository:

      Enter your GitHub credentials when prompted to push your code.

      When you push the code you will receive a success message. Your message will be slightly different:

      Output

      Counting objects: 22, done. Delta compression using up to 4 threads. Compressing objects: 100% (22/22), done. Writing objects: 100% (22/22), 187.50 KiB | 6.94 MiB/s, done. Total 22 (delta 0), reused 0 (delta 0) To github.com:your_name/digital-ocean-app.git 4011c66..647d2e1 main -> main

      You’ve now copied your code to the GitHub repository.

      In this step, you pushed your project to GitHub so that you can access it using DigitalOcean Apps. Next, you’ll create a new DigitalOcean App using your project and set up automatic deployment.

      Step 3 — Deploying to DigitalOcean App Platform

      In this step, you’ll deploy a React application to the DigitalOcean App Platform. You’ll connect your GitHub repository to DigitalOcean, configure the project to build, and build your initial project. After the project is live, each change will trigger a new build and update.

      By the end of this step, you’ll be able to deploy an application with continous delivery on DigitalOcean.

      To begin, log in to your DigitalOcean account and press the Create button, then select Apps:

      Create a new app page in the DigitalOcean interface

      You’ll next be prompted to link your GitHub repository. If you have not yet connected it, you will need to log in with your username and password and give DigitalOcean authorization to access your repositories:

      Link GitHub to DigitalOcean page

      Once you link your account, select the repository you’d like to connect on the GitHub authorization screen. In this case, you are using the digital-ocean-app repository, but you can connect more repositories if you would like:

      Select a repo on GitHub authorization page

      After selecting the repository, you will reconnect to the DigitalOcean interface. Select digital-ocean-app from the list of repositories, then press Next. This will connect your App directly to the GitHub repo:

      Select repo in the DigitalOcean UI

      Now that you have selected your repository, you need to configure the DigitalOcean App. In this example, the server will be based in North America by choosing New York in the Region field, and the deployment branch will be main. For your app, choose the region that is closest to your physical location:

      Select branch and location in the DigitalOcean interface

      For this tutorial, you are checking Autodeploy code changes. This will automatically rebuild your app every time you update the code.

      Press Next to move on to the Configure your app screen.

      Next, select the type of application you will run. Since React will build static assets, select Static Site from the dropdown menu in the Type field.

      Note: Create React App is not a static site generator like Gatsby, but you are using static assets, since the server does not need to run any server-side code such as Ruby or PHP. The app will use Node to run the install and build steps, but will not execute application code at the free tier.

      You also have the option to use a custom build script. But in this case, you can stick with the default npm run build command. You may want to create a custom build script if you have a different build script for a quality assurance (QA) or a production environment:

      Select Static Site on the app configuration page

      Press Next to move on to the Finalize and launch page.

      Here you can select the price plan. The free Starter tier is made for static sites, so choose that one:

      Select price option for DigitalOcean App Platform

      Press the Launch Starter App button and DigitalOcean will start building your application.

      DigitalOcean is building the application page

      The app will run the npm ci and npm build scripts in your repo. This will download all of the dependencies and create the build directory with a compiled and minified version of all of your JavaScript, HTML files, and other assets. You could also create a custom script in your package.json and update the Commands in the Components tab of your application on App Platform.

      It will take a few minutes for the build to run, but when it is finished, you will receive a success message and a link to your new site. Your link will have a unique name and will be slightly different:

      Deploy complete page

      Press Live App to access your project in the browser. It will be the same as the project you tested locally, but this will be live on the web with a secure URL:

      Live application

      Now that your project is configured, any time you make a change to the linked repository, you’ll run a new build. In this case, if you push a change to the main branch, DigitalOcean will automatically run a new deployment. There is no need to log in; it will run as soon as you push the change:

      New deploy

      In this step, you created a new DigitalOcean app on App Platform. You connected your GitHub account and configured the app to build the main branch. After configuring the application, you learned that the app will deploy a new build after every change.

      Conclusion

      DigitalOcean’s App Platform gives you a quick tool for deploying applications. With a small initial set up, your app will deploy automatically after every change. This can be used in conjunction with React to quickly get your web application up and running.

      A possible next step for a project like this would be to change the domain name of the app. To do this, take a look at the official documentation for App Platform.



      Source link

      How To Set Up an Ubuntu 20.04 Server on a DigitalOcean Droplet


      Introduction

      In this guide, you will create an Ubuntu 20.04 server through DigitalOcean’s administrative panel and configure it to work with your SSH keys. Once you have your server set up, you can use it to deploy apps and websites.

      This tutorial is part of the Introduction to the Cloud Curriculum, which guides users through all the steps of securely deploying an application to the cloud. If you are searching for general documentation on DigitalOcean Droplets, please visit our product documentation How to Create a Droplet from the DigitalOcean Control Panel.

      Prerequisites

      Before you begin this guide, you’ll need the following:

      • Some familiarity with the command line. If you’d like an introduction or refresher to the command line, you can visit our Linux Command Line Primer (coming soon).
      • SSH keys to enable a secure connection with your server. To set up SSH keys via the command line, you can follow our guide How to Set Up SSH Keys on Ubuntu 20.04.
      • A credit card or PayPal account to set up a DigitalOcean Droplet. Note that the smallest Droplet offering can be used for this tutorial, whose monthly subscription fee is available on our Pricing page. Users can cancel their Droplet service at any time.

      Note: Eligible students can sign up to receive $50 in free credits for Digital Ocean through the GitHub Student Developer Pack.

      Step 1 — Creating a DigitalOcean account

      To access the DigitalOcean Control Panel and create a Droplet, you need a DigitalOcean account. To create a new account, navigate to the DigitalOcean new account registration page. You can choose to register through email, Google, or GitHub.

      After you’ve confirmed your account, you will need to enter your credit card or Paypal information. This information is collected to verify identity and keep spammers out. You will not be charged until you choose a plan and confirm your subscription, which we will cover in Step 4. You may see a temporary pre-authorization charge to verify the card, which will be reversed within a week.

      Once your information has been accepted, you will be taken to a window that says “Registration Complete”. You are now ready to proceed to the next step.

      Step 2 — Setting Up Your Droplet

      In the previous step, you should have been taken to a window that says “Registration Complete” with a “Let’s make something” button. Click on the “Let’s make something” button. The next window will display buttons for different Droplet options. Click on the “Go to Control Panel” link at the bottom:

      Webpage displaying Droplet options

      Once you click on the “Go to Control Panel” link, you will be taken to the control panel:

      Digital Ocean Cloud Control Panel

      Navigate to the “Create” menu in the upper right corner and click “Droplets” to open the Droplet create page. If you don’t have any Droplets, the Resources tab displays a large, blue “Get Started with a Droplet” button, which takes you to the same Droplet create page.

      The Droplet create page is where you choose your Droplet’s configuration, like its operating system, how much memory it has, and which features (like backups or monitoring) to enable.

      In the next step, you will choose an image of the operating system to be installed on your Droplet.

      Step 3 — Choosing an Image

      An image is a copy of an operating system. To create a Droplet, users need to pick an image of an operating system to run their server. DigitalOcean offers five different Linux operating system distributions. As this tutorial is for setting up an Ubuntu 20.04, click on the option for Ubuntu 20.04 (LTS) x 64:

      Options of images for Droplets

      After selecting your operating system, you are ready to proceed to the next step.

      Step 4 — Choosing a Plan

      In the Choose a plan section, you can choose the amount of RAM, storage space, and CPU cores your Droplet will have. If you are following this tutorial for the Introduction to the Cloud Curriculum, the Basic $5 per month plan will work for the Curriculum’s hands-on tutorials and exercises.

      Click on the option for the Basic $5/mo plan:

      Choose a plan secton

      After selecting a plan, you are ready to proceed to the next step.

      Step 5 — Adding Block Storage (Optional)

      This option allows users to add block storage as independent volumes that can be moved from one Droplet to another within the same region. Block storage is useful when you need additional file storage space for your Droplet. If you are following this tutorial for the Introduction to the Cloud Curriculum, you do not need to add block storage. Leave this option unselected unless you want to add block storage.

      You are now ready to proceed to the next step.

      Step 6 — Choosing a Datacenter Region

      In the Choose a datacenter region section, select the region where you want to create your Droplet.

      A good default will be preselected for you, but for the best performance and minimal latency, choose the datacenter nearest to you and your users.

      Datacenter region selections

      Once you have selected your datacenter, you are ready to proceed to the next step.

      Step 7 — Selecting Additional Options

      In the Select additional options section, you can enable several optional services that add functionality to your Droplet:

      Select additional options

      The three features available in this section are free, so enabling them does not increase the Droplet’s monthly cost. They can be understood as follows:

      IPv6 enables IPv6 access for your Droplet. IPv6 is the most recent version of the Internet Protocol, which identifies computers on networks and routes traffic across the Internet. IPv6 addresses provide more address space than their IPv4 counterparts, and are part of an effort to sustain the growth and deployment of Internet-ready devices.

      User data is arbitrary data that you specify which is written to the user-data field of the DigitalOcean metadata service. To learn more about the purpose of user data, you can visit the User Data product documentation.

      Monitoring adds the DigitalOcean agent to collect extended metrics and create alert policies. To learn more about monitoring, you can visit the Monitoring product documentation.

      You can leave these options blank unless you’d like to enable them. Once you’ve selected your desired options, you are ready to proceed to the next step.

      Step 8 — Setting Up SSH Authentication

      In this section, you will set up SSH authentication for your Droplet, using the pair of SSH keys you created as one of the prerequisites for this tutorial. If you did not already create SSH keys, there will be an opportunity to create them in just a few moments.

      Click on the option to use SSH keys for authentication, which is more secure than a password. Then click on the “New SSH Key” button:

      Authentication section of Droplet set up

      A pop up window will appear prompting you to copy your public SSH key and paste it in the provided space:

      Pop-up window for SSH key

      Note: If you have not created SSH keys, follow the directions on the right side of the pop-up window to create the keys or follow our guide How to Set Up SSH Keys on Ubuntu 20.04.

      To copy your public key, run the following command in your terminal:

      Copy the output from your terminal and paste it into the space provided by the cloud panel pop-up window. Then give your key a name so you can select it later on. When you have finished, click “Add new SSH key”. You will then return to the cloud panel where you can make sure your new key is selected.

      When you have selected your new key, you are ready to proceed to the next step.

      Step 9 — Finalizing and Creating Droplet

      In this final section of the Droplet creation process, you have the option to:

      • Select the number of Droplets you wish to create. If you are following this tutorial as part of the Introduction to the Cloud Curriculum, you need to only create one Droplet. Otherwise, select your desired amount of Droplets.
      • Name the Droplet. You can use the automatically-generated name or create your own name.
      • Add tags to help organize your Droplets. You can leave this option blank if you wish.
      • Assign your Droplet to a project to help with organization. A default folder will be created and selected here. You can create new folders later if you wish.
      • Add backups. This option enables a system-level backup of your Droplet to help prevent data loss. Note that choosing this option adds $1 to your cost per month. Choose this option if you wish.

      Finalizing and Creating Droplet <br>
section

      When you are finished making your choices, click “Create Droplet.” You will then be taken to a page showing a progress bar for the Droplet creation process. When the Droplet is ready, its IP address will be displayed:

      Droplet page

      You will use this IP address to securely connect with the Droplet through your terminal. Copy the IP address and then run the following command in your terminal to securely connect with your Droplet via SSH as a root user.

      The terminal will then display a message like this:

      Output

      The authenticity of host '167.172.146.33 (167.172.146.33)' can't be established. ECDSA key fingerprint is SHA256:+Mx4ID5k4N8H7R24y+APZAoTe69hmAh9qMawyf/Lq9U. Are you sure you want to continue connecting (yes/no/[fingerprint])?

      Type yes. If you chose a passphrase when setting up SSH, you will be prompted to enter it here. If everything is working, you will then be logged into your Droplet as a root user. Note that it is strongly recommended to create a new user with lesser privileges for day-to-day use of your Droplet to avoid making irreparable changes. To create a new user, you can follow our Initial Server Setup guide, which is the next tutorial in the Introduction to the Cloud Curriculum.

      Conclusion

      In this tutorial, you have set up an Ubuntu 20.04 server on a Droplet and enabled SSH access. To learn more about what you can do with this Droplet, you can visit our Introduction to the Cloud Curriculum.

      If you wish to delete your Droplet, you can visit our product documentation on How To Destroy a Droplet. To cancel your account, please follow the instructions on our Account Cancellation page.



      Source link