XAMPP & PHP - file downloads instead of running - php

I am trying to run a PHP script from my browser. I have XAMPP installed. Status shows that all the important stuff is activated, including PHP. I have a directory under htdocs called test in which I have a very simple index.php file with the following contents:
<?php phpinfo(); ?>
If I go to: localhost/test I get a satisfactory result will all sorts on information in a nice table. When I go to localhost/my_other_dir I see a list of two files, as follows:
52719c32376853836_20..> 2013-10-30 19:56 55M
installer.php 2013-10-30 19:55 527K
I expect that if I click on the installer.php file it will run the script and do some cool stuff that involves the other file in the directory. This was working a couple of hours ago and I'm not aware of anything that I changed, other than installing XCode Command Line Tools on my MacBook, which is running Mavericks.
When I click on installer.php, however, instead of running the script it just tries to download the file. What gives?
My server status shows the following:
XAMPP Status
This page offers you on one view all information about what's running and working and what's not.
Component Status Hint
--------------------------------------------------------------------
MySQL database ACTIVATED
PHP ACTIVATED
Perl ACTIVATED
Common Gateway Interface (CGI) ACTIVATED
Server Side Includes (SSI) ACTIVATED
PHP extension »OPcache« DEACTIVATED see FAQ
PHP extension »OCI8/Oracle« DEACTIVATED see FAQ

Related

my "phpinfo.php" file loads a completely blank page in both firefox and safari [duplicate]

This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 7 years ago.
Background: I want to learn PHP and in the tutorial that I'm doing, one of the first things it has you do after getting PHP and mySQL going is to to test it by making a phpinfo.php file and opening it.
Problem: In FireFox, the file loads a blank page. In Safari it only shows the code that I wrote: <?php phpinfo(); ?>.
Steps so far (not necessarily in order):
I followed the steps at http://coolestguidesontheplanet.com/how-to-install-php-mysql-apache-on-os-x-10-6/
I have made a phpinfo.php file using text editor in plain text mode (as opposed to rich text) and saved that in my "sites" folder. This is the only line in that file:
<?php phpinfo(); ?>
In system preferences, I have web sharing turned on and mySQL server running. I have removed the # from in front of the load php 5 module line in the httpd.conf file as per the tutorial I mentioned. I've tried restarting the web server using "sudo apachectl restart" and then restarting Firefox.
I looked for a php.ini file in my etc folder. There wasn't one but I did find a php.ini.default. I duplicated that file and renamed the duplicate to php.ini. I'm not sure this step was a correct step to take but from the little I could find on the internet it looks like somebody else has done this and I thought, why not?. (phpinfo.php loaded a blank page before and after this step)
I typed php -i | grep php.ini into terminal and got the following:
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /private/etc/php.ini
and a timezone warning
So I decided to look for a php.ini in the /private/etc folder and there is one there. ( The one I created was in the /etc folder not the /private/etc folder.)
I have searched the internet including this website for answers.
System info:
When typing php -v into terminal it tells me that I am using PHP 5.3.28
When typing mysql -v into terminal it tells me that I am using mySQL 5.6.10
I am running Mac OS 10.7.5 on a Macbook Pro.
FireFox version: 40.0.3
Safari version: 6.1.6
Questions:
1) Did I correctly create the php.ini file?
2) What am I missing? Why is the phpinfo file not loading in my browser?
3) Is the timezone warning important?
Make sure that your source code file has the .php extension in the end.
If you can see the code of your php file in your browser, probably your apache server is not started or it is not working properly. To set your development environment quickly, I recommend that you download an "all in one package" such as XAMPP server or WAMP server. It comes with everything that you need to get your php project working and it is very easy and quick to install.
Take a look at: https://www.apachefriends.org/index.html
Once you have installed the package, create a folder for your project and put your php file inside it. So, copy your project folder to "htdocs" folder, inside the WAMP or XAMPP path, open your browser and type the URL:
http://localhost/yourProjectFolder/phpinfo.php
You shall see your php file working on.
Good luck!

Apache downloads PHP files instead of displaying in browser when called via CMD (Ubuntu)

I've installed LAMP on my Ubuntu laptop with no apparent problems and successfully did the phpinfo() test by navigating to the file through the browser. But the same file is downloaded instead of executing when I'm trying to build from Sublime Text 3 using the following script:
{ "cmd": ["/opt/google/chrome/google-chrome" ,"$file"] }
That worked the first couple of times I tested it, but stopped right after I changed the name of the build system and hasn't been functioning since even after I reversed the change. How would I go about fixing the issue?
$file is "The full path to the current file, e.g., C:\Files\Chapter1.txt.".
Apache isn't causing the file to be downloaded; you aren't requesting it from Apache.
You need to translate $file into a URL on your HTTP server.

Getting a 404 Error for index.php when trying to access it externally

After extensive search, double checking install, reinstalling, troubleshooting, I don't know where to turn next.
Background:
I'm trying to get a wiki working using MediaWiki.
I have PHP Manager installed for IIS 7.
I have a MySQL server installed on the same machine.
PHP version is 5.6.5 and installed at C:\PHP.
The main issue:
Locally I can view the index.php file, but not externally.
I get a generic page can't be displayed error if linking to the /w/ directory.
Depending on the browser I'll get two results when linking to w/index.php:
page can't be displayed
IIS 404.0 Error.
Depending on the browser I'll get two results linking to w/index.php?title=Main_Page;
IIS 404.0 Error
unformatted page content
The error:
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code: 0x80070002
Requested URL: http://localhost:80/w/index.php?title=Main_Page
Physical Path: C:\inetpub\wwwroot\w\index.php
Logon Method: Anonymous
Logon User: Anonymous
Troubleshooting done:
No errors shown by PHP Manager.
Switched PHP versions (no effect).
Externally tested other PHP forms running inside HTML (works fine).
Checked permissions on all folders (fine).
Edited Feature Permissions under Handler Mappings to allow executable (no change).
Changed PHP_via_FastCGI's access restriction to execute (no change).
Checked to make sure PHP Handling Mapping was set to *.php (it is).
Checked Default Document settings and index.php. Externally tested index.html in w/ (works both by direct link to file and link to folder).
Externally tried tested /w/index.html with PHP "Hello World" inside it (blank page).
What am I doing wrong? Everything works perfectly fine run locally on the server.
As Christpher says, localhost is a wrong in an URL to be contacted from outside: if that's what you see, you forgot to set $wgServer correctly.

wordpress downloading php file instead of viewing the webpage

I installed wordpress on my local machine (backtrack) for experimenting. After I got everything setup I moved it to an Ubuntu Server so that everybody can access those pages at work. I followed the same instructions, I moved the wordpress folder into /var/www but I created a new database with the same username, password and hostname.
The problem is whenever I access the webpage #ubuntu it tries to download the file, if access the page #backtrack it goes to the dashboard and everything is fine.
I did not have an .htaccess file on either machine sop I created one just to see if it will fix the problem but it did not.
Apache works fine because I can get to some folders I have setup by going to
"http://ubuntuserver/folder name"
and the logs shows no errors because it is delivering the webpage to the client just fine but the client is downloading it instead.
Any Ideas why this is happening??
Sounds like you haven't installed the PHP module for Apache or enabled it to use PHP using AddType in the Apache config file.
It seems that your WebServer ( Apache here, i suppose ) is not configured to use PHP module and/or is missing some PHP configuration options.
See here for some basic configuration tutorial.

Apache doesn't execute my copied PHP files, but testing.php works

I've just installed LAMP on my Ubuntu 9.10 machine, and everything works fine except when I copy my PHP files from another computer.
The LAMP guides I've followed also made me create a phpinfo() test file, which works, but when I try to type in e.g. index.php absolutely nothing happens - just a blank page in FireFox. :(
The files are in the exact same directory.
I'm thinking it's probably something with permissions and so on, but since I'm new to both PHP and Ubuntu, I'm kind of lost. It's like I can't create a PHP file with my file browser, but only by using the terminal - like when I created the testing.php from the LAMP guide.
Whaddayaknow... I made an error, tried to:
echo "Hello" world
which, even though I'm a PHP noob, I clearly know is wrong.
I think I'll have to figure out how to enable some sort of error reporting, a blank page is clearly not good enough.
You mean you have a index.php (copied from another computer) and a test.php (edited by hand, with a call to phpinfo()) in the same apache directory, the second works from your browser and the first doesnt ?
That can be a permission issue, or some compilation error in your php.
About permissions, for files should be readable from the apache server (more precisely, form the user that runs the apache server). You can type chmod a+r index.php.
YOu can also check your apache error logs (location dependent on installation). In any case it's vital to know where the error logs are if your are developing a web site.

Categories