Apache2 doesn't show PHP code - php

I want to use my Raspi as a webserver so I followed this guide that basically set me up with an apache server and accompanying php modules. This works for html webpages.
The config file seems to suggest this module is being loaded by the apache server, but obviously something is going wrong since some test.php file:
<?php phpinfo(); ?>
fails to produce any output. I have reinstalled apache and have verified the (as far as I can see) correct url's to but to no avail.
How do I get to see my precious php info?
Obviously I will supply required information.

In order to run php script with Apache web server, you have to install php package in your server and libapache module which is required by apache to run php scripts. You can use following command to install php
sudo apt-get install php5 libapache2-mod-php5
Hope it helps.

I've replalced the flashdrive with a clean raspbian and retried the process, and for some reason this time I do get the desired output. I have no idea what happened there.

Related

PHP scripts aren't run on localhost

I wrote a simple script and I executed it on localhost but it wasn't executed.
I am used to use Ubuntu operation system.
I've checked apache2 web server which to be run by following command :
sudo service apache2 start
After checking the service to be run I wrote simple script such a :
<head>
<title>THE PRACTICING FILE</title>
</head>
<body>
<?php
echo "HELLO";
?>
</body>
After running the script, I found out that the resulting page just shows the tages which I used in the script such as < title > tag at the top of page.
But the php codes weren't executed, In this case echo "Hello"; wasn't executed.
What's wrong ? why such a thing have been occurred ? and finally how can i resolve the problem ?
Apache is a web server and by default serves static content, meaning HTML documents and any other kind of text or binary files as is. The way you get it to process php content and send its output is by using an Apache PHP module to invoke the PHP processor.
In order to do achieve that, make sure that:
You have installed php and you have a php module configured for apache: sudo apt-get install php5 libapache2-mod-php5
Your script has a .php extension, such as myscript.php, which is one of the default extensions to be handled by the php module on Apache.
You restarted apache after installing the php module: sudo service apache2 restart
You are hitting the proper page on your machine's browser, such as http://localhost/myscript.php, and not something like file:///var/www/html/myscript.php
If it still doesn't work, you can also check the logs on /var/log/httpd/error_log to see what went wrong.
For more info on Ubuntu with Apache and PHP (+MySQL= LAMP), follow this tutorial

Loading Newly Installed PHP Module Into Apache

I am working to build a small email client inside a web application. After doing some research I attempted to use the imap function. I got an error saying I was calling an undefined function, so again I researched and uncommented extension=php_imap.dll.
I then found I had to update php with the imap function and I did so. Now, the imap functions works in php interactive inside Terminal, but I can't get it to work in the browser. I'm assuming I have to somehow load it in the Apache Config files but I can't seem to find how to do so.
Any Ideas?
You'll need to restart Apache to reload the PHP module with the new configuration. The command line PHP starts a new PHP instance each time with the latest configuration, whereas the PHP extension running in Apache is separate, and only loads new configuration setting when Apache itself is restarted.
Assuming you're running on Windows based on the .dll extension, so apachectl restart or apache2ctl restart may work, or the installer you used may have a tray app or other GUI tool that can do it for you.
If running on Linux sudo service apache2 restart or sudo service httpd restart depending on distribution.

Blank screen on my domain and automatic Zip download

when i try upload something on my domain ftp, blank screen appiers and automatic Zip download starts , even phpinfo not working. I have dedicated server and never had any problems
My domain is and i want to install script at http://fablefly.com/install
Can You look Guys ?
P.S i'm running Cpanel , php 5.2 , mysql , ion cube enabled.
I think I understand what you mean. I had the issue before when I set up my server and installed PHP, whenever I went to a page, it downloaded a useless file. I solved the issue by running the following commands via ssh.
sudo apt-get install libapache2-mod-php5
sudo a2enmod php5
sudo service apache2 restart
Not sure exactly how you would go about doing this via cpanel as I use webmin personally and do most of the work via command line. But I believe this is your issue.
See this page
http://serverkb.co.uk/wiki/PHP - the section titled "PHP Page downloading"
Check this out
http://cpanelhostingstuff.com/php-files-are-downloading-instead-of-executing/
Also look at some of these pages https://www.google.co.uk/#q=php+downloading+instead+of+executing+cpanel

How to setup Mongo DB & PHP with core Mac OS 10.6.8, default Apache instance/Web Sharing

I am attempting to configure PHP and Mongo DB to connect with one another and I'm having some troubles. Before I say the problem let me recap what I have so far.
I am using MAC OS X 10.6.8
I have mongo DB installed and working stand-alone.
I have enabled PHP on the default Mac OS Apache web server. It is working and the server recognizes PHP ( it is not allowing inline PHP scripts in HTML files...not sure if this an issue)
"Web sharing" works just fine.
I have installed pear via this url: curl -O http://pear.php.net/go-pear.phar
I have the pear folder and files accessible and have launched o-pear.php from a web browser.
I have gone through the step-by-step install process ( and removed any red displayed errors ).
Presumably Pear is now installed.
It says at the bottom of the install front end:
Note: To use PEAR without any problems you need to add your PEAR
Installation path (/Users/myname/Sites/PEAR) to your
include_path.
Using a .htaccess file or directly edit httpd.conf would be working
solutions for Apache running servers, too.
I am not sure what the code is I need to add for the httaccess rewrite.
As of this moment
Terminal does not recognize the pear command.
When I launch the pear "front end" from a web browser I get:
Fatal error: No PEAR.php in supplied PEAR directory: /Users/myname/Sites/PEAR in /Users/myname/Sites/index.php on line 24
Thank you.
That is all.
Create a new PHP file called phpinfo.php. Add the content <?php phpinfo(); ?> there. Run the script from within your webbrowser.
You should see a big page with PHP configuration information. Watch out for include_path. This is where your webserver/PHP module/process searches for include files.
You will also find Loaded Configuration File. This is the PHP configuration file being used. Open that file in any editor, and search for include_path again. Add /Users/myname/Sites/PEAR to the end of the include_path.
Restart your webserver. PEAR now should work.
If you need to install the MongoDB PHP extension, go for pecl install mongo from command line.

How to link PHP 5.3 (FastCGI) to cURL with Lighttpd on Mac OS X?

I installed lighttpd, php5 +fastcgi, and php5-curl earlier this morning using MacPorts. I have been able to get the former two working fine, but I can't seem to get PHP to see the installed cURL extension. I did not change the install path for cURL - it is now at /opt/local/lib/php/extensions/no-debug-non-zts-20090626/curl.so.
I've added a line into my PHP file as well:
extension=curl.so
I've tried this line as well as one using the absolute path, restarting the server in between tries, but nothing has made cURL show up as an extension when I run a test page with phpinfo().
Am I missing a step here? Do I need to reconfigure and recompile PHP with an option for cURL, maybe?
Did you view the error message of Lighttpd? I guess there might be a problem with loading the curl.so, and it will be there.

Categories