I have installed XAMPP server on my system to be able to use PHP. But after installation, when I run any php script on the browser it does not run. I do not see any ouput. No checking the phpinfo() from local host I see that version 5.3.5 is installed
Even when running a a simple php file like where I echo a line;
I do not see anything on my browser. So, my question is do I need to make any configuration changes to my browser or system to get PHP running.
Put your scripts into /XAMPP/htdocs and then point your browser to: http://localhost/your_script.php
Your best bet is taking a look at your log files, and perhaps turning error reporting on. Put a simple script in your webroot that simply echo's a string, for example:
<?php echo "Hello World!";
with the above there is very little that can go wrong. Work from there. Take a look at your phpinfo, and see where your log files are located. Search for
error_log
for the path to your PHP error log file and maybe see if
display_errors
is on.
This is something that has a multitude of possibilities that can be the cause of your problem.
install phpxx-php which is used for creating dynamic web sites
check version of php using php -v
if you have php55 then use:
yum install php55-php.x86_64
Ensure to save file as .php ; e.g. index.php and not index.html
From Troublespy here are the reasons why php might not be working in the browser:
You did not download a local server
You are using the wrong version of php
You put your scripts in the wrong directory
You have a php error and the error didn't get printed
Your php code is wrong or incomplete
Make sure you check all reasons.
Related
I have to do a php project. I done php before so I understand the syntax for the most part. Just for a test, I made a file.php and in it I wrote:
<html>
<body>
<?php echo "helloWorld"; ?>
</body>
</html>
Well it won't display. The screen is blank. I tried it in chrome, firefox, IE and nothing wants to dispaly. Actually in IE, the source is displayed which is wierd. I also tried it without all the html and just used xampp to render it. It will not work. If I right click tho in the browser and view source, the code is there. Any ideas on what's going on?
Well, it comes from your web server configuration. If you're using Apache, have you enabled the mod-php module?
If you're new to setting up your own server, i would recommend using XAMPP (or WAMP), these are preconfigured PHP, Apache and MySQL servers.
If you're sure you have setup your server correctly check the following:
Make sure your executing your files from the server directory and NOT from a local directory. (your URL should look something like "http://localhost/test.php")
Note: You will need to phisically store the files in a place the apache server will look for, an example from XAMPP (on Windows, as thats what im assuming your using) is: "C:\xampp\htdocs"
Make sure your file ends in .php or something else that the Apache server will pickup as a PHP file. (.php3, .php4, etc)(make sure you didn't accidentally leave a .txt or something like that at the very end)
Check mod-php module is enabled (as Julien mentioned)
Hope that helps!
Edit:
Try
<?php
phpinfo();
?>
That as well, it should give you the php configuration information if the server is setup correctly.
EDIT2:
I see that you are using XAMPP, double check that the following file exists at the very least:
"C:\xampp\apache\conf\extra\httpd-xampp.conf", it loads the PHP module
I have Joomla installed in my computer, but recently have been writing php files that aren't related to the Joomla-managed site. For some reason, when I try to open those php files in the web browser using xampp (note: Joomla also is using xampp), the browser doesn't process the code w/in the tags as php code.
For example, after opening a basic page (a page with title "test", no content except in the body tags) in the web browser and going to the source code, the following is shows up in the source code:
<body>
<?php echo "hello"; ?>
</body>
instead of the HTML conversion. (i.e. just "hello")
Does anyone have an idea about what's going on here?
Thanks.
It's probably because PHP module isn't loaded in your apache. Be sure it is enabled
PHP is interpreted in the server, not the browser. Whatever's going wrong, you need to look at the SERVER side to resolve it.
My first guess: maybe you didn't suffix the file ".php" (so the server doesn't recognize it as a PHP file?)
Second guess: is the directory containing your PHP files configured to parse PHP?
If you have Joomla, you probably have PHP. You probably also have Apache.
So check your Apache configuration, and check your file naming conventions.
Is the file extension .php? The server doesn't magically know when you're serving php files, this is a good way to ensure it knows what you're doing.
Apache is looking into your localhost's defined root directory for files it can parse. In this case htdocs. This is the default for XAMPP. As far as Apache is concerned, it will not interpret any files outside of that folder.
if the problem in php module it better to re install php5 in to the system and it will work fine. probably the problem is in php module you should try re installing php in your system.
Just restart httpd service. It will work fine.
sudo systemctl restart httpd.service
if it has not worked please reinstall PHP once again.
Hy!!
I just get a vserver running debian. I just installed apache and php. Now the server should support php.
i uploaded the file index.php:
<?
echo "Hallo";
?>
The problem is if i start a request to the site my browser wants to download a file.
Whats could be the problem?
THX
have you restarted apache after installing PHP?
/etc/init.d/apache2 restart
This could mean that the Mime extension of the File is not registered with the web server which means you will need to check if you have the PHP Interpreter installed as a extension/plugin in your server.
Try:
<?php
echo "Hallo";
The short_open_tags is disabled in may distributions by default. If you have to support legacy pages you can anable them in php.ini, if not then just use the above, your code will be more compatible.
Your server isn't set to parse PHP files before they are output.
Check out these pages:
http://www.phpbuilder.com/board/archive/index.php/t-7100332.html
http://www.petefreitag.com/item/516.cfm
If your page works if you changed that to the <?php tags, then vbence would be right, it could be as shanethehat says that you just need to restart apache if you've already made the change to php.ini, one of the joys of all these things working together you need to work through all the options to find out where these things fall down so you know where to start looking to fix it
(Found why it wasnt displaying, I hadnt put code round the php tags)
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.
My Environmental Variables (& I crosschecked every possible place in the Registry) show my PHP include path as: "C:\PHP\" --and PHP (5.2.9-2) works fine on the system, so that is correct. However, running
ini_get("include_path")
shows the path as "C:\PHP5\". This causes problems with PEAR, etc. I've searched the system (i.e. php.ini files, httpd.conf, & everywhere else I can think of--there are no .htaccess files) & can find nothing that points at PHP5. Where in the world is this coming from??
Try searching for the literal PHP5 using a grep search tool (like windows grep http://www.wingrep.com/) it will take a while, but I think it's the best approach after you've checked all config files and environment variables.
Cheers
If you run a script with a call to phpinfo() PHP will tell you where the values come from:
<php
phpinfo();
?>
The top table will tell you what php.ini files it's reading and you'll find the value of the include_path directive in the Core table.
Something could be setting it using ini_set.
Or, after running the aforementioned grep on the whole system, you can try these:
Debug PHP to see what causes this.
Use Filemon from Sysinternals to see what files PHP is accessing.
This isn't really an answer to your problem however if you install WAMP or XAMPP you can usually avoid all of these annoying configuration issues.