Hostrings: Pakistan's Premier Website and Mobile App Development Company

   +92 333 238 1098   EYEGLASSES TRY ON

HomeHome vitrual server wordpress Ubuntu ServerBlogHome vitrual server wordpress Ubuntu Server

Home vitrual server wordpress Ubuntu Server

Detailed guide to setting up a home virtual server for WordPress:


1. Understand the Environment

WordPress requires a web server, database, and PHP environment to run. You’ll set up a virtual server using software like VirtualBox or VMware, which will host the required stack.

Why Use a Virtual Server?

  • Experiment safely without affecting your main system.
  • Isolate the server environment.
  • Mimic production environments for testing.

2. Prerequisites

Hardware Requirements:

  • A PC with at least 8GB RAM (4GB minimum for VM).
  • At least 20GB of free storage space.

Software Requirements:

  1. Virtualization software:
    • VirtualBox (Free): Download
    • VMware Workstation Player (Free for personal use): Download
  2. Operating system ISO for the virtual machine:
  3. WordPress source files: Download WordPress

3. Create the Virtual Machine

Using VirtualBox:

  1. Install VirtualBox:
    • Download and install VirtualBox.
  2. Create a New Virtual Machine:
    • Open VirtualBox and click New.
    • Name the VM (e.g., WordPressServer).
    • Set the type to Linux and version to Ubuntu (64-bit).
    • Allocate at least 2GB RAM (4GB recommended).
    • Create a virtual hard disk (20GB+).
  3. Attach the ISO:
    • Go to the VM settings → Storage.
    • Add the Ubuntu Server ISO to the optical drive.

4. Install and Configure the Operating System

  1. Boot the VM:
    • Start the VM and follow the on-screen instructions to install the OS.
  2. Set Up the Server:
    • During installation, choose “Install OpenSSH server” to enable remote access later.
    • Set up a username and password.

5. Install the LAMP/LEMP Stack

A LAMP/LEMP stack consists of:

  • Linux: The operating system (already installed).
  • Apache/Nginx: The web server.
  • MySQL/MariaDB: The database.
  • PHP: The scripting language.

Install Apache Web Server:

sudo apt update
sudo apt install apache2
sudo systemctl enable apache2
sudo systemctl start apache2

Install MySQL Server:

sudo apt install mysql-server
sudo mysql_secure_installation

During the setup, set a root password and secure the installation.

Install PHP:

sudo apt install php libapache2-mod-php php-mysql

Verify PHP installation:

php -v

6. Download and Set Up WordPress

  1. Download WordPress:
    wget https://wordpress.org/latest.tar.gz
    tar -xzvf latest.tar.gz
    
  2. Move to Web Directory:
    sudo mv wordpress /var/www/html
    
  3. Set Correct Permissions:
    sudo chown -R www-data:www-data /var/www/html/wordpress
    sudo chmod -R 755 /var/www/html/wordpress
    

7. Configure WordPress Database

  1. Access MySQL:
    sudo mysql -u root -p
    
  2. Create a Database and User:
    CREATE DATABASE wordpress_db;
    CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_password';
    GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    

8. Configure WordPress

  1. Navigate to /var/www/html/wordpress.
  2. Rename the sample configuration file:
    mv wp-config-sample.php wp-config.php
    
  3. Edit the configuration file:
    nano wp-config.php
    

    Update the database details:

    define('DB_NAME', 'wordpress_db');
    define('DB_USER', 'wp_user');
    define('DB_PASSWORD', 'your_password');
    define('DB_HOST', 'localhost');
    

9. Access WordPress

  1. Find your VM’s IP address:
    ip addr show
    

    Look for an IP under inet, e.g., 192.168.1.100.

  2. Open a web browser and navigate to:
    http://<VM_IP>/wordpress
    
  3. Follow the on-screen setup to complete the installation.

10. Optional: Enable Remote Access

  1. Allow HTTP and HTTPS traffic through the firewall:
    sudo ufw allow 'Apache Full'
    
  2. Set up port forwarding on your home router:
    • Forward external port 80/443 to your VM’s IP.
  3. Use a Dynamic DNS (DDNS) service if you don’t have a static IP.

11. Optional: Secure Your Server

  1. Install Certbot for HTTPS:
    sudo apt install certbot python3-certbot-apache
    sudo certbot --apache
    
  2. Set up automatic updates for security patches:
    sudo apt install unattended-upgrades
    

12. Maintain Your Server

  • Regularly update the OS:
    sudo apt update && sudo apt upgrade -y
    
  • Keep WordPress and plugins updated.
  • Back up your database regularly:
    mysqldump -u wp_user -p wordpress_db > backup.sql
    
×