Trying to connect local wordpress site to a remote db - php

There is a site at my job that has only been maintained by 1-2 developers for a while but as more developers are being added to it we want to implement git. The workflow we're looking for has everyone using a local copy that is connected to the same remote database. We can all push and pull code as needed while any database changes would be shared that way.
I'm running into a weird issue where many files are refusing to load or clicking on any link results in a redirect to the xampp dashboard.
I downloaded xampp and created a directory in htdocs called local_test. I downloaded all the sites files into that directory with ftp. Grabbed the dbs info from the host and whitelisted the outside ip address on the host.
I went into wp-config.php and changes all the db values so it connect correctly. Plus I added:
define('WP_SITEURL', 'localhost/local_test/');
define('WP_HOME', 'localhost/local_test/');
At first I was convinced it was a db issue, but I can connect to the database remotely just fine using mysql workbench so I doubt it's that. The footer and the header show up, just not much of the content in between and like I said whenever I click on a link it redirect to the generic xampp dashboard.

Related

Trying to work on a client's Drupal site from my local machine

I have a client who wants me to update their Drupal site. I've never done this before, and I want to work on it from my local machine just in case something goes wrong. I have no idea where to even start!
First off, how do I access my client's site files so I can get them onto my computer? I've tried entering the information the client gave me into Cyberduck, but it won't give me access. Is there another way to get access?
Also, how do I host it locally? I have XAMPP, but I'm not sure how to use it.
That being said, I have found a few forums that should help me set up the local server. I just don't know how to get the files from the live server to my computer.
I know this is a super noob problem, but I could use the help. Thank you!
Well, for the basic question, you have to get the correct credentials from your client. There's no alternative, really :D
While you're at it, you'll want a copy of the site's database too.
For the question "how do I host it locally?" Here's how I would go about it.
Get the site into version control.
Given that you were given (S)FTP credentials, I'm guessing the site is not version-controlled. If that's correct, then that is probably the very first thing you want to do. This will allow you to keep track of the changes you've made on your local site that are different to the production version.
Create an empty directory on your computer.
Navigate to the directory in a terminal and run git init.
Add a .gitignore file to that folder (you can create your own, or use one customized for Drupal).
Download the site's files into the directory created in step 1.
Add the files from the in the directory to the git repository by running this command in a terminal: git commit -am "First commit of Drupal files to repository."
There's a good help page about working with Drupal in git on drupal.org.
Create and populate your database.
Get a database dump from the live site.
Create a new database and database user on your machine.
Import the database dump into your new database.
Record the database credentials in settings.php or settings.local.php and store them somewhere safe, preferably in a password manager.
Change the database credentials in settings.php or settings.local.php to match the credentials of the database you've just created.
(For safety and to avoid confusion, I always create local databases with a different name, user, and password than the live site has. This means if your local credentials are compromised, the live site isn't, and it means you can't connect to and change the live site's database by accident.)
Set up the webserver in XAMPP
Create a new site in XAMPP called e.g. example.local that points to the directory that contains the file index.php
Add the following line the file called /etc/hosts on your computer:
127.0.0.1 example.local
Test that this works in a browser by visiting e.g. http://example.local or http://example.local/robots.txt.
Move your local changes to the Production site
How you will be able to do this depends to some extent on your client's web-hosting infrastructure, and what version of Drupal your client uses. but in any case, you will have three separate concerns for changes you make:
Code changes
You will need to deploy changes you make to the code back to the server. Ideally you would probably do this via Git either by cloning directly into the live site or (far better!) as part of an automated build process. By the sound of it, you may just have to FTP the changes back up.
Be careful not to re-upload your modified settings.php or settings.local.php file!
Content changes
You probably have to test some/all of your content changes locally and then recreate them on the live site. Because your client may have made changes to the live site while you were working, you can't risk importing your local database into the live site.
Configuration changes
Changes to configuration should be managed in code (i.e. as part of 1. Code changes above) if that's possible. In Drupal 7, the Features module is usually the best way to accomplish this (here's an answer I wrote describing the Features workflow). Drupal 8 has the Configuration Manager. Be aware that these two tools can both be tricky to use well.
Your client needs to gave you access to the files so you can put them into htdocs on XAMPP, then you need the database (also provide by the client), start XAMPP, create a new database on localhost/phpMyAdmin and import the db of the site. On the proyect code go to sites/default/settings and change the db settings to your local settings. Then you can go to localhost/{your-proyect} and it should work.

Issue importing wordpress db into godaddy

I have a local working Wordpress site and now I'm trying to import the db on a site hosted in Godaddy but it's telling me it can't connect to the database.
Basically I need db name, user and pass in the wp-config and I created manually the db in Godaddy to make sure the table prefixes are the same. Also, Godaddy won't take localhost in the wp-config, you have to use their ip address with a port, something like: 127.0.0.1:1234. The only thing I haven't checked yet are my privileges. Not sure what the defaults are in Godaddy.
For those Godaddy users, Am I missing something? Thanks.
don't upload your local wordpress database like that!
When you create articles, post, pages, etc locally with wordpress it fills your database with your local links. Even if you push it to your new godady database, all the links won't work.
Here is what you have to do:
Create a new database in godady (done)
Create a new user and password for the db with all the priviledge (you have to this, very important)
Upload and install wordpress to your new domain (follow the install tutorial)
Register your dbname, user and password (localhost will work as the db is one godady, but you can put the IP)
Upload your local theme to the new domain (update only the theme, uploads and plugins).
If needed, set up the htacess and permissions to be able to upload files
Download WP Migrate DB on your local project and export the db with your production website info. If you are unsure, install the plugin on the production site too, simulate an export and copy the info to your local project
Upload the migrate database to gadady and then rock'n roll =)

WordPress site isn't working after I migrated site - changed site address (URL)

I migrated from my local computer to my live server using Duplicator. When I switched over, my Wordpress Address (URL) was http://107.343.442.344 - my IP address - and the Site Address (URL) was http://nameofwebsite.com. Everything appears to be working just fine.
However, when I add an item to my cart and try to delete it, it doesn't remove the item. I check the console and there's a failed AJAX request. It's requesting information from http://107.343.442.344. So, I change the Site URL to http://107.343.442.344 and then the everything works just fine. However, now I can't go to my front page.
I tried making these changes to the database (WP-Options), but nothing works.
Does anyone know what I can do to correct the problem. I've contacted WooCommerce, but they're taking forever.
My site is not currently up, so you can't go to it.
Easiest way how to properly migrate your site from localhost to server:
Copy all your local site files to web server
Install and activate "WP Migrate DB" plugin to your local site, it's free and got all functionality you will need.
After "WP Migrate DB" activation you will find it under "Tools" > "Migrate DB". Open "Migrate DB", there will be empty "Replace" block with two fields which you need to fill (look at the picture below).
These two fields are only one you need to fill, after that click on "Export" button and plugin will download mysql database.
Login into your hosting cPanel (or any other webhosting management app if your hosting doesn't provide cPanel, for example, ISPconfig etc.) and create new database or replace old one with that which you just created with "WP Migrate DB" plugin.
Open and edit wp-config.php file on your public_html folder on webserver, replacing database name and other authentification credentials (change database name, database user and password which you created in cPanel) and save this file.
Done, enjoy. :)
i think you database is not migrate properly please try again with wp migrate db plugin or search replace file , if problem still appear then check the serve file and folder permissions
So I found out what the problem was. I was using VHS Host to redirect the IP address to my new server. Once I changed the nameservers to point towards my new server, it worked.
Thanks to everyone who posted a response. I really do appreciate it.

No images are being displayed after migrating drupal website from server to local host

I'm trying to replicate drupal website in my localhost. I have copied all the files from public_html folder and mysql database. I have also updated my database details in settings.php file and deleted all contents of .htaccess file under site folder. But still I'm not able to crack down. Please suggest some solution.
N.B: Also tried refreshing the cache.
Please check your network information with your debug window of the
browser. then you can identify loading failed resources. so you can
troubleshoot your self.
See the network resources information with google chrome.
Goto Menu -> More Tools -> Developer Tools, Then click Network tab. Refresh the page again. Then your resources will be listed as follows.
Make sure your base_url is defined and all thr content are copyed successfully.
Setup a test-site database with phpMyAdmin
Change settings.php (or includes/conf.php) in your backed-up Drupal files.
Upload the backed-up Drupal files to a test-site folder on your server
Check if your test site works.
Get ready for the basic steps.
How to copy live site to local server

Trouble migrating WordPress from local server to host

I'm having trouble migrating a Wordpress site I've been working on from my local machine onto a host.
I've been through the documentation and as far as I understand, I have to:
Export the wordpress database from my local server.
Edit the wp-config.php file to suit my target server.
Change the URL's in the settings to suit my target server.
Import the database on my target server and move over the adjusted wordpress installation onto my target server.
I can do all of this, but my there seem to be some problems: in my hosts phpmyadmin I can't view or edit any users and neither can I create any databases (there's no option for it). When I try to import a database I get an error: #1046 - No database selected.
What do I not know/doing wrong?
If importing a database, you need to create one first with the same name, then select it and then IMPORT the existing database to it.
I can do all of this, but my there seem to be some problems: in my hosts phpmyadmin I can't view or edit any users and neither can I
create any databases (there's no option for it).
If you're going through CPanel, you won't be able to add a database directly through PHPMyadmin. You should go to your host's home page and look for some wizard to create a database. (it should be next to the PHPMyadmin link.
Alternatively, for moving wordpress, You can install wordpress on your live site, then export your localhost content via Wordpress's dashboard and then import it on the live site.
This article on Moving Wordpress will also be helpful.

Categories