1. Launching a Virtual Machine Instance
Step 1: Log in to your Cloud Provider Console
- Go to your chosen cloud service dashboard.
- Select Create Instance or Launch Instance.
Step 2: Choose an OS Image
- Select Ubuntu 22.04 or a similar version as the operating system.
Step 3: Configure the Instance
- Choose the instance type (e.g., t2.micro for free-tier on AWS).
- Select Storage (minimum 10GB).
- Set Security Groups: Allow HTTP (port 80), HTTPS (port 443), and SSH (port 22).
Step 4: Launch Instance
- After launching the instance, download the private key file for SSH access.
2. Accessing the Virtual Machine via SSH
Open your terminal or SSH client and connect to your instance with:
ssh -i path/to/your-key.pem ubuntu@<your-instance-public-ip>
3. Installing WordPress
Install Prerequisites
Run the following commands to install Apache, MySQL, PHP, and required PHP modules:
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php unzip wget -y
Secure MySQL Installation
sudo mysql_secure_installation
Follow the prompts to secure MySQL.
Create WordPress Database
sudo mysql -u root -p
Inside the MySQL prompt, create a database for WordPress:
CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Download WordPress
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress /var/www/html/
Set Permissions for WordPress
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
Configure Apache to Serve WordPress
Update Apache configuration:
sudo nano /etc/apache2/sites-available/000-default.conf
Change DocumentRoot /var/www/html
to:
DocumentRoot /var/www/html/wordpress
Disable the Default Apache Site:
sudo a2dissite 000-default.conf
Enable Rewrite Module:
sudo a2enmod rewrite
Restart Apache:
sudo systemctl restart apache2
Complete WordPress Setup
Open your browser and navigate to http://<your-instance-public-ip>
.
Follow the WordPress installation wizard.
4. Troubleshooting Steps
Issue 1: Apache Default Welcome Page Still Showing
-
Move WordPress Files to the Correct Directory
Ensure the WordPress files are in
/var/www/html/wordpress
:
sudo ls /var/www/html/wordpress
If the directory is empty, re-download WordPress:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress /var/www/html/
- Set WordPress as the Default Site Edit the Apache configuration to serve WordPress:
sudo nano /etc/apache2/sites-available/000-default.conf
Change DocumentRoot /var/www/html
to:
DocumentRoot /var/www/html/wordpress
- Disable Apache’s Default Welcome Page Disable the default welcome page to prevent it from overriding WordPress:
sudo a2dissite 000-default.conf
- Enable Rewrite Module
sudo a2enmod rewrite
- Restart Apache
sudo systemctl restart apache2
- Check Permissions Make sure WordPress files have the correct permissions:
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
-
Access WordPress Setup
Navigate to
http://<your-instance-public-ip>
in your browser and continue the WordPress installation.
Issue 2: Database Issues
- Check if the database exists:
SHOW DATABASES;
- Grant privileges on WordPress database:
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
Conclusion
You should now have a fully functional WordPress installation. If issues persist, refer to the troubleshooting steps provided to resolve common problems related to Apache configuration, WordPress file permissions, and database connections.
Tips:
- Ensure your SSH key is correctly set up and you’re using the right permissions for secure access.
- Regularly back up your WordPress site and database to avoid data loss.
Top comments (0)