Solved

XAMPP - Bad Request (Invalid Hostname)

Posted on 2011-10-01
26
3,183 Views
Last Modified: 2012-05-12
Hi - I'm not that bad at webbie stuff but am having a terrible time just copying a live Wordpress website to a local Apache server.
I installed XAMPPLITE and can't get Apache to stay running - seemed to be problems with other programs using Port 80 (yeah - I know about Skype and made sure it was not the problem).
I got into Apache/httpd.conf and changed the four mentions of port 80 into 4903 which seemed safe enough but then I get the error  Bad Request (Invalid Hostname) when i enter either http://localhost/ or http://localhost/xampp
Cheez! - I've never had such a bad time doing something that ought to be trivial!
I need a complete prescription for copying a live Wordpress website complete with mysql database into a local server. I've used EasyPHP in the past without an issue but not involving databases.
Help please
0
Comment
Question by:cliveburton
  • 14
  • 8
  • 3
  • +1
26 Comments
 

Author Comment

by:cliveburton
ID: 36897518
By the way - I should have noted that changing from Port 80 to Port 4903 for Apache worked - it stays running now!
0
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 36897685
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36897690
I got into Apache/httpd.conf and changed the four mentions of port 80 into 4903 which seemed safe enough but then I get the error  Bad Request (Invalid Hostname) when i enter either http://localhost/ or http://localhost/xampp

If Apache is no longer listening on port 80, then you need to explicitly add the custom port to the URL in your browser -- http://localhost:4903

Probably better to find out what the other process is that is binding to port 80 so that you don't have to specify ports in the URL.

Which OS are you running?
0
 

Author Comment

by:cliveburton
ID: 36898553
Hi papertrip
Thanks for answering my query
Unfortunately using http://localhost:4903 didn't work but that’s probably not your fault because (as I had previously written below) I don’t think I ever actually managed to change the port number – how do you do that?
I've attached a file showing the Ports.
It seems that my attempt to reset the Apache port to 4903 didn't work anyhow. The ports list looks the same whether I set the ports to 80 or 4903 in the four instances in the Apache/httpd.conf  file and rebooted???
What the hell is IIS ? Another name for Apache or what? (see first line in Port list)
How do I get rid of it if necessary?
Cheez! I've been using computers on a daily basis since 1960!!! I have three of them going right now. But this is the most arcane rubbish I have ever got into - it's a nightmare! Nothing seems to work as expected.
I decided to reset msconfig to its normal start setting (I'd turned off iTunesHelper and nmctxth.exe (NetworkMagic - which had been giving trouble)
Now Apache and MySQL both keep running with the ports shown on the attached png file and - wonder of wonders  http://localhost/ now brings up the XAMPP splash screen - whooee!! (Maybe the msconfig settings were the problem?)

However, I would still like detailed steps for copying a live website onto the local Apache server.

It seems like I need to do the following:-
1.      Export the live site as an xml file
2.      Export the live site database as an sql file. (What are the best tools (plugins?) for those first two operations?)
3.      Download a fresh copy of WordPress and install it under “localhost” (it goes under folder www on EasyPHP - what folder does it go under in XAMPP?)
4.      Fix the DB name DB User and DB Password in the WordPress wp_config.php file
5.      Then what? Can I import the xml file without screwing up the new WordPress local site? How and when do I import the sql data?
Oh - and by the way - MySQL database and Apache both currently show as deactivated on XAMPP at the moment - what to do - what to do? even though the XAMPP control panel says they are both running.
Any help greatly appreciated – I’ve been misled by novices a number of times over this one – it would be nice to find an actual expert – I hope you are the one.
Thanks again and
Best regards
Clive Burton  (PhD – physics)
P.S. by stopping and starting MySQL and Apache a few times and hitting "status" on the XAMPP for Windows screen  a few times I managed to get both MySQL and PHP both Activated but not Apache::ASP

 Ports on PCV-RZ24G Win XP     XAMPP-Screen-and-Control-Panel
0
 

Author Comment

by:cliveburton
ID: 36898554
Hi papertrip
Thanks for answering my query
Unfortunately using http://localhost:4903 didn't work but that’s probably not your fault because (as I had previously written below) I don’t think I ever actually managed to change the port number – how do you do that?
I've attached a file showing the Ports.
It seems that my attempt to reset the Apache port to 4903 didn't work anyhow. The ports list looks the same whether I set the ports to 80 or 4903 in the four instances in the Apache/httpd.conf  file and rebooted???
What the hell is IIS ? Another name for Apache or what? (see first line in Port list)
How do I get rid of it if necessary?
Cheez! I've been using computers on a daily basis since 1960!!! I have three of them going right now. But this is the most arcane rubbish I have ever got into - it's a nightmare! Nothing seems to work as expected.
I decided to reset msconfig to its normal start setting (I'd turned off iTunesHelper and nmctxth.exe (NetworkMagic - which had been giving trouble)
Now Apache and MySQL both keep running with the ports shown on the attached png file and - wonder of wonders  http://localhost/ now brings up the XAMPP splash screen - whooee!! (Maybe the msconfig settings were the problem?)

However, I would still like detailed steps for copying a live website onto the local Apache server.

It seems like I need to do the following:-
1.      Export the live site as an xml file
2.      Export the live site database as an sql file. (What are the best tools (plugins?) for those first two operations?)
3.      Download a fresh copy of WordPress and install it under “localhost” (it goes under folder www on EasyPHP - what folder does it go under in XAMPP?)
4.      Fix the DB name DB User and DB Password in the WordPress wp_config.php file
5.      Then what? Can I import the xml file without screwing up the new WordPress local site? How and when do I import the sql data?
Oh - and by the way - MySQL database and Apache both currently show as deactivated on XAMPP at the moment - what to do - what to do? even though the XAMPP control panel says they are both running.
Any help greatly appreciated – I’ve been misled by novices a number of times over this one – it would be nice to find an actual expert – I hope you are the one.
Thanks again and
Best regards
Clive Burton  (PhD – physics)
P.S. by stopping and starting MySQL and Apache a few times and hitting "status" on the XAMPP for Windows screen  a few times I managed to get both MySQL and PHP both Activated but not Apache::ASP

     
0
 

Author Comment

by:cliveburton
ID: 36898557
I've increased the point value for this query.
0
 

Author Comment

by:cliveburton
ID: 36898558
I've increased the point value for this query.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36898649
Hi Clive,

Any help greatly appreciated – I’ve been misled by novices a number of times over this one – it would be nice to find an actual expert – I hope you are the one.
I'd like to preface this with I do not admin any production Windows servers... I dabble, but am definitely more on the Unix side... however I still believe I can help you with what needs to be done.  I am most definitely however not a novice ;)
I don’t think I ever actually managed to change the port number – how do you do that?
Let's not worry about that right now, let's focus on making sure only Apache is wanting to bind to port 80 then move onto your wordpress export/import.
What the hell is IIS ? Another name for Apache or what? (see first line in Port list)
IIS is the default Microsoft web server - http://en.wikipedia.org/wiki/Internet_Information_Services
How do I get rid of it if necessary?
You can either uninstall it entirely, or disable the service and make sure it doesn't start automatically at boot.  However, looking at your open ports screenshot, it appears that the actual culprit is the Web Deployment Agent Service (MsDepSvc.exe).  Either uninstall that or stop the service as with IIS, then restart Apache (reboot may be required but just restart Apache first and check your open ports again).

Work on that while I write a reply regarding export/import of your site.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36898714
1.      Export the live site as an xml file
Read through http://codex.wordpress.org/Tools_Export_SubPanel
2.      Export the live site database as an sql file. (What are the best tools (plugins?) for those first two operations?)
There are a few ways, check out http://codex.wordpress.org/Backing_Up_Your_Database
5.      Then what? Can I import the xml file without screwing up the new WordPress local site?
http://codex.wordpress.org/Tools_Import_Screen and http://codex.wordpress.org/Moving_WordPress
Note: If you are changing to a new server but same domain, all you need to do is edit wp-config.php and upload everything as it is to your new server.
How and when do I import the sql data?
Import the database before importing the XML.

Read through http://codex.wordpress.org/Moving_WordPress -- exactly how you are going to execute all of this depends on things like are you changing the URL, can you use phpMyAdmin, do you need the old blog running during migration, etc.  It's pretty situational but I think all the links provided will be sufficient to steer you in the right direction at the very least.
Oh - and by the way - MySQL database and Apache both currently show as deactivated on XAMPP at the moment - what to do - what to do? even though the XAMPP control panel says they are both running.
Let's finish all the other steps first then address this if it still exists.
0
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 36899506
I will add, while xampp is a good way to get apache/php on windows, getting a lamp server at turnkeylinux.org may be the way to go. Virtualbox or vmware player spin it up and it gets it's own ip. It's just like a real webhost, You use FTP to send it files. The upside is no port conflicts. The downside is you sometimes have to fiddle with command line linux. FTP to get files in and out. Etc...
0
 

Author Comment

by:cliveburton
ID: 36900386
Hi Aaron
Thank you very much for your very helpful comments.
I'm not sure how this system actually works but be assured I will give you very high marks at the end of it when I accept your solution.
Well, I managed to turn off the pesky Web Deployment Agent Service (MsDepSvc.exe) as you will see in the attached new png.
Clearly I have been looking in the wrong place for advice - - should have been looking at the more authoritative WP Codex rather than the outpourings of others on the web.
Now I'll start working methodically through your suggestions and suggested reading.
One thing though - the WordPress Codex - Backing Up Your Database has six suggested ways of doing this - which one do you think would be best for me given my aversion to writing scripts! or using command lines. I'm sorry, but after 50 years of doing this stuff I try to learn as little about new coding systems as possible because they never last very long - I figured out once (quite some years ago) that I had learnt about 28 operating and coding systems (not including the hundreds of applications I used as a research physicist all that time).
Thanks so much once again
Best regards
Clive Status-Ports-Control-Panel-XAMPP
0
 

Author Comment

by:cliveburton
ID: 36900390
Hello again Aaron
I forgot to ask - what time zone are you on?
I'm on Pacific Daylight Time (near San Francisco).
Cheers
Clive
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36900423
Hi Aaron
Thank you very much for your very helpful comments.
I'm assuming you meant to address that to me?  Or are you going to setup a turnkeylinux host instead as in Aarons suggestion?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 36900426
I think you ment papertrip.
0
 
LVL 21

Accepted Solution

by:
Papertrip earned 500 total points
ID: 36900431
One thing though - the WordPress Codex - Backing Up Your Database has six suggested ways of doing this - which one do you think would be best for me given my aversion to writing scripts! or using command lines.
phpMyAdmin
0
 

Author Comment

by:cliveburton
ID: 36900629
Papertrip
Sorry - I thought your real name was Aaron - all my comments were supposed to be directed to you.
Thanks for the suggestion re using phpMyAdmin - that's what I was just in the process of doing when I saw your reply.
And no thanks - I don't want to set up a turnkey Linux host at the moment.
I got on perfectly well with EasyPHP as my localhost for at least 5 years but didn't ever have to use a database until I got into WordPress.
Cheers
Clive
0
 

Author Comment

by:cliveburton
ID: 36900832
To Papertrip
OK - here's what I did.
1. Used cpanel phpMyAdmin to export all rows of the database as an sql file which all looked reasonable in PHP Designer (editor for all sorts of files including SQL).
2. Unzipped all the fresh new WP site from WP.org into the htdocs folder of xampplite
Created a database on localhost using the XAMPP MySql admin button and imported the above-mentioned sql file into it without a problem - looks fine. I gave it the same name as the live one - is that OK?
3. Filled in the DB data etc. in wp-config.php:-

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'cliveb28_wrdp19');

/** MySQL database username */
define('DB_USER', 'cliveb28_wrdp19');

/** MySQL database password */
define('DB_PASSWORD', 'xxxxxxxxxxxx');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');


But I have a worry about this - I used the proper password represented by xxxxxx above (not the real one for the world to see here) which is the password for wp-admin - is this the same as for the database?
Or am I supposed to be using the username and password I see under phpMyAdmin on the wp-users row - the password there is humongous ????

I changed the siteurl and home entries under wp-options both to http://localhost/

But I wind up with the dreaded "error establishing database connection" which I have seen too many times!
I tried putting he username and password I see under phpMyAdmin on the wp-users row into wp-config.php but still got he dreaded "error establishing database connection"

I haven't tried to import the xml file yet - doesn't seem like a good idea until I figure out this database thing - with your help I hope.
Best regards
Clive
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36900857
I gave it the same name as the live one - is that OK?
Yep.
But I have a worry about this - I used the proper password represented by xxxxxx above (not the real one for the world to see here) which is the password for wp-admin - is this the same as for the database?
Not necessarily.  It needs to be the password for user cliveb28_wrdp19 on database cliveb28_wrdp19.
I'm not sure what the exported sql dump looked like, but it probably didn't setup the user while importing it.  This can be done easily through phpMyAdmin.
http://codex.wordpress.org/Installing_WordPress#Using_phpMyAdmin

I'm on Pacific Daylight Time (near San Francisco).
I'm in Sunnyvale.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36900860
Or am I supposed to be using the username and password I see under phpMyAdmin on the wp-users row - the password there is humongous ????
I'm going to guess that wp-users is just the login info for users of your blog -- not the user who is setup to admin your DB.
0
 

Author Comment

by:cliveburton
ID: 36901573
Hi Papertrip
So here's what I did:-
Using localhost/phpmyadmin (under XAMPPLITE) I created a new database called whitecat
I imported the sql file from the live site (see attached)
I added a "new user" with a "new password" (see attached)
I gave the new user all privileges
I fixed the wp-config file with the new db name user name and password (see attached)
I fixed the siteurl and home in wp-options setting them both to http://local host    (should there be a slash after that or not?)
And after all that when I put http://localhost in the URL box and hit return I get - wait for it - a blank white screen
Help please before I go mad!
Best regards
Clive
PS - are the variable names in config enclosed by '   '     ?
whitecat-database-2011-10-02-214.png
config-2011-10-02-2146.png
whitecat-privileges-2011-10-02-2.png
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 36905233
Let me give you some advice on putting wordpress on your local hosting - it is not the best idea, as it may experience traffic / performance problems not to mention accessibility and, as you see, configuration issues. The shared "pro" hosting should you take into consideration.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36905598
And after all that when I put http://localhost in the URL box and hit return I get - wait for it - a blank white screen
Need to see how apache is configured for xampp.  Paste pertinent sections of httpd.conf and any other included conf files for apache.


PS - are the variable names in config enclosed by '   '     ?
Yep.
0
 

Author Comment

by:cliveburton
ID: 36907998
I have found the main reasons for my difficulties.
Adding WordPress directly under htdocs seems to create problems. I tried putting it in its own "wordpress ' directory and addressing that as localhost/wordpress. At least that allows me to create a vanilla version of WordPress with its own vacant database.
I can then import the xml file successfully but importing the sql file screws the site up and results in a blank canvas.
To avoid that I got rid of a whole lot of themes in the original site and left just one - the sql import then went OK - no blank canvas but not exactly everything was in the new site - a bit of patching had to be done. But I am now over the worst of it.
I'm away all tomorrow so I'll get back to this on Wednesday and accept solutions etc.
Thanks for your help.
0
 

Author Comment

by:cliveburton
ID: 36907999
I have found the main reasons for my difficulties.
Adding WordPress directly under htdocs seems to create problems. I tried putting it in its own "wordpress ' directory and addressing that as localhost/wordpress. At least that allows me to create a vanilla version of WordPress with its own vacant database.
I can then import the xml file successfully but importing the sql file screws the site up and results in a blank canvas.
To avoid that I got rid of a whole lot of themes in the original site and left just one - the sql import then went OK - no blank canvas but not exactly everything was in the new site - a bit of patching had to be done. But I am now over the worst of it.
I'm away all tomorrow so I'll get back to this on Wednesday and accept solutions etc.
Thanks for your help.
0
 

Author Comment

by:cliveburton
ID: 36943753
I got very busy with other matters but this was all wrapped up on 10/4. I have discovered an even bigger issue than the need to put WordPress under its own folder under htdocs on XAMPP.

The bigger issue is trying to transfer a lot of templates and plugins from the live to the local site.

By removing all but the active template and all but the absolutely necessary plugins from the live site I was able to transfer the live site using xml export/import to the local site which continued to function.
There were a few broken internal links to images which I needed to fix but otherwise all was OK.

I think, without any really hard evidence, that it is important to make sure that WordPress itself is the latest version and that all templates and plugins are the latest versions and compatible with the latest version of WP before attempting the transfer from live to local site.




Thanks everybody for your help on this frustrating little exercise.
0
 

Author Closing Comment

by:cliveburton
ID: 36943783
Papertrip did the best he could and was responsive.
No one else gave me as much help.
It seemed to be quite an arcane problem.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now