This question already has answers here:
Browser ask me to download php file
(4 answers)
Closed 8 years ago.
I began following a tutorial about PHP. Reached the form handling. But here it is: when I do what they say and press Submit, it gives me to save the .php file instead of executing it? What am I missing here?
You are missing an HTTP server that supports PHP and is configured to use it. PHP (in the context on the WWW) is a server side technology.
You may not actually be running a web server, and instead may be simply loading local files in your web browser. Install an easy setup web server and PHP setup package. On Windows, WAMP is recommended. On MacOS, the equivalent is MAMP
Rather than opening files from your local drive, you then access them as (for example):
http://localhost/your_php_file.php
It is a misconfiguration of the server. Perhaps the recommendations here could help. Either PHP isn't installed or Apache was not configured.
You are missing the Apache server and required PHP installation.
If you are on windows. Go to this link Wamp and select Downloads and download the latest version of Wamp.
For Mac OS you can use Mamp
Download and install it in your machine.
If you are on Linux - Ubuntu you can do:
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
After installation place your php code in configured folder where the php is set to run and then go to browser and take the url : http://localhost/yourphp.file.
Hope this helps
Related
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 6 years ago.
Well, I am having problem while installing phpmyadmin to my linux system. I followed all the instruction from digital ocean. After, I verify it in the browser then it shows this kind of php code.
Did I miss something during my installation? My version of php is 7 and I am using ubuntu 14.04.
Its seems that your server(Apache) is not recognizing php script as PHP language to be executed. At first check whether PHP is enable or not by running the following command in your terminal:
a2query -m php7.0
If it says somathing like PHP is not enable then run the following command:
sudo a2enmod php7.0
Then restart your Apache2 server with the following command:
sudo service apache2 restart
Try refreshing the phpmyadmin page now. Hope this will solve your problem. Best of luck
After you install php for (I'm assuming) Apache you need to restart the webserver for it to read the config files.
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.
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.
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
I am trying to use the new facebook api and it requires libcurl PHP. I used
sudo apt-get install php5-curl
sudo apachectl -k restart
And it didn't work. I get the same error and the phpinfo() page says nothing about libcurl.
The source of this problem is probably that I built some of the tools from source (apache2, php), but then I got bored so installed a lot of the extensions with the package manager. But I'm not exactly how to go about diagnosing the point of failure.
The apt-get install for curl definitely worked, and can be found in
/usr/lib/php5/20060613/curl.so
I think a lot of my confusion stems from not knowing which files go where, and what purpose they have. Any help would be appreciated, and please tell me if I need to provide more information.
edit:
The specific error I get is:
Exception: Facebook needs the CURL PHP extension.
from line
if (!function_exists('curl_init')) {
throw new Exception('Facebook needs the CURL PHP extension.');
}
Ubuntu: 9.10
PHP: 5.2.13
Loaded Configuration File: /etc/php5/apache2/php.ini
In general it's a bad idea to mix and match software from your distribution's package manager with stuff you've built yourself. The package manager will not know anything about the stuff you've built yourself and so can get confused.
Not only that but who's to say the stuff from the package manager is even binary compatible with the stuff you've built yourself? If you build it all yourself then at least you know it will all be compatible.
Sounds to me like you should uninstall the extensions and build them yourself. If you can't or don't want to do that then go back and install apache and friends through your package manager but I would recommend having patience and going for the former option.
Answer of Questions
What version of Ubuntu?
What version of PHP?
How is Apache and PHP set up?
What ini files does phpinfo() say is parsed? (should be near the top)
Perhaps apt failed to properly modify your php.ini file to load the curl extension?
Check out your php.ini and see if you have line like:
extension=curl.so
or maybe:
extension=/usr/lib/php5/20060613/curl.so
To check if php-curl is installed please follow these steps:
Create a file in your web server (in Ubuntu it would be in /var/www folder), name it info.php
Open that file and type this command:
<?php phpinfo(); ?>
Save that file
Open your favorite browser and open that file (ex: http://localhost/info.php)
Now you will see the Information about your PHP installation
Search for Curl, and if you cannot find it, it mean your php doesn’t have curl installed.
To install php-curl please follow these steps:
Open your terminal and type this command:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
After it finish open php.ini file (mine is at /etc/php5/apache2/php.ini ) and add this command: extension=curl.so
Save the file and restart apache with this command:
/etc/init.d/apache2 restart
Check the PHP information page again, you will find PHP-CURL installed
That’s it
Source: http://www.ivankristianto.com/os/ubuntu/howto-install-curl-in-php-apache/379/