migrating website 'download'? - php

I am trying to move a website from one server to another. However, when I try to access this website in a browser it only downloads a 1kb file called "download." What could be causing this? The original site has SSL certificates as well as a lot of code written in php, sql, json, ajax, etc.
This question was closed as "not a real question" but I did not have time to respond to the comments. If this is a simple answer then, by all means, please give me the answer. *I have moved all files from the old server to the new server using an ftp client. All of the files have moved successfully. When try to login to the base page, or go to the index.php page, all that happens is a 1kb download titled "download" begins and ends. This file has no extension and is not able to be opened. * This problem has also occurred over multiple hosting companies as I have been trying to move this site for two weeks now.

I have had a similar problem before.
Try opening the "download" file with a text editor (perhaps rename it to download.txt to make it easier to open)
Once you have opened the file you will probably see the source of index.php. This would indicate that it is due to a misconfiguration of your server, possibly due to whoever set up the server of possibly due to your own .htaccess.
Firstly try deleting your .htaccess (some ftp clients may hide it). Does it work now?
If not try uploading a text file or image and checking if this file is being served, if not then there is something gravely wrong with the server config, probably not due to you.
If this does work then it is due to the PHP configuration, essentially the script is not being sent to PHP for processing, if this is the case then I would make sure PHP is installed and allowed on that server.

Related

php files downloaded instead of parsing, issue resolved from server, old users keep downloading even now

Explanation : some php handler issue occurred at server-side, which made all of my php file getting downloaded from server on 8-10 of my domains (hosted on same hosting) instead of parsing and displaying.
Server people claim that they have corrected, if i visit the sites now from my regular PC & browser the url is still giving me files to download. if from anyother PC or Browser its parsing the page and not downloading.
It 99% seems cached content issue after their efforts.
Problem : All of my OLD-regular users are now getting the files download rather parse. I cannot contact every user to clear their browser cache (if it is cache issue).
What can i do to resolve issue as a webmaster and make all my users get files parsed rather download.

WordPress files downloading instead of executing on the server

My WordPress files are downloading instead of executing on the server. I have tried changing the server but that does not solve the issue. I am sure it is happening from my WordPress files as the hosting runs other WordPress files smoothly.
I wish I could could provide the code but that isn't needed. Please guide me. Thanks.
I have only seen this happen when:
1) PHP is turned off or not installed on the server
2) The server needs to be reset
3) File names are not correct
4) The redirect script is not redirecting as it should
5) Links are not valid
The good news is most of these can be solved by you/your host. Call your host to ask them for help on verifying the PHP install/process. If everything is good (for instance, if you have another site on the same server that is working fine) then you need to verify file names. As this is WordPress and the file names are all pretty standard this isn't exactly likely but make sure there are no unwanted spaces and the file names are "something.php". With WordPress you may see a bunch of parameters passed through the URL so "something.php?blah=blah" Is fine too (no space between php and ?).
Check the link you are clicking. The file names might be good but the link may be bad. It might be as simple as fixing all the link URLs. From what I recall of WordPress, there is a built in method of linking to pages within the same WP site. I believe these are all based off the URL in the database so you may want to verify the URL in the database/config file to verify WP is sending them to the correct place. If they are not stored in the database and are instead, coded directly into the content, you may have to manually update every link to the correct URL.
Finally, if it is script or wordpress related you may want to consider a fresh WordPress install. The good thing about WordPress is all the good stuff is in the data base:
1) Make a backup of the data base
2) Trash your WP install completely
3) download and install new WP with desired plugins and themes
4) Restore database
If the last step breaks the server again, check URLs within the database: http://codex.wordpress.org/Changing_The_Site_URL
Your Host can usually help in backing up and restoring WP databases. Even godaddy (who does not support it) will often help you walk through the process (you really want to call the hosting team. As an ex-godaddy employee, those guys are the experts).
If this isn't enough information, please provide a link to the site. It will allow me to do some quick troubleshooting to determine the overall issue.
EDIT: Help for verifying php install
Create a php file with the following contents:
<?php phpinfo(); ?>
And upload it to your site
This will make information about your PHP install easily accessible
Note: DO NOT LEAVE THIS FILE UP PERMANENTLY AND DO NOT POST A LINK PUBLICLY, YOU DO NOT WANT RANDOM PEOPLE ON THE INTERNET ACCESSING THIS INFORMATION
If you can access the file and it loads up a bunch of information in a purple (I believe it is purple) table, your PHP install is up and running. If the file just downloads like the rest, contact your hosting provider.

Routing .htaccess to GitHub

I was wondering if there was a way to basically host a site on your server so you can run PHP, but have the actual code hosted on GitHub. In other words...
If a HTTP request went to:
http://mysite.com/docs.html
It'd request and pull in the content (via file_get_contents() or something):
https://raw.github.com/OscarGodson/Core.js/master/docs.html
Or, if they went to:
http://mysite.com/somedir/another/core.js
It'd pull down:
https://raw.github.com/OscarGodson/Core.js/master/somedir/another/core.js
I know GitHub has their own DNS servers, but id rather host it on my so i can run server side code. What would the htaccess code look like for this?
This is beyond the capabilities of .htaccess files, if the requirement is to run the PHP embedded in the HTML stored on github.com at the server on yourserver.com simply by a configuration line like a redirect in the .htaccess file.
A .htaccess file is typically used to provide directives to the Apache web server. These directives can indicate, for example, access permissions, popup password protection, linkages between URLs and the server's file system, handlers for certain types of files when fetched by the server before delivery to the browser, and redirects from one URL to another URL.
An .htaccess file can issue redirects for http://mysite.com/somedir/another/core.js to https://raw.github.com.... but then the browser will be pointed to raw.github.com, not mysite.com. Tricks can be done with frames to make this redirection less transparent to the human at the browser... but these dont affect the fact that the data comes from github.com without ever going to the server at mysite.com
In particular, PHP tags embedded in the HTML on github.com are never received by mysite.com's server and therefore will not run. Probably not want you want. Unless some big changes have occurred in Apache, .htaccess files will not set up that workflow. It might be possible for some expert to write an apache module to do it, but I am not sure.
What you can do is put a cron job on mysite.com that git pull's from github.com every few minutes. Perhaps that is what you want to do instead?
If the server can run PHP code, you can do this.
Basically, in the .htaccess file you use a RewriteRule to send all paths to a PHP script on your server. For example, a request for /somedir/anotherdir/core.js becomes /my-script.php/somedir/anotherdir/core.js. This is how a lot of app frameworks operate. When my-script.php runs the "real" path is in the PATH_INFO variable.
From that point the script could then fetch the file from GitHub. If it was HTML or JavaScript or an image, it could just pass it along to the client. (To do things properly, though, you'll want to pass along all the right headers, too, like ETag and Last-Modified and then also check those files, so that caching works properly and you don't spend a lot of time transferring files that don't need to be transferred again and again. Otherwise your site will be really slow.)
If the file is a PHP file, you could download it locally, then include it into the script in order to execute it. In this case, though, you need to make sure that every PHP file is self-contained, because you don't know which files have been fetched from GitHub yet, so if one file includes another you need to make sure the files dependent on the first file are downloaded, too. And the files dependent on those files, also.
So, in short, the .htaccess part of this is really simple, it's just a single RewriteRule. The complexity is in the PHP script that fetches files from GitHub. And if you just do the simplest thing possible, your site might not work, or it will work but really painfully slowly. And if you do a ton of genius level work on that script, you could make it run OK.
Now, what is the goal here? To save yourself the trouble of logging into the server and typing git pull to update the server files? I hope I've convinced you that trying to fetch files on demand from GitHub will be even more trouble than that.

PHP Page forced download IN ERROR

This is a strange problem but it happens enough that I wanted to ask.
For some reason, sometimes the browser will force a php page to download to the browser and it always comes up with 0 bytes.
Mind you, I'm not trying to force the download and I'm very familiar with headers and forcing files to download intentionally, what I'm talking about is an issue where the browser can't process the page and thus it spits it out as a forced download.
One Example: I've got phpMyAdmin 2.3.2 running on a PHP4 server and a PHP5 cloud server. On the PHP5 cloud server, if I click "browse" on a table it tries to spit out sql.php as a download and it comes out empty.
I know the details are vague and I don't expect a solution as much as some ideas in where to look or possibly if someone else has experienced the same thing.
BIZARRE UPDATE:
When the URL has the word "Select" in all caps it breaks.
Works:
phpmyadmin/sql.php?lang=en-iso-8859-1&server=1&db=371016_map_db&table=Data_Recovery&sql_query=Select
Breaks:
phpmyadmin/sql.php?lang=en-iso-8859-1&server=1&db=371016_map_db&table=Data_Recovery&sql_query=SELECT
Noodle that one!
ANSWER:
As it turns out, the words SELECT, UPDATE and INSERT (yes, all caps) are blocked words on The RackSpace cloud. You cannot pass these via a GET request, only POST.
However, if you change them to Select, Update and Insert they work just fine. Seems they are not blocking everything.
I have seen that when I'm trying to access a server to which I don't have a valid network route. For example, I set a tunnel proxy in Firefox, through ssh. Then try to connect to localhost - I get a download of a 0 byte PHP file.
The download is happening because it has an extension of PHP, with no content, and the server is not sending you a MIME type, so the browser doesn't know how to handle it, and reverts to a download.
Sounds like a server misconfiguration.
PS. stop using PHP 4.
In my experience this sometimes comes with a segmentation fault of the webserver, due to php scripts behaving badly (the foo(){foo();} kind of crash)
segmentations faults are logged in the apache error log.

Why I can view my php source code online?

I purchased a very well-known 3rd-party php-based forum software. Uploaded to my server, run it for few weeks. This morning, when I visit my site, it display all the PHP code, including all the comments etc, like what you will see if you open it with notepad. It was very scary, my database config which is in PHP file also visible, what happened? I have no choice but to take my website down now.
What should I do? How can view PHP code? I thought PHP code is very safe?
Has somebody hacked my website?
That's a configuration problem at the server (like mod_php not being loaded for some reason). Best contact your hosting provider immediately and let them know they have a serious problem!
Unless you have uploaded your own .htaccess file, which could also be the source of problematic Apache configuration settings?
Somebody disabled your script interpretation on your webserver. Ask your host admin.
Quick fix is to place a blank index.html in your website (and forum root directory if different). It won't stop people accessing your source code if they know the script names and know this error is in place, but at least it won't be displayed to every man and his dog as they visit your website/forum.
Other than that, you've had the PHP parsing module on your server disabled, either incorrectly or accidentally. Contact your host immediately, but I presume you would have already done this.

Categories