Installing WordPress on an Ubuntu Server using Nginx, PHP, and MariaDB on Oracle Cloud Infrastructure Free Tier.
Prerequisites
-
- Oracle Cloud Infrastructure Free Tier account
- Ubuntu Server instance
- SSH access to the server
Step 1: Update System Packages
sudo apt update
sudo apt upgrade -y
Step 2: Install Nginx Web Server
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
Step 3: Install MariaDB Database
sudo apt install mariadb-server -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
During the secure installation:
- Set root password
- Remove anonymous users
- Disallow root login remotely
- Remove test database
- Reload privilege tables
Step 4: Install PHP 8.1 and Required Extensions
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.1-fpm php8.1-mysql php8.1-curl php8.1-gd php8.1-mbstring
php8.1-xml php8.1-zip -y
Step 5: Configure Database for WordPress
sudo mariadb
CREATE DATABASE wordpress;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 6: Download and Install WordPress
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvf latest.tar.gz
sudo mkdir -p /var/www/wordpress
sudo cp -R wordpress/* /var/www/wordpress/
sudo chown -R www-data:www-data /var/www/wordpress
sudo chmod -R 755 /var/www/wordpress
Step 7: Configure Nginx for WordPress
sudo nano /etc/nginx/sites-available/wordpress
Add the following configuration:
server {
listen 80;
server_name your_domain.com;
root /var/www/wordpress;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php${
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Step 8: Enable Site and Restart Services
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
sudo systemctl restart php8.4-fpm
Step 9: Configure WordPress
- Navigate to
http://your_domain.com
- Follow WordPress setup wizard
- Create
wp-config.php
with database details
Security Considerations
- Configure firewall rules in Oracle Cloud Console
- Open ports 80 and 443
- Consider installing SSL with Let’s Encrypt
Troubleshooting
- Check Nginx logs:
sudo tail /var/log/nginx/error.log
- Check PHP-FPM logs:
sudo tail /var/log/php8.4-fpm.log
- Verify services:
sudo systemctl status nginx php8.4-fpm mariadb