Install WordPress in OCI -VM

Installing WordPress in as a separate VM in oracle cloud infrastructure is straight forward. This blog explains the steps for installing WordPress in the existing virtual machine environment.

Assumptions

  • Oracle Linux Operating System
  • Apache Webserver Installed and activated
  • MySQL server installed and available in the same VM

# Bash
# Check for Updates

sudo dnf update -y
sudo dnf update -y --nogpgcheck  ## To avoid GPG check
# MYSQL
# Create MYSQL Database and User

CREATE DATABASE wordpress;
CREATE USER 'wp_user'@'%' IDENTIFIED BY 'password@1';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'%';
FLUSH PRIVILEGES;
EXIT;
# Bash
# Install MYSQL package for oracle linux

sudo dnf install php php-mysqlnd php-gd php-xml php-mbstring php-curl -y
sudo systemctl restart httpd
# Bash
# Install wordpress and assign access

wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress /var/www/html/
sudo chown -R apache:apache /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
# Bash
# Edit conf file for apache

sudo nano /etc/httpd/conf.d/wordpress.conf

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/wordpress
    ServerName example.com
    ServerAlias www.example.com

    <Directory /var/www/html/wordpress>
        AllowOverride All
    </Directory>

    ErrorLog /var/log/httpd/wordpress-error.log
    CustomLog /var/log/httpd/wordpress-access.log combined
</VirtualHost>
# Bash
# Restart Services

sudo dnf install mod_rewrite
sudo systemctl restart httpd
# Bash
# Enable SELLinux Permission

sudo dnf install policycoreutils-python-utils -y
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/wordpress(/.*)?"
sudo restorecon -Rv /var/www/html/wordpress
# Bash
# Activate SSL Encryption

sudo dnf install certbot python3-certbot-apache -y
sudo certbot --apache

Leave a Reply

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