Creating Website

Setting Up Your Oracle Cloud Environment

Login to Oracle Cloud:

  • Access your instance and select the subnet under the Primary VNIC
  • Choose the default security list

 

Add Ingress Rules:

  • Allow HTTP Connections
    • Source CIDR: 0.0.0.0/0
    • Protocol: TCP
    • Destination Port Range: 80
  • Allow HTTPS Connections
    • Source CIDR: 0.0.0.0/0
    • Protocol: TCP
    • Destination Port Range: 443

Domain Registration

Register Domain with Cloudflare (Optional):

  • Optionally, import your existing domain to Cloudflare

 

Set Up DNS Records:

  • A Record:
    • Name: @ (for root)
    • Value: example.com
    • Proxy Status: Enabled
  • A Record:
    • Name: www
    • Value: example.com
    • Proxy Status: Enabled

Accessing Your Web Server & Updating Your System [Ubuntu]

  • SSH into your web server
  • Use your private key to connect securely
  • Update system packages
sudo apt update && apt upgrade -y

Set Hostname (Optional)

  • Change the hostname to whatever you prefer
  • Restart recommended
sudo nano /etc/hostname
sudo reboot

Installing the LEMP Stack

  • Install Nginx, MariaDB, and PHP
sudo apt install nginx mariadb-server php-mysql php-curl php-gd php-zip php-fpm

Configuring Firewall Rules

  • Setup firewall rules to allow port 80 and 443 for HTTP/HTTPS
  • Save the changes
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 443 -j ACCEPT
sudo netfilter-persistent save

Accessing Your Website

  • You can now access your website via the public IP of your webserver
  • It should be the basic Nginx page

Setting Up MariaDB / MySQL

  • Navigate to web directory
cd /var/www/html
  • Start MySQL setup
sudo mysql
  • Create a WordPress user and grant privileges
CREATE USER 'input-user-here'@'localhost' IDENTIFIED BY 'input-password-here';
GRANT ALL PRIVILEGES ON *.* TO 'input-user-here'@'localhost';
  • Create a WordPress database
CREATE DATABASE input-database-name-here;
  • Flush privileges and EXIT
FLUSH PRIVILEGES;
EXIT;

Setting Up WordPress

  • Ensure you are in “/var/www/html” directory
  • Download and setup
sudo wget https://wordpress.org/latest.tar.gz
  • Remove default Nginx html
sudo rm index.nginx-debian.html
  • Extract WordPress
sudo tar xvfz latest.tar.gz
  • Move WordPress to web directory
sudo mv wordpress/* .
  • Remove WordPress tar
sudo rm latest.tar.gz
  • Remove WordPress folder
sudo rm -rf wordpress/

Configuring Nginx for WordPress

  • Edit Nginx Configuration
sudo nano /etc/nginx/sites-available/default

Modify the configuration to include:

  • server_name example.com www.example.com;
server_name example.com www.example.com;
  • index index.php;
index index.php;
  • Uncomment “~ \.php$ {“
~ \.php$ {
  • Uncomment “fastcgi_pass unix:/run/php/php8.3-fpm.sock;”
  • Ensure php version matches
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
  • Check php location / version
  • If nothing is found, update php location / version in above configuration
ls /run/php/php8.3-fpm.sock
  • Test Nginx configuration
  • Should receive succesful response
sudo nginx -t
  • Restart Nginx
sudo systemctl restart nginx
  • Set permissions for www-data user / group to own location “/var/www/html”
sudo chown -R www-data:www-data /var/www/html

Completing WordPress Installation

  • Navigate to your website via public IP or domain name to begin the WordPress installation:
    • Database Name: [insert database]
    • Username: [insert username]
    • Password: [insert password]
  • Follow the on-screen instructions to complete the installation.

Setting Up SSL with Certbot

  • Install snap package manager
  • Install snap core
  • Install Certbot via snap (recommended)
sudo apt install snapd
sudo snap install core
sudo snap refresh core
sudo snap install --classic certbot
  • Create a symbolic link (a shortcut) to the Certbot executable
  • Obtain an SSL certificate for your domain
sudo certbot --nginx -d example.com -d www.example.com
  • Check renewal service
sudo systemctl status snap.certbot.renew.service
  • Dry run renewal test
sudo certbot renew --dry-run

Troubleshooting SSL Issues

If your website is not accessible after setting up SSL:

  • Access your DNS settings on Cloudflare
  • Select your domain, navigate to SSL/TLS Settings > Overview, and configure SSL/TLS encryption to Full

Setting Up Firewall with Firewalld (Optional)

  • Install and enable Firewalld
sudo apt install firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo systemctl status firewalld
  • Set up firewall rules to allow for HTTP / HTTPs connections
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanent
  • Reload Firewalld and check that services has updated to include HTTP / HTTPS
sudo firewall-cmd --reload
sudo firewall-cmd --list-services

Final Thoughts

This guide provides a comprehensive approach to setting up a LEMP stack and configuring it for WordPress. Follow each section carefully, and don’t hesitate to adapt configurations as needed for your environment. Happy building!

Scroll to Top