I have my wordpress site on my local server at the following path :
wordpress-4.2.3\wordpress\wp-content\themes\mytheme
and the url to access my local site is:
http://localhost/wordpress-4.2.3/wordpress/
Now I need to migrate it to another local server, for this I have imported database successfully and copied wordpress folder and placed it in my project's folder as below:
my-project-name\wp-content\themes\mytheme
and also changed WordPress Address (URL) and Site Address (URL) which is initially http://localhost/wordpress-4.2.3/wordpress/ to http://local-server-ip/my-project-name/ but it is not working. Any suggestions?
You need to replace all URLs in the database, it is not sufficient to change the values only in the options table (otherwise links and images are corrupted).
Manual Migration:
Export your database (e.g. through phpMyAdmin) and do a search&replace with the old and new url
Update your wp-config.php (database name, login and passwort)
Update your .htaccess file (check the RewriteBase and Rewrite Rule)
Migration with Plugin:
Download a migration plugin, such as "Wordpress Duplicator"
Copy all data to folder "my-project-name"
Open your database > click on SQL tab > Run these commands manually
---------------------------------------------------------------------------
WP Update Query in database
---------------------------------------------------------------------------
UPDATE wp_options SET option_value = replace(option_value, 'http://localhost/wordpress-4.2.3/wordpress', 'http://local-server-ip/my-project-name') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, 'http://localhost/wordpress-4.2.3/wordpress', 'http://local-server-ip/my-project-name');
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://localhost/wordpress-4.2.3/wordpress', 'http://local-server-ip/my-project-name');
UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="http://localhost/wordpress-4.2.3/wordpress','src="http://local-server-ip/my-project-name');
then login to your wordpress admin panel go to Setting > Permalinks > click on Save Changes button.
Note: if you have changed your database don't forget to change credintials in wp-config.php
Related
Per these excellent instructions, I can export the tables of a wordpress subsite from a multisite installation. However, I cannot manage to update the table_prefix of the db according to the instructions. Can anyone see what I am doing wrong? or provide another "neat" terminal "one-liner" to update the db table_prefix (see " #6 " below)?
synapsis:
Where:
mainsite = domain.localhost.mainsite.com
subsite = domain.com
#0 sudo su
#1 Create space for db export & conversion
mkdir /tmp/domain.localhost.mainsite.com/
mkdir /tmp/domain.localhost.mainsite.com/domain.com
#2 change to wp root directory
$ cd /var/www/html/domain.localhost.mainsite.com/
#3 Locate blog_id of relevant site (NEVER # 1, this is main site)
wp site list
#4 Export all the subsite db tables to new " .sql " file
wp db export --tables=$(wp db tables --url=domain.localhost.mainsite.com --format=csv --skip-plugins --skip-themes --allow-root) /tmp/domain.sql --allow-root
#5 Identify current db prefix
grep "table_prefix" wp-config.php
output: $table_prefix = 'wpb_';
#6 Change the table prefix to match new location db prefix (" 2nodeh_ ")
sed "s#wpb_<blog_id#>_:#2nodeh_#g" /tmp/domain.sql > /tmp/domain.localhost.mainsite.com/domain.com/domain.sql #This does not seem to work
#7 make " .sql " even smaller, using gzip
gzip /tmp/domain.localhost.mainsite.com/domain.com/domain.sql -c > /tmp/domain.localhost.mainsite.com/domain.com/domain.sql.gz
#8 (move db to safer storage space) upload db to new location and import
(php my admin fastest way)
#9 rsync plugins, themes, & uploads to new location
/wprootdirectory/wp-content/plugins/
/wprootdirectory/wp-content/themes/
/wprootdirectory/wp-content/uploads/sites/<blog_id#>/
Whenever I import the db into the new database the original table_prefix is still present. I know how to use mysql to change the table prefix. I am specifically looking for a single terminal command similar to #6 above... Any tips?
You can use the wp-cli rename package,, which works for me.
https://github.com/iandunn/wp-cli-rename-db-prefix
Note: Please remember to take backup of your existing database before you run the commands.
Thanks
Found the answer, apparently the syntax in item #6 of my question was incorrect, to change a wordpress table prefix using sed, use the following format:
sed --in-place --expression 's#`wp_<blog_id#>_#`<new_prefix>_#g' exported-db.sql
Notes:
1.) The above is specifically for exporting a subsite from a multisite as described on the question, but can be used in other scenarios as well
2.) While temptingly easy, DO NOT, use this method to replace urls if you are moving from "domain.localhost.mainsite.com" to "domain.com" because wordpress serializes urls in the db in some instances, instead use the handy sql query below via the phpmyadmin sql quesy interface, making appropriate url changes:
UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');
3.) As always.. BACKUP YOUR DB, BEFORE YOU DO ANY OF THIS
I have integrated WordPress into my Magento 2 application using Fishpig. I have changed WordPress home address as sitename/m4blog.
In my local http:localhost/sitename/m4blog is working fine. But when I deployed same thing to server, then getting 404 error. In server the url is https://sitename/m4blog. I have checked the perma links settings. Beow Permalinks settings it is like this
If your .htaccess file was writable, we could do this
automatically, but it isn’t so these are the mod_rewrite rules you
should have in your .htaccess file. Click in the field and press
CTRL + a to select all.
After this there is code for .htaccess. So I replaced my .htaccess in server with this code . But no use. Could anybody help me out to resolve the issue?
First way
Set your WordPress setup folder name "wp".
M2 Admin Menu > WordPress > Path = wp
Database: magento2_wp > Table: wp_options
option_id = 1
option_name = siteurl
option_value = http://www.example.com/wp //Folder name of your WordPress installation.
autoupload = yes
option_id = 2
option_name = home
option_value = http://www.example.com/blog //Frontend URL
autoupload = yes
Second Way
Go to wordpress folder most probably inside root.
edit .htaccess and paste a code you display on admin
Save it.
Sometime it redirecting to live or it showing not found page
NOTE : I changed all the live url to localhost in the database and set up in the way it should be done.
i cant determine the problem
you can try below solutions
1) Delete .htaccess file from your project root folder in localhost and generate again using permalink from wp-admin -> Settings-> Permalink just click save button and it will generate automatically to root folder of the project.
2) Go to wp-admin -> Settings -> Genral Settings change
WordPress Address (URL) -> to http://localhost/your project name
Site Address (URL) -> to http://localhost/your project name
3) Make sure that in Wamp or Xamp server the Apache Modules rewrite_module is on
Change and Update WordPress URLS in Database When Site is Moved to new Host and check htacess file
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
I really hope you can help me!
I need to make some changes on a WP website from Xampp on my mac.
I did the backup of the DB and via FTP I copied all the files in XAMPP/htdocs/b
I modified the wp-config.php as follow:
define('DB_NAME', 'db:name');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
after importing the DB I also changed the siteurl under wp_options.
Now my problem is this... wen I open the website no pictures loads and any link goes to /xampp/ folder
I tried so many things but nothing seams to work. I cannot even access the wp-login.php due to user and psw wrong.
please please help!
* I realise that img url is: img src="/wp-content/themes/nm/images/common/impcontent/mapfiller.jpg" so it looks for the imgs into the localhost/wp-content/... insted of localhost/b/wp-content/... how do I change that???
In wp-config.php set the following values to your proper values:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
Once this is working, install and run https://wordpress.org/plugins/velvet-blues-update-urls/ to fix the path issues.
Execute the following query in phpmyadmin, note: wp_ is prefix of table. If you have changed the prefix of the table at the time of installation then use that prefix with wp_ in the below query
UPDATE wp_options SET option_value = replace(option_value, 'old_domain_url_here', 'new_domain_url_here') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'old_domain_url_here', 'new_domain_url_here');
UPDATE wp_posts SET post_content = replace(post_content, 'old_domain_url_here', 'new_domain_url_here');
Try using https://github.com/wp-sync-db/wp-sync-db
Install it both on localhost and on remote. Follow the instructions, set correct domains and push from local to remote. It should work nice :)
I've done these things:
Export import base
Update wp-config
Zip and send to hosting via FTP
Unzip and run
Test admin and posts. Ok!
Try go to www.itpodcasts.com.ua get redirected to www.itpodcasts.com.ua:8888 that couldn't be resolved.
.htaccess
# BEGIN WordPress
# END WordPress
Somebody know how fix it?
Please try to run those queries into your database
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com', 'http://www.new-domain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');