Create a temporary staging domain for a wordpress installation

This is my first time posting and I am new to YunoHost. Thank you in advance for any time helping me!

I am creating a new version of a live wordpress website that I will be hosting on my YunoHost server. Let’s call it example.com.

I created a site on YunoHost and installed wordpress (wordpress__10) that points to my domain.

On my local computer, I changed by local hosts file and can access, build, edit the website as desired.

I am trying to create a staging site so that I can have non local people look at it but can’t figure out how.

I can’t point the DNS for the actual domain to my YunoHost installation yet because it is a live site and it needs to get approval first.

What I have tried:

I created a new domain (staging.example.com), installed redirect on it, and copied the nginx conf file from example.com into staging.example.com that looks like this:

location / {

       # Path to source
       alias /var/www/wordpress__10/;

       index index.php;
       if (!-e $request_filename)
       {
              rewrite ^(.+)$ /index.php?q=$1 last;
       }

       client_max_body_size 50m;
       location ~ [^/]\.php(/|$) {
           fastcgi_split_path_info ^(.+?\.php)(/.*)$;
           fastcgi_pass unix:/var/run/php/php8.2-fpm-wordpress__10.sock;

           fastcgi_index index.php;
           include fastcgi_params;
           fastcgi_param REMOTE_USER $remote_user;
           fastcgi_param PATH_INFO $fastcgi_path_info;
           fastcgi_param SCRIPT_FILENAME $request_filename;
       }

  # Include SSOWAT user panel.
  include conf.d/yunohost_panel.conf.inc;
}

When I go to it, it redirects me to the live version of example.com instead of the yunohost version.

I would like to set it up so that I can have the website available publicly through some sort of a redirect that I can remove when I am ready to go live with the new site and switch the actual dns record from the current site to the new site.

Thank you again for any help you are able to provide.

Hi ben1,

Welcome to the forums!

As it is your first post, start by making a good impression by reading the helpful template that is provided when you start writing your post:

image

The template asks for some basic information that not only helps current forum members to answer your question without first asking ‘the obvious’ questions first, but it also helps future readers to gauge whether the solution we hopefully come to is helpful in their situation.


Having said that

With ‘non local people’, do you mean people not in your network?

How many computers/servers/hosting providers are involved at the moment? Is everything on one Yunohost, or is the live site at a hosting provider and do you intend to switch? Is your server that hosts Yunohost at home / ‘on premise’ at an office / a VPS or dedi in a datacenter?

Your description reads as if the current site is running at a hosting provider as it seems DNS and hosting are integrated. Or is the live server already running on Yunohost?

Easiest would not to create any redirects, but just have your subdomain pointing to the IP(s) of your Yunohost.

Before I throw more questions at you, could you clearly describe your current situation? :stuck_out_tongue:

Oh, and PS: do you have prior experience with webservers and hosting, or is Yunohost your first introduction?

Thank you for your response. I apologize about the template. I was trying to figure out which category to post my question in and in this category, the template changed. I looked at other posts to try and understand best practices and must have gotten it wrong.

My YunoHost server

Hardware: VM hosted on Google Compute
YunoHost version: 11.2.9.1
I have access to my server : Yes
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : No
app name and version: wordpress 6.4.2~ynh2

By non-local, I meant that the only way that I can access is the site is because I changed my local hosts file on my personal pc. To access it.

Everything is on one YunoHost server. I do not have much background in webservers / hosting. YunoHost is not technically my first interaction but, with a limited amount of rounding, it can be considered as such :slight_smile:

I’ll try to explain my situation better:

There is a livesite (example.com) that I am remaking and hosting on YNH. The new version of the site is made and hosted on YNH/Wordpress.

I cannot point the DNS to the new site until it has gotten approval.

Right now, I only have access to the new site by changing the local hosts file on my personal PC to point to YNH’s version of example.com rather than the live version.

I have created a DNS record for staging.example.com and would like to point it to the YNH server to show the YNH version of example.com publicly. I am not sure the best way to do this.

My question is, what is the best way to point the staging domain to the wordpress site?

Thank you again for your help. This seems like a great community and I am grateful to be a part of it.

Hi ben1,

Sorry for not replying any sooner. Don’t fret about the template, thanks for adding the information!

So, is the livesite also on Yunohost? Your way of writing seems to imply it will be after successfully remaking the site. Then again, I think it does not really matter.

Its helpfus to know that :slight_smile: Yunohost actually provides just what you ask for in the title of your thread. If you go to the Wordpress settings, you can easily move the site from one domain to another:

image

First go to domains, to add a ‘staging’ subdomain to Yunohost. Also add the subdomain in the DNS at your domain registrar (or wherever DNS for your domain is configured).

In my screenshot, the current subdomain where Wordpress is found, is ‘online’. I could easily add a new domain, ‘staging.osba.nl’, and instll an alternative Wordpress installation there. When I’m done preparing the new site, I could switch the current site to ‘old.osba.nl’, and switch the new site from ‘staging.osba.nl’ to ‘online.osba.nl’.

Does that help you in a workable direction?

How?

In the webadmin > applications > <your_new_wordpress>, what is the domain and path?

Is the subdomain listed in webadmin > domains?

Redirect to where?

YunoHost is made so you don’t need to do this. Everything can be done with the webadmin.

1 Like

I am not sure if this is intended as a different question or to clarify my question from before. wbk answered mine and I am in good shape.

In case you are wondering how to edit your local hosts file, this is on your local machine and makes it so that a domain resolves to an ip address of your choosing instead of going to an online nameserver to resolve it.

Where it is depends on what operating system you are on. I am on windows and it is located at: C:\Windows\System32\drivers\etc.

To modify it, open notepad as an administrator, and add a line to the bottom like this:

0.0.0.0 example.com

Where 0.0.0.0 is the ip address to your YunoHost server (or wherever you want the domain to go to) and example.com is the domain that you want pointing there.

You can find instructions online for windows, linux, or whatever you are running.

Hopefully that helps.

1 Like

Hi ben1,

Nice to read that!

If you have time to post a short summary, you could tick that as the solution to your problem to help the next person with a similar situation up to speed!