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
- Sign Up: If you don’t already have a DigitalOcean account, go to DigitalOcean’s website and sign up.
- Add Payment Information: Enter your payment details to activate your account.
Step 2: Create a New Droplet
- Log In to DigitalOcean: Access your DigitalOcean dashboard by logging in.
- 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.
- 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:bashssh root@your_droplet_ip
Step 3: Set Up the Server Environment
- Update Packages:
- Once logged in, update your package lists and upgrade existing packages:
bash
sudo apt update
sudo apt upgrade
- Once logged in, update your package lists and upgrade existing packages:
- Install Necessary Software:
- Install Apache:
bash
sudo apt install apache2
- Install MySQL:
bash
sudo apt install mysql-server
- Secure MySQL Installation:
bash
sudo mysql_secure_installation
Follow the prompts to set up a root password and secure your MySQL installation.
- Install PHP:
bash
sudo apt install php libapache2-mod-php php-mysql
- Install Apache:
- Restart Apache:
- Restart Apache to apply changes:
bash
sudo systemctl restart apache2
- Restart Apache to apply changes:
Step 4: Create a MySQL Database for WordPress
- Access MySQL:
- Log in to MySQL:
bash
sudo mysql -u root -p
- Log in to MySQL:
- Create a Database and User:
- Run the following commands to create a database and user:
sql
CREATE 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;
- Run the following commands to create a database and user:
Step 5: Download and Install WordPress
- Download WordPress:
- Navigate to the
/var/www/html
directory and download WordPress:bashcd /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
- Navigate to the
- Set Correct Permissions:
- Adjust the file permissions:
bash
sudo chown -R www-data:www-data /var/www/html
- Adjust the file permissions:
- Configure WordPress:
- Rename the sample configuration file:
bash
sudo cp wp-config-sample.php wp-config.php
- Edit the
wp-config.php
file to add your database details:bashsudo nano wp-config.php
Update the following lines with your database information:
phpdefine('DB_NAME', 'wordpress_db');
define('DB_USER', 'wordpress_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');
- Rename the sample configuration file:
Step 6: Complete the WordPress Installation
- Access Your Website:
- Open your web browser and go to your droplet’s IP address. You should see the WordPress setup page.
- 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
- Set Up a Firewall:
- Use
ufw
to set up a basic firewall:bashsudo ufw allow OpenSSH
sudo ufw allow 'Apache Full'
sudo ufw enable
- Use
- Enable Automatic Security Updates:
- Install and configure unattended-upgrades to keep your system updated:
bash
sudo apt install unattended-upgrades
- Install and configure unattended-upgrades to keep your system updated:
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.
- Compare Shopify vs WooCommerce Choose a Platform for Your POD Business
- How to Ways to Scrape Data from Website to Excel
- How to Install and Activate a Theme on Your WordPress Website
- How to use Amazon Product Scraper
- How to use Tool Crawler Converter Variant Shopify/ShopBase/Woocommerce/ViralStyle CSV update