Simple steps to create a static website

To create a static website, just need to

1) create index.html in /var/www/websitename/pubic (can keep the permission to root).

2) add virtual host config to the available site in /etc/apache2/sites-available/

3) restart apache

sudo a2ensite your-site.conf

sudo systemctl reload apache2

Migrate a WordPress Website from AWS to OCI

Below is the notes I had to move my WordPress website from AWS (Amazon Web Services) to OCI (Oracle Cloud Infrastructure).


1. Export WordPress from AWS

On the AWS WordPress site:

  1. Install and activate the All-in-One WP Migration plugin.
  2. Use it to export your website and download the .wpress backup file to your computer.

2. Set Up WordPress on OCI

On your OCI server:

sudo mkdir -p /var/www/exampleblog.com/public

Copy your unzipped WordPress files into /var/www/exampleblog.com/public.


3. Create a New Database

Log into MySQL:

sudo mysql -u root -p

Run these commands to create the database and user:

CREATE DATABASE wp_example DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser_example'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wp_example.* TO 'wpuser_example'@'localhost';
FLUSH PRIVILEGES;
EXIT;

4. Configure Apache Virtual Host

Create a new site configuration file:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/exampleblog.com.conf

Edit the new config to point to /var/www/exampleblog.com/public.

Enable the site:

sudo a2ensite exampleblog.com.conf
sudo systemctl reload apache2

5. Fix Permissions

Give Apache ownership of your WordPress files:

sudo chown -R www-data:www-data /var/www/exampleblog.com

6. Update wp-config.php

Copy the sample config file:

cp wp-config-sample.php wp-config.php

Edit wp-config.php with your database details:

define('DB_NAME', 'wp_example');
define('DB_USER', 'wpuser_example');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');

You can customize $table_prefix if you’d like.


7. Update DNS

Log into your domain registrar (e.g., GoDaddy, Namecheap, etc.) and point your domain (exampleblog.com) to the OCI server’s IP address.


8. Complete WordPress Setup

Visit your domain in a browser.
Run the initial WordPress installation wizard and create your new admin user.


9. Import Your Backup

On the new WordPress site:

  1. Install and activate the All-in-One WP Migration plugin.
  2. Import the .wpress file you exported earlier.
  3. This restores all your posts, pages, comments, and settings.

10. Enable HTTPS with Let’s Encrypt

Install an SSL certificate using Certbot:

sudo certbot --apache -d exampleblog.com -d www.exampleblog.com

11. Adjust Apache Config (Optional: Keep HTTP)

If you want to keep HTTP (not just force HTTPS), edit:

/etc/apache2/sites-available/exampleblog.com.conf

Comment out the auto-redirect lines:

# RewriteCond %{SERVER_NAME} =www.exampleblog.com [OR]
# RewriteCond %{SERVER_NAME} =exampleblog.com
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Test and reload Apache:

sudo apache2ctl configtest
sudo systemctl reload apache2

12. Update WordPress URLs

In your WordPress dashboard:

  • Go to Settings → General.
  • Update WordPress Address (URL) and Site Address (URL) from http:// to https://.

argparse const vs default

default is used when option is not provided. const is used when option is provide, but no value is given.

For example, if we have an arg ‘–bookname’ for test.py, then test.py will use default name, test.py –bookname will use const name.