Nginx Wordpress configuration issue on Ubuntu guest and Virtualbox

0

I have updated the question based on the suggestion from @Gerard H. Pille below.

First time setting this up. I have Virtualbox running Ubuntu 18.04 on a Win 10 host for a wordpress project.

My shared folder is mounted in /media/sw_wp and working

My projects folder contains one project only, at /media/wp_sf/myproj

I am using this nginx config from here:

# Upstream to abstract backend connection(s) for php
upstream php {
        server unix:/tmp/php-cgi.socket;
        server 127.0.0.1:9000;
}

server {
        ## Your website name goes here.
        server_name myproj.com.au;

        ## Your only path reference.
        root /var/www/html/myproj;

        ## This should be in your http block and if it is, it's not needed here.
        index index.php;

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

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

        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
        }

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

I have created the symbolic link from sites-available to sites-enabled and I can see the link using ls.

/var/www/html/myproj contains my wordpress installation.

I have created a symlink from the share folder so that it now appears as:

/var/www/html/myproj

Everything else in the guest is ubuntu + php 7.2 + nginx + mysql

When I browse the project I get:

This site can’t be reached
myproj.com.au refused to connect.

On suggestion below the result of nslookup myproj.com.au is

Server 127.0.0.53
Server Address 127.0.0.53#53

Non-authoritative answer:
Name: myproj.com.au
Address: 52.64....  // An IP I do not recognise

I can ping the guest from a DOS window in the Host and I get a response., so the environment is set up correctly.

ping myproj.com.au

What have I missed? Thanks.

TheRealPapa

Posted 2018-05-28T11:22:54.487

Reputation: 133

How does myproj.com.au resolve? Try "nslookup myproj.com.au". What is the use of "/media/sw_wp"? It isn't mentioned in nginx's config. "/media/wp_sf/myproj" vs. "root /media/sf_wp/myproj" ??? – Gerard H. Pille – 2018-05-28T11:38:02.020

The /media/.wp_sf is where Virtualbox mounts the host shared folder. Ubuntu does not allow me to symlink /var/www to /media/sf_wp folder. Is there a different way to set this up? – TheRealPapa – 2018-05-28T11:56:07.460

Does the folder name change each time you type it? Now it's "/media/.wp_sf" ? – Gerard H. Pille – 2018-05-28T12:00:18.653

Hi sorry, longest day! no, the folder name should always be /media/sf_wp. But see my update on your suggestions above. Thanks for helping. – TheRealPapa – 2018-05-28T12:16:13.897

What IP address does "ping myproj.com.au" give? Different from nslookup? – Gerard H. Pille – 2018-05-28T12:22:46.070

BTW did you run the nslookup & ping on the windows host or the linux client? – Gerard H. Pille – 2018-05-28T12:30:06.950

I ran it on ubuntu guest – TheRealPapa – 2018-05-28T12:30:32.990

The ip on the host side is the correct '192.168.0.5', which matches the ip of the bridged adapter in virtualbox and what the ubuntu guest can see ifconfig. So the ip looks ok. Additionally, the host myproj.com.au is resolving on my host to the same ip. – TheRealPapa – 2018-05-28T12:32:43.047

next test (from the host!) : "telnet 192.168.0.5 80" to see if you can contact nginx inside the guest. I think you'll have to replace bridged by nat with port forwarding. – Gerard H. Pille – 2018-05-28T12:52:01.480

hey! It refuses to connect to SSH from my git window though I can see ssh server running on the guest. But connection refused is also what I get on the browser. I can ping the address, the fw is off (and I just reinstalled clean 18.04 to start again). – TheRealPapa – 2018-05-28T14:21:20.717

You reinstalled. Yeah, was probably a lot easier than following my advice. – Gerard H. Pille – 2018-05-28T14:41:14.773

Hi Gerard, your advice showed me another problem around permissions, as my /var/www/html (shared from win 10 host, symlinked) folder is permission denied. So I though I would reinstall but I ended up with this problem now. https://superuser.com/questions/1327055/virtualbox-ubuntu-18-04-permission-issue-to-symlinked-share-host-folder

– TheRealPapa – 2018-05-30T04:41:31.230

No answers