Score:0

How to open Wordpress by server IP addres instead domain?

ai flag

I'm trying to install Wordpress via Nginx. I want to open Wordpress by accessing public IP address.

I extracted Wordpress to ~/wordpress

ls ~/wordpress/
index.php    readme.html      wp-admin            wp-comments-post.php  wp-content   wp-includes        wp-load.php   wp-mail.php      wp-signup.php     xmlrpc.php
license.txt  wp-activate.php  wp-blog-header.php  wp-config-sample.php  wp-cron.php  wp-links-opml.php  wp-login.php  wp-settings.php  wp-trackback.php

How should I change my Nginx conf?

server {
    listen 80;
    root /var/www/html/wordpress;
    index  index.php index.html index.htm;
    server_name ?;

    client_max_body_size 500M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
    }
}
jp flag
It is not clear what is the full path to your `~/wordpress`.
Алексей Пашнин avatar
ai flag
@AlexD /root/wordpress/
jp flag
Your `nginx` `root` directive points to `/var/www/html/wordpress`.
Paul avatar
cn flag
In most Linux distributions, `nginx` cannot access `/root`.
Алексей Пашнин avatar
ai flag
@Paul so the most correct way is reinstall all server configuration via non root user?
Paul avatar
cn flag
Just put the WordPress directory somewhere `nginx` can access, such as the already configured `/var/www/html`.
Score:0
ws flag

In nginx, server_name: _

Note that the admin pages require HTTPS by default which you can't do without a name (you can use any certificate as long as you don't mind clicking through the errors).

Although the core Wordpress should work (but you can't have it accessible both by address and name) a lot of plugins might not behave correctly.

Score:0
us flag

Try using the "listen" directive like this:

listen 80 default_server;

It will make this virtual host the default server for handling the requests when their HTTP Host header remains unmatched with any other server blocks. Therefore, it should handle any access made directly through public IP addresses.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.