How to Install WordPress on DigitalOcean: A Step-by-Step Guide

DigitalOcean provides a robust and scalable cloud infrastructure that’s perfect for hosting WordPress sites. If you’re looking to set up a WordPress website on DigitalOcean, this guide will walk you through the process from start to finish. By the end, you’ll have a fully functional WordPress site running on a DigitalOcean droplet.

Step 1: Create a DigitalOcean Account

  1. Sign Up: If you don’t already have a DigitalOcean account, go to DigitalOcean’s website and sign up.
  2. Add Payment Information: Enter your payment details to activate your account.

Step 2: Create a New Droplet

  1. Log In to DigitalOcean: Access your DigitalOcean dashboard by logging in.
  2. Create a Droplet:
    • Click on the “Create” button and select “Droplet” from the dropdown menu.
    • Choose an OS: For WordPress, a popular choice is Ubuntu. Select the latest version of Ubuntu (e.g., Ubuntu 22.04).
    • Select a Plan: Choose a plan that fits your needs. For most small to medium WordPress sites, the basic plan (e.g., $5/month) is sufficient.
    • Choose a Data Center: Select a data center location that is closest to your target audience.
    • Add SSH Keys: For secure access, add your SSH keys. If you don’t have an SSH key, you can generate one using tools like ssh-keygen on your local machine.
    • Create Droplet: Click on “Create Droplet” to launch your server.
  3. Access Your Droplet:
    • Once your droplet is created, you will receive an email with its IP address and root password.
    • Use an SSH client (like ssh in the terminal or PuTTY on Windows) to connect to your droplet:bashCopy codessh root@your_droplet_ip

Step 3: Set Up the Server Environment

  1. Update Packages:
    • Once logged in, update your package lists and upgrade existing packages:bashCopy codesudo apt update
      sudo apt upgrade
  2. Install Necessary Software:
    • Install Apache:bashCopy codesudo apt install apache2
    • Install MySQL:bashCopy codesudo apt install mysql-server
    • Secure MySQL Installation:bashCopy codesudo mysql_secure_installation
      Follow the prompts to set up a root password and secure your MySQL installation.
    • Install PHP:bashCopy codesudo apt install php libapache2-mod-php php-mysql
  3. Restart Apache:
    • Restart Apache to apply changes:bashCopy codesudo systemctl restart apache2

Step 4: Create a MySQL Database for WordPress

  1. Access MySQL:
    • Log in to MySQL:bashCopy codesudo mysql -u root -p
  2. Create a Database and User:
    • Run the following commands to create a database and user:sqlCopy codeCREATE DATABASE wordpress_db;
      CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'your_password';
      GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
      FLUSH PRIVILEGES;
      EXIT;

Step 5: Download and Install WordPress

  1. Download WordPress:
    • Navigate to the /var/www/html directory and download WordPress:bashCopy codecd /var/www/html
      sudo wget https://wordpress.org/latest.tar.gz
      sudo tar xzvf latest.tar.gz
      sudo mv wordpress/* .
      sudo rm -rf wordpress latest.tar.gz
  2. Set Correct Permissions:
    • Adjust the file permissions:bashCopy codesudo chown -R www-data:www-data /var/www/html
  3. Configure WordPress:
    • Rename the sample configuration file:bashCopy codesudo cp wp-config-sample.php wp-config.php
    • Edit the wp-config.php file to add your database details:bashCopy codesudo nano wp-config.php
      Update the following lines with your database information:phpCopy codedefine('DB_NAME', 'wordpress_db');
      define('DB_USER', 'wordpress_user');
      define('DB_PASSWORD', 'your_password');
      define('DB_HOST', 'localhost');

Step 6: Complete the WordPress Installation

  1. Access Your Website:
    • Open your web browser and go to your droplet’s IP address. You should see the WordPress setup page.
  2. Follow the Installation Wizard:
    • Choose your language and click “Continue.”
    • Enter your site title, admin username, password, and email address.
    • Click “Install WordPress” and then log in using the credentials you set up.

Step 7: Secure Your Server

  1. Set Up a Firewall:
    • Use ufw to set up a basic firewall:bashCopy codesudo ufw allow OpenSSH
      sudo ufw allow 'Apache Full'
      sudo ufw enable
  2. Enable Automatic Security Updates:
    • Install and configure unattended-upgrades to keep your system updated:bashCopy codesudo apt install unattended-upgrades

And there you have it! Your WordPress site is now up and running on DigitalOcean. With this setup, you’re ready to start customizing your site, installing themes and plugins, and adding content. If you encounter any issues or need further customization, DigitalOcean’s documentation and community forums are great resources for additional help.

Xem thêm:

Leave a Reply

Your email address will not be published. Required fields are marked *

About Us

📍 thon Doai

📞 0346386451

📧 user@gmail.com

Quick Links

Terms & Conditions

Privacy Policy

Ordering Guide

Delivery & Order Fulfillment

Return & Refund

Customer Support

Contact Us

About Us

FAQ

DCMA

Social

Facebook Zalo Twitter YouTube
Copyright 2025 © Last updated 2025