Mirroring a Wordpress *configuration* between local and remote - wordpress

Ok, so I'm familiar with creating local Wordpress builds, and have been chugging along happily with the technique outlined in Smashing's MAMP-based article. My question goes a step beyond this.
The article is great for developing generic themes, but when developing sites (not necessarily blogs) based in Wordpress, for me at least, it's a little painful come launch day.
I have to go back in and reconfigure the server's Wordpress to match what I've already done locally. Settings have to be entered again, plugins need be installed again, menus recreated, and css will have to be altered to reference the unique classes/id's Wordpress generates for posts/pages/custom taxonomies…sometimes things are missed in the process. What I want to know is this:
Is there an easy way to automate cloning or mirroring the build on my local machine to the remote server?
Even if you have to just LMGTFY me, that would help. I don't exactly know what I should be searching for. Searches dealing with 'mirroring wordpress configuration' and 'cloning wordpress configuration' returns tutorials on moving content, which I know how to do.
If it helps, I'm running OSX 10.6.8 with xcode dev tools, git, ruby, node, and homebrew. All of my live servers have ssh access as well as ftp, and I build with the most current versions of Wordpress.

Here are some easy steps to follow:
Download and install the WP Migrate DB plugin.
Go to Tools > WP Migrate DB and fill-in the blank fields(New address (URL), New file path and optionally check/uncheck the other options). Click on Export Database and save the export file to your computer.
Make a .zip archive with ALL of your files(the /wp-admin, /wp-content, /wp-includes directories and all files in the root directory).
Upload that file to your production server, where you want your WordPress site to reside.
Go to your cPanel(or use the unzip command through SSH) File Manager(or any other alternative that you might have) and unzip the file that you just uploaded.
If you don't already have a Database set-up on your production server - create one through the hosting control panel(for cPanel, it would be Creating a mySQL database in cPanel, for plesk it would be Plesk 7 Tutorial: Creating a database, for anything else, just google it up, or try your hosting's FAQ). Remember/write-down your Database Name, Database User and Password.
Edit the wp-config.php file and change the values for the DB_NAME, DB_USER, DB_PASSWORD and optionally DB_HOST - but this is usually localhost - if that doesn't work try asking your web host, or if you have phpMyAdmin, log-in to it and look at the very top of the page - in this case the DB_HOST would be localhost.
After you've done all of that, log-in to your DB administration tool(most of the time this would be phpMyAdmin, but it could be something else as well) and upload the database export file that you save to your computer in step 2. Note: If your hosting hasn't provided you with a DB administration tool, I would suggest that you upload the phpMiniAdmin(click on the "Download latest version" link and save the file to your computer) script to your production server. Then go to that script(if your website is located at http://example.com/, go to http://example.com/phpminiadmin.php) and enter your DB details. On top of that page, you will see an import link. Click on it and upload your DB export file. Note 2: phpMiniAdmin doesn't support gzip-compressed files, so if you did check the Compress file with gzip option in step 2, you will have to re-do that step with this option unchecked.
Log-in to your site and go to Settings > Permalinks in order to update your permalink structure.
Check the permissions of the /wp-content/uploads and /wp-content/plugins directories - make sure that you will be able to upload images and plugins without any problems.
That's pretty much it. It might seem like a lot, but I follow this process for almost every site that I upload to production servers and it can take me as less as a bit under 10 minutes to do all of that(considering that I usually use custom MySQL commands, instead of the WP Migrate DB plugin - I should probably start using it :) ). Once you get used to the process and you don't encounter any low-quality web hostings, you should be perfectly fine with these steps.
Note: Since you used ssh as one of your tags, I assume that you usually have ssh access to the production server. If you don't I'm still assuming that you have a cPanel access(if that's not true and you can't unzip files on the server, then upload all files manually via FTP client, instead of doing steps 3 and 4).

I guess the only way is to copy the database or part of it.
What I do is to copy the relevant tables and modify manually the site URLs in table options. There are only 2. There is also a nice plugin velvet-blues-update-urls to modify all links, after the site URLs are set manually to be able to access the backend, in case posts are also copied.
Next, copy all theme directory files to the same directory in the site, assuming you are using the same theme.
Both processes can be automated with a PHP script.
I am not sure this is what you want, but hope this helps.

Not sure that this is exactly what you need, but to move a site you can use the built in Wordpress "export" and "import" options. As far as I remember there was an option when importing to change URL's and the import would change a few things for you.
Even if this does not answer your exact question, hope it helps.

Related

Localhost works but refuses to connect on a particular project (ERR_CONNECTION_REFUSE) (WAMP)

this is my third question about the same project, so yes, i'm struggling.
I'm trying to manually import a wordpress site in local. We don't have access anymore to the dashboard (some bad stuff happenning), so i can't install a plug-in that migrate the site easily and automatically.
After having problems for linking the database with the site, i had PHP errors (continue targetting to break). Now i don't have php errors anymore but i can't access the site anymore.
I can go to localhost, it reaches it easily, i can go to my other projects, but it refuses to reach this particular project.
It says :
This site can’t be reachedlocalhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
I've traveled on different forums to find a solution but i didn't find why it occurs only on one of my projects. The only difference i see is that the other projects use mariaDB and this one MySQL.
thanks for the help
Dude,
check local on flywheel its much simplier than wamp. Link:
https://localwp.com/
besides when migrating manually:
zip all ur files and download
install new wordpress in your local machine.
copy somewhere new wp-config.php and save it in different localization
paste and extract zip package in new wordpress localization on your computer
download database from wordpress you want to migrate on your local machine
replace wp-config.php which u extracted from files with your new wordpress instalation wp-config.php [ad.3]
it would be nice if u install wp-cli on your computer:link for windows:
https://www.ryadel.com/en/install-wp-cli-windows-wordpress-command-line-interface-how/
import database into your new wordpress and than run search replace in order to change migrating site domain name [use wp cli its easiest way]
to import DB:https://developer.wordpress.org/cli/commands/db/import/
to replace domains:https://developer.wordpress.org/cli/commands/search-replace/
remember that your DB need to be .sql and pasted in main wp directory
open terminal in main wp directory and write than wp-cli commands
If u re not familiar with terminal on windows I prefer gitbash / its easy to use adding linux commands and all sort of staff (always remember to open as administrator)
u can download here:https://gitforwindows.org/
after performing all this actions you can now log-in into wordpress on your local machine.
go to settings->permalinks and click save.
here you go u have finally migrated your site!
If you see 'error technical issues' you should also check ur file and directory permissions of wordpress.
here a link to correct permissions You can change with in gitbash terminal:Correct file permissions for WordPress

Wordpress wants to install itself, rather than run the blog

We have created a duplicate of our website on a new server as part of a migration. We have a wordpress blog that is part of our website.
The docroot of the wordpress site is set as an alias in our main site. The result is that to access the site home page, the following url is used: https://www.rephunter.net/blog/.
The new environment is not available to the public at this time, and is only accessible within our VPN. When the above link to the blog is followed, instead of the expected home page of our blog, we get the page at https://www.rephunter.net/blog/wp-admin/install.php, which wants to install a new site.
The configuration in the new environment is supposedly an exact copy of our production site from some time back. The permissions on the main files is the same.
What is it that is causing the attempted blog access to be redirected to the installation script?
EDIT:
The responses so far have not really absorbed the intent of the previous information. We are not migrating in the normal sense. Rather we are testing in a new virtual environment that will eventually lead to a more normal migration.
We have an exact duplicate of our original wordpress and database environment that is running in a virtual environment with an updated protocol stack that is only accessible if you are on the VPN for that environment. As far as we can tell, there is no difference in the configuration.
For example, the parameters in wp-config.php are exactly the same as in the original installation. When php runs, it sees the same environment, with host names and everything identical. It would not work otherwise.
Yet if there really were no difference, it would just run. But since WP is trying to install a new database, there is something different that we are missing.
To further illustrate this: supposed you took an image backup of the wordpress installation and the database, and put it in a different VM, and set up the DNS and everything as it needs to be--the new environment looks no different than the old one. All databases, wp-config settings, etc, are the same. So our main website and database functions very similarly.
As I mentioned above, the difference in the protocol stack should be considered. The old system is on PHP 5.6.27--the new one is on 7.3.4. So that could be causing some difference, which maybe somebody might recognize. Wordpress is 5.2.2 and should be compatible with both PHP levels.
We believe there is some relatively simple parameter setting that we are missing. For example, as in the first answer that $table_prefix is set wrongly. But that is not it in this case.
WordPress redirects you to that installation screen because the database it's connecting to is working (meaning, the username and password are correct), but the data it's expecting to be there isn't. Therefore, it assumes it's a new / empty database and prompts you to install WordPress.
I've seen this happen in two scenarios:
The database really is empty, and thus WP needs to install the standard tables and info
The table prefix in your wp-config.php file is incorrect for an existing database
Look at your wp-config.php file in the root directory of WordPress, and look for a line similar to this:
$table_prefix = 'wp_';
Then, open up the database (phpMyAdmin or some other interface to browse what the database structure actually is) and confirm that the table prefixes (the first few characters of the table names) actually match what's set above.
Hopefully this gives you something to go on! Let us know what you find
Migrating Wordpress websites can be quite tricky. I've worked as a WP developer for a number of years and always struggled with manually migrating websites.
There are a number of factors to consider:
WP stores a lot of installation specific information within the database. So you can't do a database dump and upload the export into a new database.
Changing the website url within the wp_options table in the databased there are still other references to the original url scattered throughout the db.
You could try a find and replace all using an editor that supports this sort of functionality (vscode, sublime, atom) but things always end up breaking and your doing tons of "find & replace" actions.
I have always relied on a 3rd party tool Backup Buddy as it simplifies the entire backup and migration process and offers the peace of mind of having easily deployable backups for your website.
Backup Buddy allows you to export your website as a zip and then you can move the zip to any server you want and the plugin provides an installer script (php) to guide you through the migration of your wp site to any host and database of your choosing.
Note: I am not in any way affiliated with iThemes or Backup buddy, and I do not stand to benefit in anyway if you decide to use the plugin. This is only advice on a tool that I have found helpful, reliable, have had success with, and currently actively use on a number of websites that I maintain.
WordPress display installation page because you have not update your wp-config.php file after migrating server so please follow below steps in future when you migrate your website.
Please follow this steps when you migrate your WordPress website from one server to another server.
Back up your website files/database
Export wordpress database.
Create database on your new host server.
Edit the wp-config.php File and edit this details.
Add new database name
Add new database username
Add new database user Password
Add new host as per your hosting provider or (localhost is default)
Import your database to new server.
upload the WordPress files to your new host
defining new domain URL & Search/Replace old domain URL

wordpress edit theme offline

I have a Wordpress-theme-based web published on the net, uploaded in a hosting.
I have to edit/simplify/modify the whole page, offline, on local for example.
While I make the changes offline, the page (an online magazine) has to keep online, as it is, until I publish the new version.
I have to be able to show the changes online, without affecting the original until the end.
What is a good way to do the whole process? Thank you very much.
Make offline server by installing eg. XAMPP.
Copy files, and export database from online to local,
Modify wp-config.php to match local database settings
Modify theme offline
Upload theme to online FTP when work is done
Make sure if changes you made are only in wp-content/themes/theme_name files - not in database content. If not, you will have to sync databases.
You can make the same to work online by cloning your WP to eg. subdomain, then protect it by htpasswd, to prevent unauthorised access.
I assume you mean with the same content?
One way is to make a copy of the main database (possibly refresh it now and then) for a second install online, with same plugins, settings etc.
Another way (bit riskier, but would give realtime sameness) would be to have a demo install on the same server that shares the same database: https://codex.wordpress.org/Editing_wp-config.php#table_prefix. I'd suggest with a custom user and usermeta where NO ONE has update privileges to avoid updates to the main site https://codex.wordpress.org/Editing_wp-config.php#Custom_User_and_Usermeta_Tables

How to manually back up wordpress website

I have never used wordpress before, My boss has given me access to a site which was created using wordpress. then He asked me how I am going to make sure I don't break the site accidentally, I told him I would create a backup on my local computer so that all my changes can be restored if I mess up.
I have the wordpress dashboard up. How do I back up EVERYTHING, I hear there are two separate things I need to back up? someone please help me.
PS: I don't think he would like me to do this with out the use of additional plugins.
There are two separate things:
Your website database. Simply export all the MySQL tables from the database, which is dedicated to your site.
The site files, everything you've got under WordPress folder, /wp-includes, /wp-content, /wp-admin directories and all files.
This should do it all. You can test on your localhost to make sure it's everything that's necessary.
You can backup your WordPress either from your hosting account (preferable) or from your WP dashboard.
You need to backup two things - all the files (the root of your Wordpress installation) and the database for your WP installation.
Since you only have access to the dashboard, you have to use plugin for this.
Two of my favorite free backup plugins are:
BackupWordpress - https://wordpress.org/plugins/backupwordpress/
BackWPup - https://wordpress.org/plugins/backwpup/
They are intuitive and easy to work with, so you shouldn't have issues.
If you go to the dashboard go to "tools" in the left toolbar. Select "export". On the export page you can report that you want to export "all content". This will get you the items that you need from the server.
Then you need to install wordpress to your machine. You can download that from: https://wordpress.org/download/
Once you have that on your machine you also need a local server to run it and test it. I like WAMP, but it partially depends on your operating system. I suggest the following video to get you up to speed on how to get the localhost set up and running: https://www.youtube.com/watch?v=snFzbPm_RUE
Hope this helps!

How to push wordpress from mamp into hostgator

I have done a blog in mamp and would like to push into hostgator. Must i recreate everything in hostgator like Installing Wordpress on Hostgator. Is there any way i could just push my stuff straight into hostgator without redoing everything in hostgator. Need some suggestion.. Thanks..
It's quite easy to deploy a local version of Wordpress to a live server. First of all, you are right, I would not bother installing a clean copy of Wordpress on your server, you'd then have to totally rebuild the site.
What you need to do is;
FTP all your files from your local machine to the server.
Transfer the whole database from local phpmyadmin to a new database on the server
Change the database connection details in wp-config.php
Make any necessary changes to your default Wordpress .htaccess. What I mean here is that your MAMP site probably isn't in the root but your live site probably will be. If you have SEO permalinks set up then you would remove the Mamp subdirectory from the rewrite rule and the base in the .htaccess. Your host might also require you to add rules here (ie specifying which version of PHP to use etc). You could always install Wordpress using their installer to see if they add any special rules themselves.
All easy so far - now comes my tip. Moving Wordpress databases from your local development environment to live can be a massive pain because Wordpress (and lots of plugin/theme developers) use serialized arrays to store data. So if you do a find-and-replace on the database to replace your old url with the new one, you will disable lots of things like config settings and widgets (text widgets specifically, but there's loads of stuff you end up having to recreate).
Download this file;
http://interconnectit.com/124/search-and-replace-for-wordpress-databases/
and upload it to the server and access it directly in your browser. Run through the quick form and perform a serialized array-friendly find and replace on your database urls. Job done. Good luck.

Resources