Migrating client wp site for local development - wordpress

I've been asked to help out with a former colleague of mine's Wordpress Site. Nothing crazy, just change the format of a page, and add some kind of form on another page. I'm not so concerned with these changes I need to make, but am more concerned with setting up an identical site locally so that I can exercise these changes, do whatever I need to do, then simply upload my changes.
Quick background of myself; web developer of about 5 years with strengths in the Javascript frameworks and Node sphere. I know what Wordpress is and can navigate through the project with relative ease. Where I fall short is uncertainty in the project set up side of things.
So I have both the project itself and an export of my clients database, and configuration is updated accordingly. When I attempt to run the site I'm constantly prompted with errors, most of which have me take a look at the code and see what exactly the problem is. At this point I've made quite a few adjustments to the site to try and make it work that I feel continuing development won't get me anywhere.
Is duplicating an existing site to a local env usually this difficult? Could bad implementation of the initial site by the previous developer be a reason why I'm now struggling? Am I missing a step?

Duplicating a WordPress website is not that difficult. If you have the wp admin login of your website then you can simply use duplicator or akeeba backup plugin, but no worries, if you do not have the wp login access and just have the wp files & db then try this: create a new db from phpmyadmin, place your files in wp theme directory, install your new wp by using your new db file created, after that import your db file and do the following changes in your wp config file found in your root directory.
You will need to type in the new database information: database name, database user, and the password.
Once you have updated those, click Save Changes
Fixing your Permalinks
Log into your WordPress Dashboard, using the username and password from the copy of WordPress you brought over
Under Settings, click Permalinks
You don't have to make any actual changes, just click the Save Changes button.
Doing this will update all the page and post URLs. If you have custom themes or plugins/widgets with old URLs, you will have to update those manually since there are not any plugins that are able to modify those as well.
For ref:
https://my.bluehost.com/cgi/help/2361
https://www.tipsandtricks-hq.com/how-to-easily-import-or-export-any-of-your-wordpress-database-content-using-phpmyadmin-3415

Related

problem mooving woocommerce to another domain

I have a woocommerce website installed and work normally , I want to change the theme without make changes on the website so all still ( products , pages, ...etc) .
I want to copy the same website into another domain to do changes without stop my first website .
this what i have do :
1- copy all files from the old to new website.
2- import database frm the old .
3- past into the new domain all files
4- import the tables of the old database to the new database
5- change the wp-config to work with the new database
6- change the domain into table : wp_options
and i launch the new domain : the first page is ok without errors
but when i enter to preview product i have error that page dosen't exist , and all other pages the same error . can any one help me ??? any ideas ?
When moving a WordPress site a few things to make it easier.
Manually, zip up uploads/plugins/theme or if you have some crazy thing going on wp-content. Generally, nothing else needs to be moved. (this excludes things like robots.txt etc you may have to move)
After importing the DB you need to run a search and replace to swap out the domain. It is used in more places than you think.
Go to settings and re-save permalinks twice. - This fixes most issues with pages not loading/404.
There are plugins out there that make this easier.
Updraft - Don't need the paid version. Can setup new site then add files and import them.
All in One WP Migration - Haven't seen anything this doesn't move but can be slow and harder with large sites.
Plugins like All in One WP Migration or Duplicator can be helpful, but from time to time they may fail.
With AIOWM you must create a backup and a blank WP installation, install the plugin in this blank installation and import the backup. Beware that many features are paid.
With Duplicator you create a backup and an installer that you've to upload (via FTP) to the new host and there execute the installer.php script to recover the backup.
Both of them take care of the search&replace needs.
If you want to go manual, you have to copy all files via ftp, or if you've a Cpanel or similar you can upload a Zip file and then extract it via the panel (I guess you don't have the ssh access to the server).
Than you've to create a database dump via PhpMyAdmin and restore it in the new server, thank you've to change two option in the database: the site url, and the wordpress address url.
That should let you login to the website backend, but BEWARE you've to do the search and replace on your database.
To do so, easyly, you can use Better Search & Replace plugin (https://it.wordpress.org/plugins/better-search-replace/).
Guessing that http://old_domain.com is your old domain and https://new_domain.com is the new one, usually I go this way on S&R:
- Search for "old_domain.com" and replace with "new_domain.com"
- Search for "http://new_domain.com" and replace with "https://new_domain.com" if you have an active SSL certificate
Than go to Settings -> Permalink and save twice.
Everything should be fine now :)
Remember to clean every cache if you've one active.

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

moving WordPress over to domain, after working on it locally through MAMP

I've finished the styling changes on WordPress and I'm ready to move it from MAMP to my domain.
Will this involve any changes to the WordPress files or can I just drag it over to my new domain once I purchased it?
The main start you must make is update your wp-config.php
define('WP_HOME','http://www.mynewdomain.com');
define('WP_SITEURL','http://www.mynewdomain.com');
That way wordpress knows what domain it MUST run from.
The reason you do that is because without this you may not be able to access admin, login, etc etc.
When this is working and you have logged in, go to wp-admin and go to your permalink settings.
Make a NOTE of your settings, then change them to default (and woocommerce settings etc).
Go to your home page and a few others, and notice how messed up your urls look :)
Now go back to permalink settings and restore them (the point of this is to make sure your .htaccess file that wordpress depends upon is set correctly)
Finally, have a look at https://github.com/veloper/WordPress-Domain-Changer to change your sql etc if needed.
note this method is very handy for developers so you just update your wp-config.php for localhost or development or production (not for testing purposes, don't use your local pc. copy it all up to a subdirectory of your hosting partner e.g. http://www.mynewdomain.com/mytestarea. Make sure you use a COPY of the mysql database (never point both to the same database). You now can test on the hosting platform without disturbing the live site or your development causing issues to other people.
It's been a long while for me personally, but you'll want to change the SiteURL via the options menu in wp-admin.
Otherwise, just make sure your MySQL database is exported over, your credentials and user permissions are all setup and those work too.
If you still have problems:
https://codex.wordpress.org/Changing_The_Site_URL
https://codex.wordpress.org/Moving_WordPress
The database has to be updated. What always works for me is that I export the database from phpMyAdmin or MySQL (using mysqldump) and open the exported .sql-file with a text editor, like Sublime Text.
Now you want to find any occurence of your previous URL. Let's say on your dev machine the URL to the index of your Wordpress site is http://localhost:8080/wordpress and you want it to be on a website under https://domain.com you simply do a Find & Replace using that and replace everything with https://domain.com.
For older Wordpress versions you have to update the .htaccess files if you have custom URL's.
You have to make a search replace in your database and replace your local domain ( test.lo ) with the live domain ( test.com ).
To do this you can use the script from here: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Add the searchreplacedb2.php file in your route folder and the access test.lo/searchreplacedb2.php and follow the steps there. This will replace your local domain with your live one everywhere in the database.
You can't make a simple search-replace because the local domain might be serialized in some fields in the database, and a simple search-replace will not replace those.

WORDPRESS Trouble with simple non profit theme

I've created a web application based on this free Wordpress Theme:
http://vandelaydesign.com/blog/wp-themes/simple-non-profit/
All ok in localhost environment, but when I uploaded the site on remote (PHP + MySQL + Email active), the admin panel changes, and shows me only a part of whole admin menu.
e.g., admin panel doesn't show me the theme customization page and the slideshow customization page, that instead, in local environment, I have it.
Can you help me??? Thanks!
It might be that the live server is running a different version of PHP, or has config settings that make it different from your local environment.
However, my guess is that you haven't modified the database properly when you transferred it and that is the cause of your problem (I would suggest that it's nothing to do with the theme).
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.
Delete the database on the live server and copy the local version of the database again, but this time use the instructions in the thread above to change all the instances of your local url path to the live domain url.

Resources