Creating a duplicate WordPress install for testing - wordpress

I am trying to create an identical wordpress website - on the same server. I need to create this as a testing environment but every time I try to duplicate the site it breaks. Is there an easy way to create a testing environment, of the live site, on the same server while keeping all of the same widgets, plugins and content?
I am an experienced web developer but a novice when it comes to Word Press.
I appreciate the help.

In my experience the following usually works:
Setup your prod site
Copy all files to the test site
Modify the wp-config settings as needed, and create the test db schema
Export all the data from the prod site control panel and import into the test site

The problem is that while you have all the files identically, your database contains all the configuration information for the live site. You'll need to copy the database from live to your development/testing server. You can run an export on the SQL and import the data into a new database. Then modify the wordpress/wp-config.php file in your development site to connect to the new copied database.
Additionally, you'll want to go through the new copied database, table: wp_options and change the site URL to match the development site/server instead of the live server.
Some default fields you'll want to change are:
option_name: home
option_name: siteurl
As well as fields installed by plugins that contain your site URL and path.

Create a directory for the testing.
Backup the original database, and
create another one (you may use the
same db user/pass if you like).
Execute the SQL file from the backup (at the test database)
Edit the wp-config.php.
(Test Database) Update the URL at the (your prefix)_options table. It's the very first value with the option name: siteurl
Done.

Related

Local By Flywheel - Error establishing a database connection

I was working on a website for a client a week ago and I came back to make further edits, but whenever I want to access the website, it reads:
Error establishing a database connection
I checked my wp-config file and everything is untouched; I did not touch one single line of code here when setting up my new Wordpress project in Local by Flywheel.
All my other local websites work except for this one. I've provided an image of my workspace just to make it more clear.
Looking at this image, the MySQL Version is a little bit off. The version should in fact be 5.6.37, but instead it's reading an older version of MySQL.
I did try closing and reopening Local by Flywheel, but it had no effect.
Any help appreciated. Thank you!
Right click on the site name and click on “Reveal in Finder” in Local by Flywheel.
Compress the folder containing all your site in a *.ZIP file (normally there must be at least the “app” and “logs” folder, sometimes “conf”).
In Local by Flywheel, import the site manually in FILE / IMPORT SITE, choose the Zip of your site
Normally, it reinstalls the site and recreates the Database … for me it’s work (on Windows and on Mac)
Are you able to compare your wp-config.php file in the broken site to a site that is using the same MySQL server?
I know you said that the file is untouched, but check again that all of the define parameters are correct.
Next I would suggest logging into your MySQL server using the credentials you have listed in the wp-config.php file and ensure you are able to access your database.

Migrating Wordpress site to new domain

I have a Wordpress site with hostagator web hosting , I am buying new domain and want to use new domain for site but same existing developed site. How to backup existing site and then restore to new domain ?
Solution is here
after searching a lot i got one simple solution.
Using Duplicator plugins or any other tool is either difficult or paid.
My simple solution is as follows
Backup and download all data from public html folder
Download the SQL database associated with the wordpress site.(in phpMyadmin you will find option of export database.)
Now upload the same files of public html folder to the public html folder of new hosting.
create a database with same name and import the tables from the downloaded SQL database.(in phpMyadmin you will find option of import.)
Now check the site if the domain is not changed
If you are changing domain name too by keeping the website same you need to follow few more steps
Download and place the interconnet/it tool in public html folder and follow the steps in documentation to use this tool.
case1- you are transferring site from one domain to another
if you are transferring from abc.com to xyz.com ins search and replace tool replace abc.com string with xyz.com .
case2- if you are changing the names only in website
if you are keeping the domain same but changing name of site e.g. ABC Technologies to XYZ technologies . Then replace ABC to XYZ
You can use this tool as per your need as it is applicable for database too.
There are a lot of ways of doing that. You can search a lot of materials on Internet but I would advise you to use this tool because I used in the past and it's reliable and very straightforward.
It is called Duplicator and is a wordpress plugin solution:
https://wordpress.org/plugins/duplicator/
Consider to maintain your site active until your new site is working properly. I hope I could help you. Regards.
Just install WP migrate db plug-in in your current website. And export the database with your new URL. Then create a new database in your server and import the updated SQL file. Then edit your config.php with new database details. Finally point your new domian to this server
**should take complete backup (both files and databse) before making the above changes **
Here I will explain how to take back up manually and restore manually on another server with other domain name.
Backup: You need to take back up of site and database.
For site, you can take only back up of wp-content. It contains all data you need to resore.
STEP1 : cpanel-file manager-public html- (wp-content)- compress & save- export or
download zip file.
For database: phpmyadmin -> export databse. This gives you localhost.sql file.
These two files one .zip file and another .sql file are your back up.
(It is good to remember user id password of wordpress dashboard of this one)
Restore in another server on another domain:
After you get you new domain dns propagated on new server, open its cpanel.
Run wordpress script , see database name it is creating.
1) database restore:
MyphpAdmin->Database created by wordpress->check all tables->drop all tables.
Now your database is clean without any table.
In your loacalhost.sql file remove two piece of codes:
a)any signature like this (it should be on top)
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
-- Host: localhost:3306
-- Generation Time: Oct 14, 2019 at 09:45 PM
-- Server version: 5.6.45
-- PHP Version: 7.2.7
b) Code prompting creating a new database like this:
-- Database: soniasin_fitfoody
CREATE DATABASE IF NOT EXISTS soniasin_fitfoody DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE soniasin_fitfoody;
-->Now, go to import and import, select your back up .sql file-> go. It will import all tables in your this database.
--> There is a database table now like wp_option, go there & edit siteurl (keep your new domain name), home (keep your new domain name) and admin email id.Very important.
Site Restoration:
1) Go to public html folder. Remove directory wp-content.
2) Import your back .zip file here and unzip.
3) You will find on wp-config.php file in public html folder, open it and update table prefix.
$table_prefix = 'wp_'; Here yo have to see what is your table prefix. Check database tables and see what prefix is in all tables. Here in this example it was 'wp_' , therefore kept it.
4) Now log in to you wordpress dashboard. It will take username of old site now and should take old password too. In case you forget password, change it and then open. Now wordpress will confirm that your database is changed, say ok and proceed.
Your site should be running on new URL now on another server.
In case of doubt, you ask me. If one want to watch any video here goes the link https://youtu.be/wROa37k_RQA.

read wordpress user data into a local ms access database

I'm a MS Access developer who has a client with a wordpress website. I need a way of reading any new users who are added into the wordpress site into a microsoft access database that resides on the users local machine.
I only need to add any new records and don't need to write anything back to the site.
What would be the easiest way of doing something like this? I would sooner do it from the Access side as I'm not very familiar with wordpress, also I would prefer it to be automated so the user doesn't have to manually export from wordpress then import the data every time.
Any advice appreciated.
Thanks
Justin
There's no way to have WordPress connect to an Access DB because Access isn't persistent, it's on demand. The only way I can imagine handling it would depend on Access more than anything. Assuming Access can using the ODBC connectors installed on the windows system it's running on, you could do the following:
Setup the MySQL ODBC Connector on any systems which would run the Access DB you're setting up. I assume the WordPress install is using MySQL.
Setup a new ODBC connection using that connector within Access to the Wordpress
database (you can use the same connection information stored in the
WordPress root directory in a file called wp_config.php).
If you're connecting successfully, you can then read the wp_users table using properly formatted SQL commands (select * from wp_users, for instance).
The function within Access that manages this can either be scheduled to do it periodically while Access is open or just when Access is initialized. Depending on your needs.
You'll have to compare it to a local table of users to find differences if you're interested in all changes, though the user_login is static through normal channels so it's a good key. There's also a "user_registered" date/time column in wp_users so you could just look for users who registered since your last update/change to the local access table.
I'm not familiar with Access beyond a cursory understanding of it as a data source and some minor development functions, so there may be a much easier way to do it, but this is how I'd do it in any system that needed the user information from Wordpress.
Because Wordpress and Ms-Access live in very different environments, a trick is needed to "marry" the two. Another way we can use:
Use IIS as a webserver, so as not to collide with the port used by wordpress, so don't use port 80. Just use any port.
Use ASP to access Access Database (of course there is a block of ASP code to activate the connector to the Access file, then create a recordset via that connector for record2 and display it to the browser). Call it with the file name: recordshower.asp
The recordshower.asp file must be able to be called by the browser.
After that, go back to a page in wordpress, insert <iframe src=recordshower.asp width:.... ></iframe>
So, a wordpress page can display the contents of an Access table, with the help of ASP
I export the WordPress entries to a .CSV, I then run an Excel macro, which is stored in my personal workbook, to open the file from my downloads directory, convert the .CSV to .XLS, and write it to an XLS file in a known location. I then push a button in my MS Access program to read the entries from the .XLS file (which is externally linked to my MS Access as a Excel spreadsheet) and update my MS Access tables with the data.

Drupal Commerce Kickstart - Making Test site of Live site

I want to do developments on my client's website but by making a clone of it. So, main website url is: http://website.com and the clone i am trying to create is: http://test.website.com.
So far i've done the following:
copied entire root directory into public_html/test dir (with folders config,field,FirePHPCore,fontyourface,includes,js,misc,modules,scripts,sites,styles and themes)
created a subdomain in cPanel for test.website.com
checked the file settings.php (inside sites/default folder) for $base_url but found it commented, so left it as it is unchanged.
copied db via phpMyAdmin and updated the new db details in settings.php (inside sites/default folder).
inside the table variable, two rows with the name securepages_basepath and securepages_basepath_ssl. Changed their values from http://website.com to http://test.website.com (using the variable_get and variable_set functions).
Now i can access http://test.website.com but when i click on login (from header) it takes me to http://website.com/user and if manually type http://test.website.com/user and login then it takes me to http://website.com/users/admin then i have to manually type in correct address http://test.website.com/users/admin.
And when i logout, it again takes me back to http://website.com.
So i want to know how can i completely make it to work on http://test.website.com?
Are there more variables to change?
And how i can make 100% sure that the test site is only using test and not the live site. I am afraid of messing up live website.
Please advice, thanks!
I fixed it by disabling the secure pages from inside the mysql database. It was inside variable table and securepages_enable field. It was in blob so i had to download the blob first and opened it in notepad and changed the value inside it from 1 to 0 and then uploaded it back by updating the securepages_enable field.
I had to do this because after logging in from my test url, the urls were redirecting back to the live website, so whatever change i was making, it was all affecting the live site.
Hope this helps to someone with similar case. Thanks!

Creating a MAMP Local Copy of a Drupal 6 Website

We're currently rebranding a client of ours and it's come the time to take the new brand to their website.
I've not much experience with Drupal other than the theming (I've themed a Drupal website in the past but not very familiar with the software's inner workings).
As this website is live, it's obviously not feasible for me to make any changes to the live environment, so I have downloaded the source files of the website to a local webserver (MAMP).
I also have a MySQL dump of the database.
I'm not sure what files need to be changed inside Drupal to allow access to the MAMP webserver. Could somebody point me in the right direction here?
How would I connect the database to the website, which files need modification?
I think the client is running Drupal 6.
Update:
I've installed the database and linked it up using the below line:
$db_url = 'mysql://root#localhost/databasename';
I've hidden databasename for anonymity.
As it's MAMP, the database has no password. When I load up the website I get an error that install.php is not found. It's not there because the website is already 'installed'.
I've also updated the $base_url to read:
$base_url = 'http://localhost:8888/foldername';
You only need to modify one file, 'sites/default/settings.php'; you'll just need to change the database connection string in there to match your new database settings. There may be a couple of other settings in there you need to tweak depending on the set up of the site (for example the $base_url or $cookie_domain).
Other than that everything in your installation should be relatively path-ed so there shouldn't be any need to make more changes.
i was facing same problem after couple of hours try i got solution : we have to check the DB (tick on list of databases in local host) [ observe this after DB list : Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server. so enable only the db you want to use] this will redirect to http://localhost:8888/foldername/install.php successfully :D :D

Resources