Setting Up Ratals on Nginx (Complete Configuration Guide)

Rob Cuppett Author: Rob Cuppett

If you're installing Ratals on an Nginx server, there's one important step you cannot skip: configuring your Nginx server correctly.

Unlike Apache, Nginx does not use .htaccess files, which means rewrite rules and routing must be defined manually in your server configuration.

This guide walks you through:

  1. Generate Your Nginx Configuration
  2. Apply the Configuration via SSH
  3. Test Your Nginx Configuration Before Restarting
  4. Restart Services
  5. Final Notes
  6. You're Done
  7. Troubleshooting: Admin Not Loading After Installation

Step 1: Generate Your Nginx Configuration

Enter your server information below. Ratals will automatically insert these values everywhere they are required in the Nginx configuration.

Before replacing your current Nginx configuration, create a backup in case you need to revert.

Nginx Configuration Generator

Enter each value once. The completed Nginx configuration and SSH commands below will update automatically. If you're unsure what values to use, check your current server configuration, where most of these values can be found.

Enter the path only. Do not include the domain, leading or trailing slashes. When installing Ratals, make sure you use the same Admin Login Path during installation. Common or easy-to-guess paths such as admin, admin-login, or dashboard are not allowed. Use a unique path that would be difficult for an attacker to guess.
The document root configured for this domain in Nginx. Do not include the Ratals Installation Path here.
Leave blank if Ratals is installed at the domain root. If Ratals is installed in a subdirectory, enter the path only without leading or trailing slashes. Example: ratals.
Enter the domain names this Nginx configuration should respond to, separated by spaces. Example: example.com www.example.com. Do not enter server_name or a semicolon.
Common Ubuntu/Debian default shown. Change if your server uses a different FastCGI include. Enter the include path only, not the include directive or semicolon.
Update the PHP version and socket path to match your server. Enter the socket value only, not the fastcgi_pass directive or semicolon.
Used in the restart command below. Example: php8.3-fpm.
Change this if your domain uses a different Nginx configuration file path.
Select Yes if this domain already has HTTPS/SSL configured in Nginx. The generated Ratals configuration is HTTP-only and should not replace or remove your existing SSL certificate, port 443, or other HTTPS/SSL settings.

Generated Nginx Configuration

Review the generated configuration below, then copy it into your Nginx site configuration file.

HTTP Configuration: This domain does not currently have HTTPS/SSL configured. The generated Ratals configuration can be used as the site's HTTP Nginx configuration. After confirming the site is working correctly, you can configure HTTPS/SSL using your preferred certificate provider.

Step 2: Apply the Configuration via SSH

Once the configuration above is ready, connect to your server via SSH and follow these steps.

1. Open your Nginx configuration file

The command below automatically uses the Nginx configuration file path entered in the generator.

Tip: If you're unsure which file is being used, check your Nginx configuration or look inside the sites-enabled directory to see which configuration is active.

2. Paste your generated configuration

  • Important: The generated configuration uses HTTP on port 80. If this is a new HTTP configuration, you can use the generated configuration as your site's Nginx configuration and configure HTTPS/SSL afterward using your preferred certificate provider.
  • If your site already has HTTPS/SSL configured, do not replace or remove your existing SSL settings. Preserve your existing HTTPS/SSL configuration and merge the Ratals routing and security rules into your existing Nginx server configuration.
  • Make sure the values shown in the generator match your server before saving.

3. Save and exit

CTRL + O - Save (Write Out)
Press Enter - Confirm the save
CTRL + X - Exit nano

Step 3: Test Your Nginx Configuration Before Restarting

Before restarting anything, always test your Nginx configuration:

sudo nginx -t

If everything is correct, Nginx will report that the configuration test was successful.

Do not restart Nginx if the configuration test reports an error. Fix the reported error and run sudo nginx -t again first.

Step 4: Restart Services

After the Nginx configuration test succeeds, apply your changes by restarting PHP-FPM and Nginx.

The PHP-FPM restart command above automatically uses the service name entered in the generator.

If you're unsure which PHP version you're running, you can check with:

php -v

Final Notes

  • If something doesn't load correctly, verify:
    • The Admin URL Path must match the path you enter during the Ratals installation. If Ratals is already installed and you want to change the Admin URL Path, go to Admin > Website > Site Settings > URL Settings. If you cannot access the admin area and need to change it manually, the value is stored in the sites database table under the admin_directory column.
    • The PHP-FPM socket path matches your server.
    • The FastCGI include path is correct.
    • The website document root points to the directory containing your Ratals files.
    • The server name is correct for your domain/server configuration.
  • Nginx is strict. Even a small typo can prevent the configuration from loading, so always run:
    sudo nginx -t
    before restarting Nginx.
  • The real /admin/ directory is intentionally blocked from direct access. Always use your custom admin URL path.

You're Done

Once everything is configured and restarted:

  1. Go back to your Ratals install page.
  2. Refresh the page. The Nginx message will still appear, which is expected.
  3. Continue the installation.
  4. Important: Enter the exact same Admin URL Path in the Ratals installer that you entered in the generator above.

If these values do not match exactly, your admin area will not work correctly.

Troubleshooting: Admin Not Loading After Installation

This section only applies if you have already completed the installation and later changed your Nginx configuration.

If you update the Admin URL Path in your Nginx configuration before updating it inside the Ratals admin settings, the admin area will no longer load. This is expected behavior because the routing will no longer match.

This is not a system error - it simply means the Nginx configuration and database are no longer using the same admin path.

If this happens, you can restore access by updating the value directly in your database:

  • Database: your_database_name
  • Table: sites
  • Field: admin_directory

Important: If you have multiple sites in your database, make sure you update the admin_directory value for all sites/rows in the sites table.

Once these values match your Nginx configuration, your admin area will load normally.

Rob Cuppett
About the Author
Rob Cuppett is the founder and lead engineer behind Ratals, bringing over 25 years of experience in digital marketing, software development, and business automation. He shares expert tutorials, practical guides, and insights to help business owners optimize, customize, and fully leverage software solutions to grow their businesses efficiently.
0 Comments
Post a New Comment
This site uses cookies to deliver its services and to analyze traffic. Learn more on our Cookie Policy and Privacy Policy.