Migrate WordPress from AWS to OCI

AWS turned out to be super costly for running a simple wordpress website on a single T2 micro VM (on-demand plan) with both apache webserver and mysql database. The overall cost came around 1400 INR for a month. With savings plan for 1 year/3year, we could get around 30% discount. It would be still be 1000+ INR for a month.

I started evaluating other options like BlueHost. But they rely on certain plugins for migrating the data. By chance, I happen to see that Oracle Cloud Infrastructure offers a free tier that says – 2 VMs with 1VCPU and 1GB RAM free always. The free tier comes with 400 SGD.

With Azure, GCP and AWS, I had only a single VM. With OCI, I deployed the apache web server and mysql database separately on 2 VMs with Ubuntu 24.04. Thanks to OCI’s pricing model and free tier, I could deploy VMs within India. I am OK with the performance for now. If needed, I will switch to a lighter OS and switch to nginx.

Overall, the migration steps were almost same (see GCP to AWS migration). Created a tar file from /var/www/html and used mysqldump to export the data to .sql file. Once the VMs are ready, untar the .tar.gz file and import the .sql file to database.

With OCI, though I had the VCN and security lists with ingress rules for 80/443, I still had to enable the firewall rules at the Linux system level. Only after executing the below iptables command, I was able to provision the SSL certificates via certbot for my domain.

sudo iptables -I INPUT 6 -m state –state NEW -p tcp –dport 80 -j ACCEPT

sudo iptables -I INPUT 7 -m state –state NEW -p tcp –dport 443 -j ACCEPT

curl command helped to troubleshoot and isolate the port issue. “curl http://localhost:80” was working and “curl http://<PUBLIC_IP>:80 failed with “Could not connect to server” error.

Since the database mysql-server was on a different VM, I had to make changes to that VM as well. Enabled port 3306 (default mysql port) for ingress and also update the binding address in /etc/mysql/mysql.conf.d/mysqld.cnf file to 0.0.0.0 instead of localhost.

bind-address = 0.0.0.0
mysqlx-bind-address = 0.0.0.0

The privileges of wp_user was also bound to localhost in the past. I modified the SQL commands also to use ‘%’ instead of ‘localhost’ in the SQL queries.

ALTER USER ‘your_user’@’%’ IDENTIFIED BY ‘user_password’;
GRANT ALL PRIVILEGES ON . TO ‘your_user’@’%’;

FLUSH PRIVILEGES;

Do not forget to restart mysql and apache after any of the above config changes before testing.

sudo systemctl restart mysql

sudo systemctl restart apache2

I initially struggled to assign a reserved IP to an already created VM. Later, I ended up creating a new VM and was able to assign a previously created reserved ip address to it. https://docs.oracle.com/en-us/iaas/Content/Network/Tasks/reserved-public-ip-assign.htm

If you are new to OCI, apart from the free tier, there are also free learning materials for Oracle Cloud Infrastructure 2024 Foundations Associate 1Z0-1085-24 certification exam @ https://mylearn.oracle.com/ou/learning-path/become-an-oci-foundations-associate-2024/139374. This exam is retiring soon – Feb 13, 2025. Until then, the exam is free and covers foundational topics.

Scroll to Top