Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Så här skapar du enkelt en Staging Site för WordPress (steg för steg)

När det gäller att göra uppdateringar eller betydande ändringar på din WordPress-webbplats kan det vara riskabelt att göra det direkt. Det är här en staging-webbplats kommer in i bilden.

Det är en perfekt klon av din live-webbplats där du på ett säkert sätt kan testa ändringar, felsöka problem och förfina uppdateringar innan du distribuerar dem till din huvudwebbplats. Att skapa en staging-webbplats kan rädda dig från potentiella driftstopp, trasiga funktioner och andra komplikationer.

På WPBeginner använder vi staging-webbplatser för att testa webbplatsuppdateringar innan vi publicerar dem på våra live-webbplatser.

I den här Step-by-Step guiden visar vi hur du enkelt skapar en staging-miljö för din WordPress webbplats. Vi kommer att täcka flera olika metoder och de flesta av dem kräver bara några click.

How to create a staging site for WordPress

Vad är en Staging Site?

En staging site är en klon av din live website som används för att testa ändringar innan de görs live. Staging sites hjälper dig att hitta error, så att du inte förstör din live website.

Förr i tiden var det mycket svårt att skapa en WordPress staging site, men nu har det ändrats så att även en icke-teknisk person kan göra det.

Många användare installerar WordPress lokalt på sina Windows- eller Mac-datorer för att testa ändringar. När de är klara med updatingen laddar de helt enkelt upp ändringarna från localhost till live-servern.

Det största problemet med detta tillvägagångssätt är vad som händer om något som fungerade på your localhost inte fungerar på live-servern?

Ofta körs de lokala webbplatserna och live WordPress webbhotell servrar inte i samma miljö.

Eftersom staging-webbplatsen lever på din webbhotell server, kan du enkelt förhindra alla dessa error eftersom den kör samma serverkonfiguration som din live site.

Med det sagt, låt oss ta en titt på hur du ställer in en staging site för WordPress.

Så här skapar du enkelt en WordPress Staging Site

Det finns flera sätt att skapa en staging site för WordPress. Det enklaste är att använda din hosting providers utvalda funktion för staging site.

Några av de bästa webbhotellen för WordPress erbjuder redan 1-click staging websites. Om din website är hosted hos ett av dem kan du enkelt skapa en staging site utan krångel.

Om du inte har någon av dessa populära hostinglösningar har vi också en lösning som hjälper dig att skapa en WordPress staging site med hjälp av ett plugin (och även manuellt).

För snabbare browsing kan du använda navigationen under för att hoppa till den section som är mest tillämplig för you:

Skapa en Staging Site på Bluehost

Bluehost är ett av de bästa företagen för webbhotell för WordPress. De erbjuder en snabb 1-click staging site-lösning med alla sina planer.

Först måste du gå över till din Bluehost-instrumentpanel och besöka avsnittet ”My Sites”.

Därefter växlar du till tabben ”Tillägg” och toggle omkopplaren bredvid alternativet ”Bluehost Plugin”.

Turn on Bluehost plugin

Efter det, head över till din WordPress dashboard och besök Bluehost ” Staging page.

Gå nu vidare och klicka på knappen ”Create Staging Site”.

Click create staging site button

Bluehost kommer nu att förbereda staging-miljön för din website.

När det är gjort kommer det att visa en Staging Site ’section där du måste kontrollera rutan ”Ej för närvarande redigering”.

Click not currently editing button

En prompt kommer nu att öppnas på din vy där du ombeds att byta till staging site.

Här klickar du på knappen ”Switch”.

Click switch button

När du har kopplat om kommer du att se en knapp på vyn som visar att du arbetar på staging website.

You can go ahead and work on your website without worrying about it affecting your live site.

Activate theme on staging site

Distribuera ändringar från Staging till Live Site på Bluehost

När du är redo att flytta ändringar från staging till live site går du helt enkelt till Bluehost ” Staging page från sidebaren i WordPress admin.

Härifrån ser du rullgardinsmenyn med alternativ för driftsättning bredvid din staging website. You can deploy only the files, only the database, or deploy all changes.

Om du ej är säker kan du klicka på knappen ”Deploy All Changes” för att fortsätta.

Choose the Deploy All Changes option from the Staging Site option

Därefter klickar du på knappen ”Deploy Site” bredvid dropdown-menyn.

Detta kommer att visa en popup där du ombeds bekräfta att du vill distribuera staging site till produktionssiten. Klicka på knappen ”Deploy” för att fortsätta.

Click the Deploy button in the prompt

Bluehost kommer nu att börja distribuera din staging site till live site. Beroende på storleken på din website kan detta ta en stund.

You can now switch back to your live website to see your changes in action by clicking on the Radio button under the Production site alternative.

Switch to the Production Site

Kloning av Production Site till Staging

Nu när you byter tillbaka till produktionswebbplatsen synkroniseras inte de ändringar som du gör där automatiskt till din staging website.

Om du i framtiden vill testa fler saker på din staging-webbplats måste du duplicera din website.

För att göra detta måste du besöka Bluehost ” Staging page och klicka på knappen ’Clone to staging’.

Click Clone to staging button

Bluehost kommer sedan att klona de senaste ändringarna på din Live website till din Staging website. Efter det kan du byta till staging website för testning och utvecklare.

Skapa en Staging Site på SiteGround

SiteGround är ett annat högst upp WordPress webbhotell som erbjuder en 1-click staging funktion med deras GrowBig och GoGeek planer.

Om din website är hosted med SiteGround, då är det så här du skulle ställa in en staging-webbplats.

Först måste du logga in på din SiteGround dashboard och växla till fliken Websites. Härifrån måste du välja Site Tools under din website.

SiteGround dashboard

På nästa vy måste du klicka på WordPress ” Staging menyn från den vänstra kolumnen.

From Name väljer du din website och anger sedan ett namn för din staging-kopia.

SiteGround make a staging copy of your website

Klicka på knappen ”Create” för att fortsätta och Siteground kommer att skapa en staging-kopia av din website.

Efter det måste du klicka på knappen ”Go to protected URLs” så att du kan skydda din staging website med password och hålla den privat.

Siteground staging site created

På nästa vy kommer Siteground automatiskt att fylla i URL och sökväg för din staging website.

You have to enter the username and password that you want to use to protect your staging site.

Protect staging website

Click on the ”Protect” button to save your settings.

Du kan nu gå tillbaka till WordPress ” Staging page och klicka på knappen Logga in på adminpanelen” bredvid din staging website.

Login to your staging website

SiteGround kommer nu att öppna WordPress admin area på din staging website. Du kan testa dina ändringar på denna staging website.

Distribuera Changed tillbaka till din Live website

När du har provat dina ändringar på staging-webbplatsen kanske du vill slå samman dem med din live-webbplats.

SiteGround gör det också enkelt.

Klicka bara på menyn WordPress ” St aging i den vänstra columnen. Klicka sedan på menyn med tre punkter bredvid din staging site under sektionen ”Manage Staging Copies”.

Deploy all changes from staging to live website

Menyn visar dig två alternativ för driftsättning. You can either choose the ”Full Deploy” or ”Custom Deploy” alternative.

Alternativet ”Full Deploy” sammanfogar allt från staging-webbplatsen till din live website. ”Customize deploy” allow you to select which files or data you want to merge.

Om du är osäker väljer du alternativet ”Full Deploy”.

SiteGround kommer sedan att kopiera staging site till din live website.

Sammanfoga Live till din Staging website

Changeds som du gör på din live website kopieras inte automatiskt till din staging website.

Varje gång du behöver arbeta med din staging website upprepar du processen ovan för att skapa en ny staging website.

Skapa en Staging Site på WP Engine

WP Engine är det bästa webbhotellet i världen som hanterar WordPress. Hanterad WordPress-hosting är en conciergetjänst för din WordPress site där hosting provider tar hand om updates, backups, säkerhet och prestanda.

WP Engine erbjuder en one-click staging-lösning med alla sina planer. Om du använder WP Engine för att servera din website, då är det så här du skulle ställa in en staging-miljö för din site.

Först måste du logga in på din WP Engine dashboard. Gå sedan till sidan ”Sites” och select your website genom att clicka på den.

WP Engine sites

Detta kommer att ta dig till din website dashboard.

Nu måste du klicka på länken ”Add Staging” i den vänstra colonnen eller välja den under namnet på din site högst upp.

Click to add staging environment in WP Engine

Då kommer du till vyn ”Add Environment”.

You’ll be asked to choose how you wish to proceed with your staging environment.

Copy existing environment to staging site

Här är vad vart och ett av dessa alternativ gör:

  • ”Starta med en ny tom site” skapar en ny tom site.
  • ”Start with a guided experience” skapar en new site med en guidad upplevelse och demo-content.
  • ”Copy an existing environment to this site” kopierar din produktions- eller utvecklingsmiljö till den här webbplatsen (t.ex. kopierar din live-webbplats till den här miljön).
  • ”Flytta en befintlig miljö” flyttar en miljö till den här webbplatsen (t.ex. flytta utvecklingsmiljön till Staging)
  • ”Starta med en WooCommerce-webbplats” skapar en new WordPress site med WooCommerce förinstallerat.

Eftersom du vill skapa en staging-kopia av vår live-webbplats måste du klicka på alternativet ”Kopiera en befintlig miljö till den här webbplatsen”.

Choose environment you wish to copy

När du har valt en miljö väljer du den senaste backupen som du vill kopiera från och klickar sedan på knappen ”Next” för att fortsätta.

Nu måste du ange ett namn för din staging site. Detta namn kommer att användas i URL:en för din staging site. Därefter väljer du STG (staging) som din miljötyp.

Staging site name

Klicka på knappen ”Skapa miljö” för att fortsätta.

WP Engine kommer nu att skapa en staging site åt dig. Efter det kommer du att redirectas till din dashboard för Staging-miljön.

Password protect your staging environment

Därefter måste du klicka på knappen Padlock för att aktivera skydd med password för din staging site.

Efter det måste du byta till tabben ”Utilities” för att kopiera användarnamn och password för din staging site.

staging site password

Du kan nu klicka på knappen ”WP Admin” högst upp för att logga in på din staging website.

Du kan gratis göra ändringar och prova utvalda funktioner på staging-webbplatsen precis som du skulle göra på en vanlig WordPress-webbplats som du installerar någon annanstans.

login to staging website

Distribuera Changed från Staging till Live website på WP Engine

Vill du slå samman ändringar som du har gjort på staging-webbplatsen till din live website?

Klicka bara på knappen ”Kopiera miljö” för att påbörja distributionen.

Copy staging environment

Då kommer du till sidan med valfria alternativ. From here, you need to choose your source and destination environments for the copy.

Här väljer du din staging website som källmiljö och din produktions- eller live website som destinationsmiljö.

Deploy options

Du kan välja vad du vill kopiera. Instance, you can copy all database tables and files, specific files and database tables, or only the file system.

Note: Om du kopierar allt kommer du att förlora alla data som finns lagrade på din live website efter att du har använt den för att skapa en staging-miljö. Detta kan inkludera viktiga data som new posts, pages, customers och orders. Så det är en bra idé att run en backup av din live site innan du distribuerar från staging.

Därefter klickar du på knappen ”Review and Confirm” för att påbörja distributionen. Det kommer att ta ett tag att kopiera allt till din live website.

Du kommer att få ett email notification när processen är completed.

Skapa en Staging Site med hjälp av tillägget WordPress

Om ditt WordPress webbhotell inte tillhandahåller en funktion för staging site kan du fortfarande skapa en staging website med hjälp av ett WordPress plugin.

Det finns vissa nackdelar med att använda denna metod.

För det första kommer ett plugin att ha begränsad control över din server på webbhotellet. Det är därför det kanske inte alltid ger de bästa resultaten.

För det andra kommer det plugin vi kommer att använda att lagra din staging site på sina egna servrar. Om du är orolig för integritet och dataskydd kanske detta inte är idealiskt för dig.

Slutligen har pluginet flera kända inkompatibiliteter. Vänligen kontrollera deras inkompatibilitets page för att se till att din website är kompatibel.

Med detta sagt, låt oss se hur man skapar en staging WordPress site med hjälp av ett WordPress plugin.

Det första du behöver göra är att installera och aktivera WP Stagecoach plugin. För mer detaljer, se vår Step-by-Step guide om hur du installerar ett plugin för WordPress.

Vid aktivering kommer pluginet att lägga till ett nytt menu-item märkt WP Stagecoach till din admin bar. Om du klickar på det kommer du till plugins page för inställningar.

Enter WPStagecoach API keys

Du måste enter ditt WP Stagecoach användarnamn och API key, som du kan hitta i ditt account på plugin-webbplatsen.

Efter det måste du besöka WP Stagecoach ” WP St agecoach page och välja ett namn för din staging site. Detta namn kommer också att användas som subdomain för din WordPress staging website.

Connect WP Stagecoach

Glöm inte att kontrollera boxen bredvid alternativet ”Password protect the staging site”. Det kommer att skydda din staging website från offentlig view och search engines.

Klicka på knappen ”Ride the Stagecoach” för att fortsätta.

WP Stagecoach progress

Pluginet kommer nu att skapa en backup av din WordPress filer och databas för att exportera dem till din staging site.

Det kan ta en stund beroende på storleken på din website i WordPress.

När du har slutfört kommer du att se länken till din staging site och dess admin area.

WP Stagecoach fiinished creating a staging site

You can click the link to visit your staging site and start working on it.

You’ll notice a bright orange message in the admin bar at the top indicating that you are working on your staging site.

WPSC staging preview

Distribuera Staging Site till Live med hjälp av WP Stagecoach

När du är redo att importera ändringar till din live site, head över till WP Stagecoach ” Import Changes page och klicka på knappen check for changes.

Check for changes

Pluginet kommer nu att kontrollera om det finns ändringar på din staging site och sedan visa dig alternativ för att importera dem.

You can choose from all changes, file changes, or database changes.

Changes options

Pluginet visar hur importen fortskrider och meddelar you när den är klar.

You kan nu testa din live site för att se om alla ändringar importerades utan problem.

Skapa en Staging Site för WordPress manuellt

Med den här metoden lär du dig att manuellt skapa en staging site för din install av WordPress. Den är avsedd för avancerade användare och är obligatorisk jämfört med de metoder som beskrivs ovan.

En annan nackdel med den här metoden är att your website kommer att vara tillfälligt otillgänglig när ändringar distribueras tillbaka från staging till live-servern.

Med detta sagt, låt oss se hur du manuellt skapar en staging-miljö för din WordPress site.

Först måste du skapa en subdomain för din staging website. Om du använder Bluehost, gå till dashboarden för ditt webbhotell account och växla till tabben ”Advanced”.

Klicka sedan på knappen ”Hantera” bredvid alternativet ”cPanel”.

Click Manage button next to the cPanel option

Detta kommer att öppna cPanel i en new tab där du måste rulla ner till ”Domain” section.

Härifrån klickar du på alternativet ”Domäner”.

Click the Domain option in the cPanel

Detta öppnar en lista över alla domäner på ditt webbhotell konto. Här måste du klicka på knappen ”Create a New Domain”.

Följaktligen kommer en new page att öppnas på vyn där du måste skriva din subdomain följt av domain name under fältet ’Domain’ gillar detta:

subdomain.example.com

Efter det klickar du bara på knappen ”Submit” för att store dina settings.

Create a sub domain

Note : Vi använder Bluehost i våra exempel screenshots, så din skärm kan se annorlunda ut.

Din webbhotell control panel kommer nu att add to din subdomain, som du kan använda för att importera din live WordPress site.

Därefter måste du installera och aktivera plugin-programmet Duplicator på din live site. Om du behöver fullständiga funktioner kan du få premium-versionen av Duplicator här.

Efter aktivering måste du klicka på Duplicator-menyn i din WordPress admin sidebar och klicka på knappen ”Create New” under Packages.

Create new Duplicator package

Efter det kommer du att bli ombedd att klicka på knappen ”Nästa” för att fortsätta. Duplicator kommer nu att runna website duplicator wizard.

Först kommer den att runna några tester för att se om allt är i order. Om alla objekt är markerade med ”Bra” klickar du på knappen ”Bygg”.

Duplicator build package button

Plugin kommer nu att börja skapa ett Duplicator-paket för din WordPress site. Denna process kan ta några minuter beroende på storleken på din website.

När du är slutförd ser du alternativ för download av Installer- och Archive-paketet. You need to click on the ”Download Both Files” button to download both files on your computer.

Download Duplicator package and installer to your computer

Du måste uploada båda dessa filer till filkatalogen för den subdomain som du just har skapat. För detaljer, se vår guide om hur du använder FTP för att uploada filer till din WordPress website.

Därefter kommer din nya staging site WordPress att behöva en new database. Låt oss skapa en.

Head över till kontrollpanelen på ditt WordPress webbhotell account och växla till ”Advanced” tabs.

Därefter rullar du ner till sektionen ”Databases” och klickar på knappen ”Manage” bredvid den.

Click the Manage button next to the Database option

Om du ej använder Bluehost kan din WordPress webbhotellmiljö se lite annorlunda ut. Oroa dig inte, utan leta bara efter Section Databases.

Detta tar dig till sidan ”MySQL Databases” där du kan börja med att ange ett namn för din database.

Klicka sedan på knappen ”Create Database” (Skapa databas).

Click create database button to create a  Staging site database

Därefter måste du skapa en MySQL-användare för din database.

Rulla ner till MySQL Users section och ange ett användarnamn och password för din nya användare av databasen.

Database username and password

Nu måste du ge den här användaren behörighet att komma åt och ändra databasen som du skapade tidigare.

Rulla bara ner till ”Add user to database” section och select your database och den användare you just skapat.

Add user to database

Därefter klickar du på knappen ”Add” för att fortsätta.

You will be asked to select privileges for the user. Gå vidare och välj checkboxen ”All Privileges” och klicka sedan på knappen ”Make changes”.

Manage user privileges

Nu är din database redo att användas för din staging website.

Därefter måste du öppna en ny webbläsare tabs och enter subdomain av din staging site gillar detta:

https://yoursubdomain.example.com/installer.php

Glöm inte att ersätta yoursubdomain it med den faktiska subdomänen och example.com med ditt eget domain name.

Detta startar Wizard för installation av Duplicator.

Enter database details

Under ”Setup” section kommer installatören att be you att enter your WordPress database information.

Din server kommer troligen att vara localhost. Efter det kommer du att enter details för den database som du skapade för ditt new domain name i det tidigare steget.

Klicka på knappen ”Validate” för att se till att Duplicator kan ansluta till din database.

Duplicator validated

När du är klar klickar du på knappen ”Next” för att fortsätta.

Duplicator kommer nu att packa upp din WordPress database och filer och importera dem till din staging site.

När den är slutförd kommer du att se ett success message.

Duplicator wizard finish

Du kan clicka på knappen ”Admin Login” för att enter WordPress admin area på din website på den new staging site.

Nu har du konfigurerat din staging site. You can protect it by adding password protection to the subdomain.

Head över till ditt webbhotell kontos dashboard och växla till fliken ”Avancerat”.

Därefter rullar du ner till section ”cPanel” och klickar på knappen ”Hantera” bredvid den.

Click the Manage button next to the cPanel option

Detta öppnar cPanel i ett new fönster där du måste rulla ner till sectionen ”Files”.

Klicka sedan på ikonen ”Directory Privacy”.

Click on the Directory Privacy option in the Files section

Därefter måste du välja din subdomain folder och sedan välja alternativet till ”password protect this directory” checkbox.

Du kommer att bli ombedd att ange ett namn för denna inställning och sedan klicka på knappen ”Save”.

Configure directory privacy settings to password protect staging site

Din staging site kommer nu att vara dold bakom ett password, vilket håller den borta från search engines och Offentligs ögon.

You can now work on your staging site and make any changes to it.

Manuellt distribuera Staging Site till Live

När du är redo att distribuera ändringar från din staging site till live-servern följer du samma steg som beskrivs ovan.

Skapa helt enkelt ett new Duplicator-paket på din staging site och download install- och archive-filerna till din dator (se instruktionerna ovan).

Därefter måste du heada över till din live site och skapa en komplett WordPress backup (du kan använda Duplicator för att skapa en komplett backup också).

När du är klar måste du ta bort alla WordPress-filer och -folders från din live website. Detta innebär att din WordPress site kommer att vara nere ett tag.

Följ slutligen instruktionerna ovan för att runna installationsguiden för Duplicator för att importera staging site till live-servern.

Som du kan se är den sista metoden inte alls den bästa metoden. Det finns många saker under processen som kan skada din site.

Vi föreslår att du undviker den här metoden till varje pris om du inte har något annat val. Vi rekommenderar att du använder en tillförlitlig hosting provider som Bluehost, SiteGround eller WP Engine med built-in staging site funktioner.

Vi hoppas att den här artikeln hjälpte dig att lära dig hur du enkelt skapar en staging-miljö för din WordPress-webbplats. Om du runar på några issues, kontrollera vår ultimata guide till att fixa de vanligaste WordPress-felen. Du kanske också vill lära dig hur du använder WordPress Playground i din webbläsare för testning.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

206 kommentarerLämna ett svar

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Lynda Joy

    Hi,

    I just did the first five or so steps of this, and then got lost at ”upload your WordPress content to. So now I have completely messed up my site and I would like to know how to undo what I have done.

    Thanks.
    – Lynda

  3. Rachel

    Thanks so much for this – I am very much a beginner but trying to figure out how to do these things myself so I can launch a new design by first using a test site in order to get it right. I have managed to follow your instructions perfectly until this part:

    ”After copying your database, you need to copy your WordPress files, plugins, themes, and uploads. First download a fresh copy of WordPress from WordPress.org. Upload the contents of WordPress to your staging site. Note, do not run the WordPress install yet”

    Can you please advise as to how this is done or direct me to another instruction article? I can’t seem to find out how to do it otherwise. Many many thanks in advance

  4. Sanket D.

    So I’ve managed to create my staging environment successfully — I’ve all my media, themes, plugins, everything else properly transferred. However, I’d made some changes to my theme (not through any codes, but through the theme’s inbuilt settings — basic stuff like a custom logo (which I can see in my media library), theme color, homepage layout, etc. These changes are the only thing that for some reason are missing from my staging site. Anybody knows why this might be?

    • byberkan

      I’m hoping you can find the solution. Same problem exists for me.

  5. Joe

    It seems we have to do the steps in here after we have our theme, plugin etc.

  6. Mark Park

    Great article! Just one thing that isn’t clear to me.

    If I have the current non-wordpress website on a domain name example.com and I want to build a new website using WordPress and develop it on a staging environment on a sub-domain dev.example.com – is this possible?
    Can I make a sub-domain dev.example.com and install WP on the same server used by the current non-WP website?
    Later when the website is finished I want to connect my WP developed site with the domain name example.com.

    Thank you for your help.

    • WPBeginner Support

      Yes this is possible. Make sure you block search engines on your development subdomain.

      Administratör

      • Maria

        Thanks for a Very helpful article! I am in a similar situation as Mark, however my current website is a WordPress site. Can I still develop the redesigned website on a staging site within a sub domain? And if so do I have to create a new database?

        • byberkan

          You really didn’t read the article, do you?

  7. Benito

    Hello, great article, but what if I don’t want to use XAMPP, and I just want to use a subdomain as a staging site and then push changes to live? What would be the best way to deploy the changes?

  8. Raj

    Will this process create a Database User and add it to the database we created while copying giving it all privileges by itself? or do we need to create a database user at some point?

    • Raj

      Okay I tried it.. both ways.
      Once I created the database user before installing wordpress on the staging site and it worked. The other time around, I didn’t and got the issue ”We were able to connect to the database server (which means your username and password is okay) but not able to select the a*******_ata_d2db database.”

      That to me means that one has to create a user manually, only copying database won’t do. Right?

      • Sanny

        Raj, I see the same error (”Can’t select database”). How did you fix it ?

      • Scott

        Hopefully you guys figured this out, but just to leave this here for others to find, you do indeed need to create a database user (which is not clear in this article). While using Bluehost, I had to do about three steps. First step is to use the MySQL Database cPanel to get access to the list of MySQL databases. Once there, I could see that the new staging database that I had copied using phpMyAdmin per the article, did not have a privileged user assigned to it. So, I created a user, but then discovered that the user I created had too many characters (16 is the max). Once I got that straightened out, I then had to Add this user to a database using the same MySQL page. As part of this assignment step, I was able to select ”ALL PRIVILEGES” to make this user a privileged user for this new staging database. Once that was all setup, I was able to configure WordPress to connect up to the staging database.

  9. Gayle

    Terrific resource! Reached a WP staging breaking point and then found this. Lifesaver! Thank you! Only things I’d add would be some meta information for newbies like me. : )

  10. LizP

    Yikes, too hard for me!

  11. Deborah

    Thanks for the tutorial. I seem to be stuck on one of the very first steps. When clicking go after changing the URL’s in SQL, I get a message of ’# MySQL returned an empty result set (i.e. zero rows)’
    This is how I’ve entered the data:

    UPDATE wp_options SET option_value = REPLACE(option_value, ’http://www.example.co.za/wp’, ’http://staging.example.co.za’);
    UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ’http://www.example.co.za/wp’, ’http://staging.example.co.za’);
    UPDATE wp_posts SET guid = REPLACE(guid, ’http://www.example.co.za/wp’, ’http://staging.example.co.za’);
    UPDATE wp_posts SET post_content = REPLACE(post_content, ’http://www.example.co.za/wp’, ’http://staging.example.co.za’);

    Can anyone please help me with this?

    Thanks

  12. Andreas Kofoed

    Hi,

    First of all thanks for an amazing tut on this.

    I’ve encountered one problem so far and that is when I try to enter my subdomain through www.staging.example.com. I get this message: err_connection_timed_out ???

    • Andreas Kofoed

      Hi,

      I figured this out as I was due to some table prefix.

      Now my staging.mysite.com is up and running, but the styling and layout is totally different.
      How do I do, so my files in my child theme applies to the current theme???

      It seems like it is missing a lot of pictures, css and some basic settings?…

  13. Patrick

    Thanks for this great tutorial!

    I’m finding that after setting everything up, comments on the live blog are now going to the sub-domain staging blog. I can’t find anything in the settings that explains this behavior. Do subdomains perhaps take precedence for some reason?

    Any ideas?

    • Jennifer Filgate

      Perhaps when you ran the operation to update the URLs in your database you performed it on your live site’s database instead of the new staging site’s database? You have to select the staging site’s database after you create it before you run the operation. Maybe you missed that selecting step.

  14. Arjun Singhal

    I got errors regarding SSL certificates. I am a newbie when it comes to using Git and the command prompt on my Mac. So I couldn’t get to syncing everything like I wanted.

    Also, how it appears is that the steps are good to sync the local disks files to the server – changes in the theme folder etc.

    However, there is no syncing mechanism highlighted for the MySQL server changes in the case of WordPress.

  15. Evan

    I don’t know. This just seems really confusing.

    So, a Git Bucket is like an intermediary between your local computer and the hosted dev server? For example, if I have website.com then I create dev.website.com then I create an account and empty repository in Git Bucket then I create an empty folder on my local computer, and I edit files locally and sync them to the Git Bucket repository and then how do I commit to the live site? Is there any connection and control to the live site? It seems like from here, you sync your Git Bucket repository to the dev.website.com

    Then what? I wish this article had a diagram to understand how this all works. It might make sense to you guys because you do it all day, but for the first time, this is a dizzying experience. Especially since multiple points in this setup failed and I had to go about custom fixing each one. At this point, I have created dev.website.com, copied all files from the live site to it, copied the database, connected it in, logged into the dev.website.com wordpress site, made sure all is cool, but now … I am lost as to what I do next.

    In your article, you ask us to INIT a local directory on our computer. Well, I’m trying out Git Bucket’s SOURCE TREE, which by the way looks great. But now what? Any help on what is the procedure from here? What’s the logic to all this?

    I create a folder on my local drive, it syncs to a Git Bucket Repository so that people can develop collaboratively. But who uploads the changes to the dev.website.com server? Don’t users need to be able to do that to see live changes on the server? So how does that all connect?

    And how do you update the final changes to the live website once you’re ready? Man I’m confused. I spent 3 days getting this setup and I can’t figure out this next step, because I don’t understand how that all works.

    Any help?

    • Oscar

      Hi Evan, although I am sure you figured it out by now as its months later, I figured it may help others with the same question. After you have committed your code to version control, you would move your changes over to the server of your choice (dev/staging/production) using the deploy feature. This is described in the section above titled, ”Deploying Changes From BitBucket to Staging Site”. Hope this helps clarify!

  16. vjohnson

    I am truly a beginner at this, and I have read the article a couple of times. I think my environment is almost set up, the piece that appears to be missing is in the install step. The directions say copy the files but do not install ”yet”, when in this process do I run an install of wp? I am unsure if some of the issues that i ran into are due to my host which is hostgator or something that I’ve done wrong. Any input would be great.

    What is happening at this point is no errors but nothing is rendered on at the url for my staging area.

  17. Martin

    Nice article. Although, the whole way, you’re talking about setting up a development site on the server as a subdomain. But at the end your using a local Xammp server.

    How would you setup a test environment on the server where the doomain is hosted? Do you use bitbucket for it as well?

    Thanks, cheers.

  18. Alberto Serrano

    Hello , I made a staging site successfully but my live site already had a little problem with a plug in , I contacted the developer and he asked for my admin credentials , following your advice on other article I gave him log in credentials to my staging site and he fixed the issue , to make the changes on the live site he told me to import the database from the staging site to the live site , my concern is the sql changes I made to the staging database , if I copy the database isn’t my live site going to redirect to the staging site now ? I can’t find the SQL queries to delete them
    Thanks

  19. isagani

    hey,

    nice article, i followed all instructions and gave me a clean view process on using git and staging environment. hope all experienced people do what you did so many can step forward from beginner to advance.

    Thanks a lot.

    Isagani

  20. Kristof Bernaert

    Just a perfect article that helped me to setup the whole thing.

    My staging environment is on the same shared linux hosting, just in another directory.
    I used this also as the repo for git.

    With Coda, I’m working online in that staging. As I save changed files (mainly css), I see instantly the updates.
    So I don’t need the local files on my laptop.

    But how to checkout those remote files under the staging folder, without fetching a local copy?

    Thx!
    Kristof

  21. bcall

    Thanks for the article!

    I have one problem, though: I have two databases and am not sure which one (or maybe both) is connected to my live site. I checked the wp-config.php file and it’s linking to a database with a different name, one that does not appear in my database list (in phpMyAdmin). Is it possible that the database was renamed?

    • Nick Jubrey

      Look in your wp-config.php file that’s where wp is directed to that particular database, the db your using will be listed there.

  22. Tiffany Johnson

    I’m having some issues with the dev site recognizing my theme and content. I copied over the following files prior to running my installation of wordpress, however the pages and content are still not being recognized. I checked the files and my media is in the uploads file, my themes are present, as are my plugins, but none of them are recognized in the actual wordpress site.

    /wp-content/uploads
    /wp-content/themes
    /wp-content/plugins

    Any suggestions on what else I can try? Thanks!

    • Nicole

      I’m having this same problem. Any suggestions of what to try? I followed the instructions to copy those files from one folder to the other, and it is in the right place.

    • byberkan

      Brad, so that means you are not using the subdomain. You are just using it as a subdirectory which you didn’t have to create a subdomain to use that..

  23. Paula Lay

    Thank you so much for this tutorial! The step-by-step instructions are perfect for someone who hasn’t done this before. I encountered a snag where I was getting an error message after creating a subdomain (something like a problem configuring the DNS). For anyone that encounters this problem – clear your browser cache and cookies, and then you will see the correct screen. Took me days to figure this out (I gave it a few days because I thought it would take 24hrs or so for the domain to propogate).

  24. Random Dev

    Whoa. Wouldn’t it be simpler, cutting down on quite a few steps and reducing the technical nature of this process, to just use a backup plugin with a migrator (search/replace the database) function… instead of copying the databases manually, *and* instead of using Git/Bitbucket? Or am I not understanding something?

    • Cannonpult

      For smaller sites, maybe. But plugins like Duplicator start to fail or have significant diminishing returns on larger sites. For example, if you were working on a site with a lot of media, Duplicator will never be able to transfer everything. You will get warning messages and have to leave media behind in the transfer.

      Yes, this tutorial would be overkill for a small blog. But it’s absolutely the way you should go for say, a woocommerce site with 3,000 products (including images and custom data).

      The other big consideration is frequency of changes. Some sites are fairly hands-off after they go live. Maybe you just update core + plugins and perform a few minor changes per year. Other sites might require weekly or even more frequent changes. If this were the case, it would become a pain to wait for backups and then drop a backup on the new site (crossing your fingers that it works each time). By using the method described in the tutorial, you can commit smaller changes at a time right after testing them.

  25. mgiulio

    Excellent article.I was looking for info about best practices for wordpress staging sites. The additional section on the git-bitbucket workflow is very much appreciated.

  26. nwesource

    Fantastic tutorial, thank you! I know WPEngine.com has a staging site built into their hosting options which seems fantastic although I haven’t tried it just yet. Are there any other easier options you know of to setup and operate a staging site, with more of a plugin functionality like WPEngine? They literally have a clone to staging button and a clone to live button that makes this seem like a process from the 80’s LOL… :-)

    Amazing tutorial, thank you for enterprise level content!

  27. WPBeginner Staff

    No you first need to extract the zip folder and then upload the contents of wordpress directory to your staging site.

  28. Tony Leary

    Can someone elaborate on this one step:

    ”First download a fresh copy of WordPress from WordPress.org. Upload the contents of WordPress to your staging site. Note, do not run the WordPress install yet.”

    I read that as ”1) download WordPress zip file from WordPress.org and 2) upload .zip file to /staging folder via File Manager.” However, I don’t think that’s correct.

    • bcall

      You can upload the .zip file and then extract the contents within file manager.

    • Julius

      I actually found out the problem..and it’s been resolved…however, I am unable to add images to my library….anyone else experienced this challenge.

      • Hans Lindgren

        Is the wordpress install running on Windows?
        (If so, you need to grant Modify NTFS permissions to IUSR on C:WindowsTemp)

  29. Julius

    Awesome tutorial…however, after I attempt to log into the staging site I am taking to the ”Opps! Google Chrome could not find http”. What am I doing wrong?

  30. Julius

    This is really a great tutorial and something I been wanting to do for quite sometime. My problem is that when I visit the WP login screen it appears that the styling from my theme isn’t applied. Is this normal? Also, when I enter my credentials from the live site into the fields for the staging site, it doesn’t log me in. It’s taking me to the ”Oops! Google Chrome could not find http”. Am I doing something wrong?

  31. Sloan Stewart

    Very helpful article. Only issue I have is that when it begins discussing version control, it switches from focusing on the alternate wordpress installation on the server to a local installation on one’s machine.

    I am assuming one would build your site locally (I am using WAMP) and then use Git/Bitbucket & Ftploy to update your dev/staging wordpress install? That would mean one would have three versions of the wordpress site at all times [Production, Dev/Staging, Local].

    How does one ensure your local wordpress install remains compatible with the database and other configuration on the server? Or is there a way to utilize Git/Bitbucket/Ftploy on the server without having to involve a local copy of your wordpress site.

  32. Karlis

    Do you need to create user for your freshly created phpmyadmin database?

  33. Aathi

    Hi,
    Will the above process works for wordpress multisite ?

  34. Cheryl S.

    Because I typically develop in a staging area on my server and then move it to the clients server to go live, rolling back to previous versions is nearly impossible. This article has made me seriously consider implementing version control with Git and Bitbucket. Thank you so much for this tutorial.

    • Mimi Bondi

      Thank you. Is it safe to simply copy all the files from the ”test” site and paste them over the current ”live” files via FTP? Or is there more to it?

  35. Mimi Bondi

    Would this be the best way to duplicate a website, set it up with a new theme/content then copy it over to the current live website?
    I want to change theme but it’s quite a big job so instead of activating it then frantically trying to fix things for days, I’m looking for a way to copy my current site, change it all ”in the background” then make the new one live. Please let me know if it’s even possible?

  36. Mimi Bondi

    Once i have my site exacty how i want it in the staging environment,
    is there a safeway to copy those files to the real live site?

    My goal is to change themes but because this would involve quite a bit of
    setting up, i am looking for a way to do this safely and only replace my
    current content with the new content when it’s ready (without changing
    permalinks and SEO hopefully). Is that possible?

  37. Larry

    Excellent article….I was able to follow the instructions step-by-step and complete the creation of development site on my hosting server. Kudos to the writter.

  38. Mike

    I’m having some issues when I try to run the SQL queries to change the references to the staging site. I am receiving the following error:


    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’1
    UPDATE wp_options SET option_value = REPLACE(option_value, ’http://example’ at line 1

    My SQL query is as follows:


    1
    UPDATE wp_options SET option_value = REPLACE(option_value, ’http://example.com’, ’http://dev.example.com’);
    2
    UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ’http://example.com’, ’http://dev.example.com’);
    3
    UPDATE wp_posts SET guid = REPLACE(guid, ’http://example.com’, ’http://dev.example.com’);
    4
    UPDATE wp_posts SET post_content = REPLACE(post_content, ’http://example.com’, ’http://dev.example.com’);

    As I missing a step or do I have something incorrect in query? Thanks for your help.

    • Mike

      Never mind, I figured out my issue. Feel free to delete this comment.

      • djramc

        i have the same problem. could i ask how did you solve this issue?
        thanks by advance

        #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’)’ at line 1

    • WPBeginner Support

      You need to remove numbers from lines, replace example.com with your live site url and dev.example.com with your development or staging site URL.

      Administratör

  39. Bevis Larsen

    This article is most useful for the user who want to make advance wordpress application

  40. Brad E

    I followed the directions and am able to get the staging site to work. However, every link, page and even login revert to the live site not the staging site. How do I fix this?

    • WPBeginner Support

      you need to change site address and wordpress address. To do that you need to run this SQL query in phpmyadmin for the database of your staging site:

      UPDATE wp_options SET option_value = REPLACE(option_value, ’ORIGINAL_URL’, ’NEW_URL’);
      UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ’ORIGINAL_URL’, ’NEW_URL’);
      UPDATE wp_posts SET guid = REPLACE(guid, ’ORIGINAL_URL’, ’NEW_URL’);
      UPDATE wp_posts SET post_content = REPLACE(post_content, ’ORIGINAL_URL’, ’NEW_URL’);

      Don’t forget to replace the original url with the url of your live site and new url with the URL of your staging site.

      Administratör

      • Brad E

        OK – it works now. I had to run the query several times, but got it to work. The problem I am having now, is that all of the theme settings are missing. The header, widgets, background, etc. are set to the theme’s defaults. I am not sure how to update the settings to what the live site has. I copied the 3 files from the wp-content directory. Thanks for the outstanding article and support.

  41. ROHIT

    Hi,

    As usual, just read you well written article on staging. I’ve got only question in mind right now and is that if there is any changes made in database while working on any project then do I need to upload it seperately on server from local environment whereas files would automatically get deployed via ftploy.

    Cheers and Thanks.
    Keep your good work up.

  42. Clive

    If I make changes on my local WP project, I understand files in my theme are changed, and those are uploaded to staging via BitBucket/Ftploy. What about the database/tables from my local project? I don’t understand why those aren’t also included? Or would the database/tables in staging be updated based on theme changes that are uploaded? Thanks!!

    • WPBeginner Support

      Clive, in your BitBucket repository you can only store your WordPress files. FTPloy simply syncs those files to your staging site.

      Administratör

      • Paul Sweany

        What do you recommend for when database changes are made? Let’s say I create a new page; should I just re-import the database on the dev server after I make changes to it on my local copy? Also, moving it from dev to live, any recommendations other than manually importing it and running a search and replace to fix the URL?

  43. Glen Clay

    As usual, great article and right when I need it. Keep up the great work! On another note, I am on my iPhone and that annoying floating black ’Trending’ bar keeps getting in the way of me commenting. This article benefited me so much that I went through the several tries it took for me to comment.

  44. Eben

    I wasn’t really mentioned on what to do with the staging database and how to transfer the changes to the live database, especially if your client has been making changes to the live site while you’ve been making changes to the staging site and there are changes in both databases.

    This is one area of staging environments with wordpress that I haven’t been able to get my head around.

    • WPBeginner Support

      Staging is basically for development, when working on themes or plugins. We imported the database only so that we have actual data to test with. It is not supposed to be a synchronized mirror of your live site.

      Administratör

      • Juliana Maggioli

        I don’t know if is the same as Eben’s question, but everything is going fine till…: upload/transfer the staging content to the live site. supposing everything is perfect in the staging, how do i make all this perfect structure/content be the live site, without risks?

  45. Damien Carbery

    I have started using WP Migrate DB (http://wordpress.org/plugins/wp-migrate-db/) to convert urls and paths in the DB. It will also convert urls and paths that are in serialised data.

    So I copy the files to the staging server and create a database and then export the live db via WP Migrate DB and import it to the new database via phpMyAdmin.

    The biggest issue is when the live site is updated before I bring the staging server db back.

  46. Zimbrul

    If you have Softaculous is even easier to deploy a staging site to the live site: you can clone the site to a location within the same server.
    It’s what I’m doing: I create the staging environment and when done I just go the the list of my WordPress installs in Softaculous control panel and ”clone” the site to the live location. The live location must be empty by other files for this to work.

    • Giacomo Ardesi

      Hey Zimbrul, can you give some more details about Softaculous and how you used it please?

    • Giacomo Ardesi

      Hey Zimbrul, could you please give some more details on how you use Softaculous to clone your WP staging site? Thank you!

  47. M Asif Rahman

    Thanks Syed & The Team, that’s one of the most complete and understandable for normal readers Staging Guide for WP. Nicely done.

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.