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 […]
2 min read
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:
- Virtualization software:
- Operating system ISO for the virtual machine:
- Ubuntu Server (recommended): Download
- WordPress source files: Download WordPress
3. Create the Virtual Machine
Using VirtualBox:
- Install VirtualBox:
- Download and install VirtualBox.
- 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+).
- 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
- Boot the VM:
- Start the VM and follow the on-screen instructions to install the OS.
- 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
- Download WordPress:
wget https://wordpress.org/latest.tar.gz tar -xzvf latest.tar.gz
- Move to Web Directory:
sudo mv wordpress /var/www/html
- 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
- Access MySQL:
sudo mysql -u root -p
- 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
- Navigate to
/var/www/html/wordpress
. - Rename the sample configuration file:
mv wp-config-sample.php wp-config.php
- 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
- Find your VM’s IP address:
ip addr show
Look for an IP under
inet
, e.g.,192.168.1.100
. - Open a web browser and navigate to:
http://<VM_IP>/wordpress
- Follow the on-screen setup to complete the installation.
10. Optional: Enable Remote Access
- Allow HTTP and HTTPS traffic through the firewall:
sudo ufw allow 'Apache Full'
- Set up port forwarding on your home router:
- Forward external port 80/443 to your VM’s IP.
- Use a Dynamic DNS (DDNS) service if you don’t have a static IP.
11. Optional: Secure Your Server
- Install Certbot for HTTPS:
sudo apt install certbot python3-certbot-apache sudo certbot --apache
- 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