You can set up WordPress using your server’s public IP address now and bind your actual domain name later when you are ready.
Here is the complete step-by-step guide to installing WordPress on Nginx + PHP-FPM using your IP address.
Step 1: Install Nginx & PHP-FPM
Run the following commands in your VS Code terminal to install Nginx and the necessary PHP extensions:
Bash
sudo apt update
sudo apt install php-fpm php-mysql php-cli php-curl php-gd php-mbstring php-xml php-zip -y
php -m | grep -E 'mysqli|curl|gd|mbstring|xml|zip'
This will install and verify all packages required
Check your PHP version to confirm the socket file name:
Bash
ls /run/php/
(You will see a socket file like php8.1-fpm.sock or php8.3-fpm.sock—keep note of the version number).
Step 2: Create the WordPress Database
Since MySQL is already installed on your server, log into MySQL:
Bash
sudo mysql -u root -p
Execute these commands to create a dedicated database and user:
SQL
CREATE DATABASE wordpress_db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'YourStrongWPPassword123!';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 3: Download & Extract WordPress
Download the latest release into /var/www/wordpress:
Bash
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
sudo mv wordpress /var/www/wordpress
# Set permissions so Nginx/PHP can write media uploads & plugins
sudo chown -R www-data:www-data /var/www/wordpress
sudo chmod -R 755 /var/www/wordpress
Step 4: Configure Nginx to Use Your Server IP
- Remove the default Nginx placeholder site:Bash
sudo rm /etc/nginx/sites-enabled/default - Create a new Nginx configuration file:Bash
sudo nano /etc/nginx/sites-available/wordpress - Paste the following configuration (replace
YOUR_SERVER_IPwith your actual VPS IP address and adjust the PHP version socket if necessary):
Nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name YOUR_SERVER_IP; # e.g., 192.0.2.1
root /var/www/wordpress;
index index.php index.html index.htm;
# Enable WordPress Permalinks
location / {
try_files $uri $uri/ /index.php?$args;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock; # Adjust version if needed (e.g. php8.3-fpm.sock)
}
# Deny access to hidden files (.htaccess, .git, etc.)
location ~ /\.ht {
deny all;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
}
- Enable the file and test for syntax errors:Bash
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx
Step 5: Complete WordPress Installation in Your Browser
- Open your browser and navigate to:Plaintext
http://YOUR_SERVER_IP - You will see the WordPress Setup Wizard. Click Let’s go!
- Enter your database details:
- Database Name:
wordpress_db - Username:
wp_user - Password:
YourStrongWPPassword123! - Database Host:
localhost - Table Prefix:
wp_
- Database Name:
- Complete the site admin setup!
How to Switch to a Domain Later
When you acquire your domain and point your A Record to your server IP, updating WordPress takes less than 2 minutes:
- Update Nginx: Open
/etc/nginx/sites-available/wordpress, replaceYOUR_SERVER_IPinserver_namewithyourdomain.com [www.yourdomain.com](https://www.yourdomain.com), and reload Nginx (sudo systemctl reload nginx). - Update WordPress URLs: Go to WordPress Admin > Settings > General, and change both WordPress Address (URL) and Site Address (URL) from
http://YOUR_SERVER_IPto[http://yourdomain.com](http://yourdomain.com). - Add Free SSL: Generate an HTTPS certificate via Certbot:Bash
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com