PHP code is not being executed, instead code shows on the pageWhy are my PHP files showing as plain text?Browser is showing PHP code instead of processing itphpmyadmin showing php scriptHow do I show / run a PHP file in a browser? As if it was a webpagePHP code display in browser instead of executing itPHP file opens in browser instead of runninginclude variable to html titlePHP code is visible on websitePosting to PHP using AJAX - Returning full PHP pagePHP Code showing and not executing?How can I prevent SQL injection in PHP?Deleting an element from an array in PHPConvert HTML + CSS to PDF with PHP?startsWith() and endsWith() functions in PHPHow do I get PHP errors to display?How do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?Why PHP include is working on local server and not on website
What are these ingforms of learning?
Is this a Sherman, and if so what model?
How to manage expenditure when billing cycles and paycheck cycles are not aligned?
How does IBM's 53-bit quantum computer compare to classical ones for cryptanalytic tasks?
Guitar tuning (EADGBE), "perfect" fourths?
What are the benefits and disadvantages if a creature has multiple tails, e.g., Kyuubi or Nekomata?
Is there any reason nowadays to use a neon indicator lamp instead of an LED?
Is the mass of paint relevant in rocket design?
Is it a good idea to leave minor world details to the reader's imagination?
The quicker I go up, the sooner I’ll go down - Riddle
In a folk jam session, when asked which key my non-transposing chromatic instrument (like a violin) is in, what do I answer?
Would Taiwan and China's dispute be solved if Taiwan gave up being the Republic of China?
Is it really necessary to have a four hour meeting in Sprint planning?
How to make interviewee comfortable interviewing in lounge chairs
Is it more effective to add yeast before or after kneading?
If the EU does not offer an extension to UK's Article 50 invocation, is the Benn Bill irrelevant?
Leaving a job that I just took based on false promise of a raise. What do I tell future interviewers?
What are these pixel-level discolored specks? How can I fix it?
What is the meaning of "heutig" in this sentence?
Counting most common combination of values in dataframe column
1, 2, 4, 8, 16, ... 33?
Hiking with a mule or two?
Resolving moral conflict
Algorithm that spans orthogonal vectors: Python
PHP code is not being executed, instead code shows on the page
Why are my PHP files showing as plain text?Browser is showing PHP code instead of processing itphpmyadmin showing php scriptHow do I show / run a PHP file in a browser? As if it was a webpagePHP code display in browser instead of executing itPHP file opens in browser instead of runninginclude variable to html titlePHP code is visible on websitePosting to PHP using AJAX - Returning full PHP pagePHP Code showing and not executing?How can I prevent SQL injection in PHP?Deleting an element from an array in PHPConvert HTML + CSS to PDF with PHP?startsWith() and endsWith() functions in PHPHow do I get PHP errors to display?How do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?Why PHP include is working on local server and not on website
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to execute some PHP code on a project (using Dreamweaver) but the code isn't being run.
When I check the source code, the PHP code appears as HTML tags (I can see it in the source code). Apache is running properly (I'm working with XAMPP), the PHP pages are being opened properly but the PHP code isn't being executed.
Does someone have a suggestion about what is happening?
Note: The file is already named as filename.php
Edit:
The Code..:
<?
include_once("/code/configs.php");
?>
php apache
|
show 7 more comments
I'm trying to execute some PHP code on a project (using Dreamweaver) but the code isn't being run.
When I check the source code, the PHP code appears as HTML tags (I can see it in the source code). Apache is running properly (I'm working with XAMPP), the PHP pages are being opened properly but the PHP code isn't being executed.
Does someone have a suggestion about what is happening?
Note: The file is already named as filename.php
Edit:
The Code..:
<?
include_once("/code/configs.php");
?>
php apache
41
Are you using short tags<?
instead of<?php
?
– Dan Grossman
Feb 25 '11 at 19:09
2
Yes, i'm using <? ...
– Gui
Feb 25 '11 at 19:12
25
Don't EVER use short tags. (<?
). They are deprecated, don't really work in a lot of places, and are otherwise completely unneccessary. Saving three keystrokes is not a valid reason to allow potential for your code to fail on probably half of the servers it may run on.
– mopsyd
Feb 11 '15 at 19:53
7
@mopsyd Where does it say that short tags are deprecated? Please note that short tags are not the same as short echo tags, and short echo tags have been supported by default since PHP 5.4, regardless of theshort_open_tag
setting.
– Kyle Anderson
Mar 15 '16 at 19:23
2
I am aware that short tags are not short echo tags, which is why I specified which I was talking about in the comment. At the time of writing, short tags were flagged for deprecation for the php 6 release, though that has apparently changed since. The problem still exists that a lot of servers have them disabled, which makes your code significantly less portable. This does not apply to short echo tags (<?=
), which should run fine on php 5.4+ regardless of server settings.
– mopsyd
Mar 18 '16 at 0:44
|
show 7 more comments
I'm trying to execute some PHP code on a project (using Dreamweaver) but the code isn't being run.
When I check the source code, the PHP code appears as HTML tags (I can see it in the source code). Apache is running properly (I'm working with XAMPP), the PHP pages are being opened properly but the PHP code isn't being executed.
Does someone have a suggestion about what is happening?
Note: The file is already named as filename.php
Edit:
The Code..:
<?
include_once("/code/configs.php");
?>
php apache
I'm trying to execute some PHP code on a project (using Dreamweaver) but the code isn't being run.
When I check the source code, the PHP code appears as HTML tags (I can see it in the source code). Apache is running properly (I'm working with XAMPP), the PHP pages are being opened properly but the PHP code isn't being executed.
Does someone have a suggestion about what is happening?
Note: The file is already named as filename.php
Edit:
The Code..:
<?
include_once("/code/configs.php");
?>
php apache
php apache
edited Mar 22 '17 at 16:16
Taryn♦
200k47 gold badges306 silver badges366 bronze badges
200k47 gold badges306 silver badges366 bronze badges
asked Feb 25 '11 at 19:06
GuiGui
3,93510 gold badges35 silver badges51 bronze badges
3,93510 gold badges35 silver badges51 bronze badges
41
Are you using short tags<?
instead of<?php
?
– Dan Grossman
Feb 25 '11 at 19:09
2
Yes, i'm using <? ...
– Gui
Feb 25 '11 at 19:12
25
Don't EVER use short tags. (<?
). They are deprecated, don't really work in a lot of places, and are otherwise completely unneccessary. Saving three keystrokes is not a valid reason to allow potential for your code to fail on probably half of the servers it may run on.
– mopsyd
Feb 11 '15 at 19:53
7
@mopsyd Where does it say that short tags are deprecated? Please note that short tags are not the same as short echo tags, and short echo tags have been supported by default since PHP 5.4, regardless of theshort_open_tag
setting.
– Kyle Anderson
Mar 15 '16 at 19:23
2
I am aware that short tags are not short echo tags, which is why I specified which I was talking about in the comment. At the time of writing, short tags were flagged for deprecation for the php 6 release, though that has apparently changed since. The problem still exists that a lot of servers have them disabled, which makes your code significantly less portable. This does not apply to short echo tags (<?=
), which should run fine on php 5.4+ regardless of server settings.
– mopsyd
Mar 18 '16 at 0:44
|
show 7 more comments
41
Are you using short tags<?
instead of<?php
?
– Dan Grossman
Feb 25 '11 at 19:09
2
Yes, i'm using <? ...
– Gui
Feb 25 '11 at 19:12
25
Don't EVER use short tags. (<?
). They are deprecated, don't really work in a lot of places, and are otherwise completely unneccessary. Saving three keystrokes is not a valid reason to allow potential for your code to fail on probably half of the servers it may run on.
– mopsyd
Feb 11 '15 at 19:53
7
@mopsyd Where does it say that short tags are deprecated? Please note that short tags are not the same as short echo tags, and short echo tags have been supported by default since PHP 5.4, regardless of theshort_open_tag
setting.
– Kyle Anderson
Mar 15 '16 at 19:23
2
I am aware that short tags are not short echo tags, which is why I specified which I was talking about in the comment. At the time of writing, short tags were flagged for deprecation for the php 6 release, though that has apparently changed since. The problem still exists that a lot of servers have them disabled, which makes your code significantly less portable. This does not apply to short echo tags (<?=
), which should run fine on php 5.4+ regardless of server settings.
– mopsyd
Mar 18 '16 at 0:44
41
41
Are you using short tags
<?
instead of <?php
?– Dan Grossman
Feb 25 '11 at 19:09
Are you using short tags
<?
instead of <?php
?– Dan Grossman
Feb 25 '11 at 19:09
2
2
Yes, i'm using <? ...
– Gui
Feb 25 '11 at 19:12
Yes, i'm using <? ...
– Gui
Feb 25 '11 at 19:12
25
25
Don't EVER use short tags. (
<?
). They are deprecated, don't really work in a lot of places, and are otherwise completely unneccessary. Saving three keystrokes is not a valid reason to allow potential for your code to fail on probably half of the servers it may run on.– mopsyd
Feb 11 '15 at 19:53
Don't EVER use short tags. (
<?
). They are deprecated, don't really work in a lot of places, and are otherwise completely unneccessary. Saving three keystrokes is not a valid reason to allow potential for your code to fail on probably half of the servers it may run on.– mopsyd
Feb 11 '15 at 19:53
7
7
@mopsyd Where does it say that short tags are deprecated? Please note that short tags are not the same as short echo tags, and short echo tags have been supported by default since PHP 5.4, regardless of the
short_open_tag
setting.– Kyle Anderson
Mar 15 '16 at 19:23
@mopsyd Where does it say that short tags are deprecated? Please note that short tags are not the same as short echo tags, and short echo tags have been supported by default since PHP 5.4, regardless of the
short_open_tag
setting.– Kyle Anderson
Mar 15 '16 at 19:23
2
2
I am aware that short tags are not short echo tags, which is why I specified which I was talking about in the comment. At the time of writing, short tags were flagged for deprecation for the php 6 release, though that has apparently changed since. The problem still exists that a lot of servers have them disabled, which makes your code significantly less portable. This does not apply to short echo tags (
<?=
), which should run fine on php 5.4+ regardless of server settings.– mopsyd
Mar 18 '16 at 0:44
I am aware that short tags are not short echo tags, which is why I specified which I was talking about in the comment. At the time of writing, short tags were flagged for deprecation for the php 6 release, though that has apparently changed since. The problem still exists that a lot of servers have them disabled, which makes your code significantly less portable. This does not apply to short echo tags (
<?=
), which should run fine on php 5.4+ regardless of server settings.– mopsyd
Mar 18 '16 at 0:44
|
show 7 more comments
25 Answers
25
active
oldest
votes
Sounds like there is something wrong with your configuration, here are a few things you can check:
Make sure that PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run
php -v
from a command line and see if returns version information or any errors.Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like
LoadModule php5_module "c:/php/php5apache2_2.dll"
in the file. Search forLoadModule php
, and make sure that there is no comment (;
) in front of it.Make sure that Apache's httpd.conf file has the PHP MIME type in it. This should be something like
AddType application/x-httpd-php .php
. This tells Apache to run.php
files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.Make sure your file has the
.php
extension on it, or whichever extension specified in the MIME definition in point #3, otherwise it will not be executed as PHP.Make sure you are not using short tags in the PHP file (
<?
), these are not enabled on all servers by default and their use is discouraged. Use<?php
instead (or enable short tags in your php.ini withshort_open_tag=On
if you have code that relies on them).Make sure you are accessing your file over your webserver using an URL like
http://localhost/file.php
not via local file accessfile://localhost/www/file.php
And lastly check the PHP manual for further setup tips.
13
Don't know why, but installer of PHP 5.3.15 doesn't add the lineAddType application/x-httpd-php .php
. Thanks a lot!!
– MatuDuke
Jul 25 '12 at 2:03
7
@shmeeps: Where have you seen that short tags are deprecated? I've done some searching and can only find recommendations against them, nothing about deprecation. Granted for applications which are to be distributed it is better to use <?php in case the hosting server doesn't have them enabled, but for apps where you have full control over the server they're going to be on I don't see any reason not to use them.
– ClarkeyBoy
Oct 28 '13 at 16:35
3
point no 6 worked for me.. local access doesn't use the apache server
– KawaiKx
Jul 6 '14 at 15:24
6
point 2 worked for me the safe way -apt-get purge apache2; apt-get install apache2 libapache-mod-php5
– ulkas
Sep 16 '14 at 20:41
1
@full_prog_full Try uploading a file with a.php
extension with the contents<?php echo("Success"); ?>
and see if accessing the file through a web browser results in "Success" being displayed without the associated PHP code.
– shmeeps
Apr 18 '16 at 3:29
|
show 14 more comments
php7 :
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
sudo service apache2 restart
16
While this code snippet may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.
– Toby Speight
Feb 6 '17 at 18:31
4
This answer is linux related the topicstarter is clearly using windows.
– Raymond Nijland
Apr 24 '17 at 11:53
3
@RaymondNijland true but this is canonical and I found this question and it saved me after over an hour of troubleshooting.
– Goose
May 5 '17 at 20:57
How and Why: This happens when PHP7 doesn't configure the default fast-CGI service in the make script.sudo a2enmod proxy_fcgi setenvif
creates three new mods/mods-available/proxy.conf proxy_fcgi.load proxy.load
Likewise,sudo a2enconf php7.0-fpm
creates a config file/conf-available/php7.0-fpm.conf
Once this is done and Apache2 can then run the PHP7 module as a fast-CGI service.
– Talvi Watia
Nov 21 '17 at 12:49
1
worked for linux mint
– zzapper
Jan 20 '18 at 23:41
add a comment
|
I'm running Apache on Ubuntu and my issue was that the /etc/apache2/mods-available/php5.conf
file was missing this:
<FilesMatch ".+.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
I added it back in and php was parsing php files correctly.
add a comment
|
note for php 7 users, add this to your httpd.conf file:
# PHP 7 specific configuration
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
2
Just to help other people with this issue. Thehttpd.conf
file is located in/etc/apache2/httpd.conf
If you're using Ubuntu, it would beapache2.conf
in the same directory that needs to be modified for PHP7.
– Ahmed Sagarwala
Aug 14 '18 at 19:07
add a comment
|
I found another problem causing this issue and already solved it. I accidentally saved my script in UTF-16
encoding. It seems that PHP5 can't recognize <?php
tag in 16 bit encoding by default.
add a comment
|
I'm posting this answer because my Virtualmin/Webmin admin interface decided it was a good idea to disable my PHP engine.. took me a while to find the solution, so I thought I'd share it with you guys:
Also, be sure to check that none of your website config files related to this specific host or virtualhost have any php_admin_value's in them that turn off PHP, like this:
php_admin_value engine Off
When in doubt, comment it...
# php_admin_value engine Off
And restart your webserver.
Where are these config settings exactly?
– cronoklee
Jul 27 '16 at 14:43
2
@cronoklee In vHost settings of httpd.conf. For existing hosts, you need to edit apache config in webmin. For future hosts, go to virtualmin > server template > apache website. Eitherway, this is not as secure as fastcgi - virtualmin's default. So the correct approach should be to troubleshoot why fcgi doesn't work, for example it may be caused by file permissions.
– Sheepy
Sep 9 '16 at 3:43
If you're using a version of Apache that doesn't have httpd.conf, look in/etc/apache2/mods-enabled/php7.conf
orphp5.conf
– Sam Malayek
Oct 20 '16 at 22:53
When in doubt about the location of a certain configuration setting, you can always use grep to find what you're looking for by (for example in this case) typing:sudo grep php_admin_value /etc/* -R
– Henry van Megen
May 23 '18 at 11:05
add a comment
|
You're just opening your php file into browser. You have to open it using localhost url. if you open a file directly from your directory it will not execute the php code in any case.
use: http://locahost/index.php
or http:127.0.0.1/index.php
Enable php short code. In your case, you are using <?
which is php short code for <?php
. By default php short codes are disabled.
Also use: sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
if you are a ubuntu user.
1
Why is mcrypt required when i'm just including a file? You should noticed that this question is old and the short tags issue was mentioned 16 times, also in the top comment of my question.
– Gui
Dec 6 '16 at 16:20
1
I just share my solution, I was also facing the same error and after executing this command of mcrypt my issue solved. you may also try.
– Hasan Baig
Dec 7 '16 at 7:43
by default php short codes are enabled. short_open_tag=On (Default Value=ON) in php 5.6
– zond
Jan 26 '17 at 13:38
This was my problem, my virtualmin/apache configuration was for 127.0.0.2 but i was putting my external ip address in the browser, i just updated my v/a config and now its working
– Hayden Thring
Jan 15 at 20:14
add a comment
|
I know it should sound silly... but seldom it happens.
Check if you are trying to execute php from
**http://localhost/info.php**
and not from
file:///var/www/info.php
ps> you can notice that if you write from shell
php info.php
it answer with the code (it means php functions)..
PHP works fine (checked using command line). but, when I access the file using URL, it shows PHP code.
– muaaz
Jun 17 '15 at 8:08
add a comment
|
This just happened to me again, along with the server downloading html files, rather than processing. I had not use the webserver apache for some time on the computer and meanwhile Ubuntu updated like two more versions from originally installed LTS. Now it is
$ cat /etc/issue
Ubuntu 16.04 LTS
So the php worked after like so:
$ sudo apt-get install lamp-server^
$ sudo a2enmod php7.0
$ sudo service apache2 restart
The webserver was now parsing the php. Maybe now got to update some webs since php7.0 now running where as it was before running php5. Oh well.
2
you just reinstalled entire server..
– RozzA
May 10 '17 at 21:38
add a comment
|
I've solved this by uninstalling XAMPP, and installing WAMP.
Thanks for the help.
I am xampp but it works fine. did you find why it was showing php code @Gui
– Pie
Jun 13 at 18:18
add a comment
|
on my ubuntu 14.04, apache 2.4, php 5.5.9 install, I tried with a sample.php on /var/www/html (default document root) and it worked ok.
So the problem was on my Virtual Servers config.
The solution was to include, on the Directory def containing the .php, this line:
php_admin_flag engine on
and where should I add this line in Apache file in httpd.conf of my virtual server? and I am using Webmin
– suresh pareek
Aug 21 '17 at 12:45
add a comment
|
I faced this issue on php 7.1 that comes with High Sierra (OS X 10.13.5), editing /etc/apache2/httpd.conf
with following changes helped:
Uncomment this line
LoadModule php7_module libexec/apache2/libphp7.so
Paste following at the end
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
Like same can you pls suggest Wamp 3 version same error. There is no /etc/apache2/httpd.conf folder path in wamp 3. @AamirR
– Gem
Jan 9 at 7:00
add a comment
|
i had similar problem but in my case solution was different.
my file that held php code was called "somename.html"
changed it to "somename.php" worked fine
This also solved it for me. Does anyone know if the sever will execute php in a .html file or does the file ending always have to be changed to .php when there's a line of php to be executed?
– full_prog_full
Nov 10 '16 at 14:42
depends upon the server settings, for most cases php code that existing in anyfile.html will execute. and if it does not, it can be changed, although idk how :P
– Netrus
Dec 4 '16 at 16:49
add a comment
|
Check all the packages you have installed for php using:
yum list installed | grep remi
Install all relevant php packages, especially php-devel on your machine.
add a comment
|
This was in my .htaccess
DirectoryIndex index.html index.htm
index.html contained PHP code. By default, PHP won't process files with extentions like htm* as PHP code.
You can override this, by adding the following to .htaccess:
<FilesMatch ".+.html$">
SetHandler application/x-httpd-php
</FilesMatch>
add a comment
|
For fresh setup of LAMP running php 7
edit the file /etc/httpd/conf/httpd.conf
Note: make sure to make backup for it before changing anything.
Paste this at the very bottom of the file:
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Then, search for LoadModule and paste the following line:
LoadModule php7_module modules/libphp7.so
This line will simply ask httpd to load the php 7 module
Then restart httpd
add a comment
|
Make sure the script contains
<?php
before the code that should be executed. There should be no space between <?
and php
in this.
add a comment
|
I think the problem that it is showing code instead of the result is that it is not going to local host . recheck what address u r going in. are u going to a local file directory or to the local host.
from the screenshot u sent it is going to ur computer not to the localhost.
"file:/// " it should be "localhost/"
add a comment
|
Reinstalling the mcrypt
module worked for me.
$sudo apt-get install php5-mcrypt
$sudo php5enmod mcrypt
It honestly did, maybe because I hadn't configured the PHP properly on my system.But, since the question I asked regarding the same issue has been marked as a duplicate to this question, I only could answer it here. I wonder why the down vote.
– b.g
Oct 17 '16 at 13:06
This answer is linux related the topicstarter is clearly using windows
– Raymond Nijland
Apr 24 '17 at 11:55
add a comment
|
I had a case that I accidentally started untaring my files directory in root. It added the .htaccess file from my files folder that would block all php
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
Bottom line check the .htaccess file on root.
add a comment
|
If you have configuration like this:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example.com"
<FilesMatch ".php$">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</VirtualHost>
Uncomment next lines in your httpd.conf
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
It works for me
add a comment
|
Add AddType application/x-httpd-php .php
to your httpd.conf file if you are using Apache 2.4
add a comment
|
Just spent hours of trying to get PHP 5 to run with Apache 2.4 on Windows 10. Finally for me it was a typo in httpd.conf LoadModule
. Drew attention to writing and exact module path through the last answer in this apachelounge thread of denny2018. Thank you!
After two nights I discovered... My directory was written
c:
(lower case)
I had LoadModule php5_module "c:/php/php5apache2.dll"
but correct for apache 2.4 is:
LoadModule php5_module "C:/php/php5apache2_4.dll"
So I also missed the _4
before (for apache 2.4). The full snippet that worked for me:
# PHP
LoadModule php5_module "C:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Just tried PHP 7. There the LoadModule
line in httpd.conf for Apache 2.4 reads
LoadModule php7_module "C:/php/php7apache2_4.dll"
Currently php manual shows up c:/php/php5apache2.dll
which of course needs to be adjusted.
add a comment
|
in my case (Apache/2.4.34),
after uncommenting the specific module
"LoadModule php7_module libexec/apache2/libphp7.so"
from
"/etc/apache2/httpd.conf"
my problem was gone.
add a comment
|
the file that you put in /var/www/html/ should have .php
forexample example.php if it is example it is not working but if you change it to example.php it works.
add a comment
|
protected by Community♦ Jun 10 '15 at 1:01
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
25 Answers
25
active
oldest
votes
25 Answers
25
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sounds like there is something wrong with your configuration, here are a few things you can check:
Make sure that PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run
php -v
from a command line and see if returns version information or any errors.Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like
LoadModule php5_module "c:/php/php5apache2_2.dll"
in the file. Search forLoadModule php
, and make sure that there is no comment (;
) in front of it.Make sure that Apache's httpd.conf file has the PHP MIME type in it. This should be something like
AddType application/x-httpd-php .php
. This tells Apache to run.php
files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.Make sure your file has the
.php
extension on it, or whichever extension specified in the MIME definition in point #3, otherwise it will not be executed as PHP.Make sure you are not using short tags in the PHP file (
<?
), these are not enabled on all servers by default and their use is discouraged. Use<?php
instead (or enable short tags in your php.ini withshort_open_tag=On
if you have code that relies on them).Make sure you are accessing your file over your webserver using an URL like
http://localhost/file.php
not via local file accessfile://localhost/www/file.php
And lastly check the PHP manual for further setup tips.
13
Don't know why, but installer of PHP 5.3.15 doesn't add the lineAddType application/x-httpd-php .php
. Thanks a lot!!
– MatuDuke
Jul 25 '12 at 2:03
7
@shmeeps: Where have you seen that short tags are deprecated? I've done some searching and can only find recommendations against them, nothing about deprecation. Granted for applications which are to be distributed it is better to use <?php in case the hosting server doesn't have them enabled, but for apps where you have full control over the server they're going to be on I don't see any reason not to use them.
– ClarkeyBoy
Oct 28 '13 at 16:35
3
point no 6 worked for me.. local access doesn't use the apache server
– KawaiKx
Jul 6 '14 at 15:24
6
point 2 worked for me the safe way -apt-get purge apache2; apt-get install apache2 libapache-mod-php5
– ulkas
Sep 16 '14 at 20:41
1
@full_prog_full Try uploading a file with a.php
extension with the contents<?php echo("Success"); ?>
and see if accessing the file through a web browser results in "Success" being displayed without the associated PHP code.
– shmeeps
Apr 18 '16 at 3:29
|
show 14 more comments
Sounds like there is something wrong with your configuration, here are a few things you can check:
Make sure that PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run
php -v
from a command line and see if returns version information or any errors.Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like
LoadModule php5_module "c:/php/php5apache2_2.dll"
in the file. Search forLoadModule php
, and make sure that there is no comment (;
) in front of it.Make sure that Apache's httpd.conf file has the PHP MIME type in it. This should be something like
AddType application/x-httpd-php .php
. This tells Apache to run.php
files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.Make sure your file has the
.php
extension on it, or whichever extension specified in the MIME definition in point #3, otherwise it will not be executed as PHP.Make sure you are not using short tags in the PHP file (
<?
), these are not enabled on all servers by default and their use is discouraged. Use<?php
instead (or enable short tags in your php.ini withshort_open_tag=On
if you have code that relies on them).Make sure you are accessing your file over your webserver using an URL like
http://localhost/file.php
not via local file accessfile://localhost/www/file.php
And lastly check the PHP manual for further setup tips.
13
Don't know why, but installer of PHP 5.3.15 doesn't add the lineAddType application/x-httpd-php .php
. Thanks a lot!!
– MatuDuke
Jul 25 '12 at 2:03
7
@shmeeps: Where have you seen that short tags are deprecated? I've done some searching and can only find recommendations against them, nothing about deprecation. Granted for applications which are to be distributed it is better to use <?php in case the hosting server doesn't have them enabled, but for apps where you have full control over the server they're going to be on I don't see any reason not to use them.
– ClarkeyBoy
Oct 28 '13 at 16:35
3
point no 6 worked for me.. local access doesn't use the apache server
– KawaiKx
Jul 6 '14 at 15:24
6
point 2 worked for me the safe way -apt-get purge apache2; apt-get install apache2 libapache-mod-php5
– ulkas
Sep 16 '14 at 20:41
1
@full_prog_full Try uploading a file with a.php
extension with the contents<?php echo("Success"); ?>
and see if accessing the file through a web browser results in "Success" being displayed without the associated PHP code.
– shmeeps
Apr 18 '16 at 3:29
|
show 14 more comments
Sounds like there is something wrong with your configuration, here are a few things you can check:
Make sure that PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run
php -v
from a command line and see if returns version information or any errors.Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like
LoadModule php5_module "c:/php/php5apache2_2.dll"
in the file. Search forLoadModule php
, and make sure that there is no comment (;
) in front of it.Make sure that Apache's httpd.conf file has the PHP MIME type in it. This should be something like
AddType application/x-httpd-php .php
. This tells Apache to run.php
files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.Make sure your file has the
.php
extension on it, or whichever extension specified in the MIME definition in point #3, otherwise it will not be executed as PHP.Make sure you are not using short tags in the PHP file (
<?
), these are not enabled on all servers by default and their use is discouraged. Use<?php
instead (or enable short tags in your php.ini withshort_open_tag=On
if you have code that relies on them).Make sure you are accessing your file over your webserver using an URL like
http://localhost/file.php
not via local file accessfile://localhost/www/file.php
And lastly check the PHP manual for further setup tips.
Sounds like there is something wrong with your configuration, here are a few things you can check:
Make sure that PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run
php -v
from a command line and see if returns version information or any errors.Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like
LoadModule php5_module "c:/php/php5apache2_2.dll"
in the file. Search forLoadModule php
, and make sure that there is no comment (;
) in front of it.Make sure that Apache's httpd.conf file has the PHP MIME type in it. This should be something like
AddType application/x-httpd-php .php
. This tells Apache to run.php
files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.Make sure your file has the
.php
extension on it, or whichever extension specified in the MIME definition in point #3, otherwise it will not be executed as PHP.Make sure you are not using short tags in the PHP file (
<?
), these are not enabled on all servers by default and their use is discouraged. Use<?php
instead (or enable short tags in your php.ini withshort_open_tag=On
if you have code that relies on them).Make sure you are accessing your file over your webserver using an URL like
http://localhost/file.php
not via local file accessfile://localhost/www/file.php
And lastly check the PHP manual for further setup tips.
edited Nov 13 '17 at 11:44
Quentin
688k81 gold badges933 silver badges1089 bronze badges
688k81 gold badges933 silver badges1089 bronze badges
answered Feb 25 '11 at 19:15
shmeepsshmeeps
6,1792 gold badges21 silver badges32 bronze badges
6,1792 gold badges21 silver badges32 bronze badges
13
Don't know why, but installer of PHP 5.3.15 doesn't add the lineAddType application/x-httpd-php .php
. Thanks a lot!!
– MatuDuke
Jul 25 '12 at 2:03
7
@shmeeps: Where have you seen that short tags are deprecated? I've done some searching and can only find recommendations against them, nothing about deprecation. Granted for applications which are to be distributed it is better to use <?php in case the hosting server doesn't have them enabled, but for apps where you have full control over the server they're going to be on I don't see any reason not to use them.
– ClarkeyBoy
Oct 28 '13 at 16:35
3
point no 6 worked for me.. local access doesn't use the apache server
– KawaiKx
Jul 6 '14 at 15:24
6
point 2 worked for me the safe way -apt-get purge apache2; apt-get install apache2 libapache-mod-php5
– ulkas
Sep 16 '14 at 20:41
1
@full_prog_full Try uploading a file with a.php
extension with the contents<?php echo("Success"); ?>
and see if accessing the file through a web browser results in "Success" being displayed without the associated PHP code.
– shmeeps
Apr 18 '16 at 3:29
|
show 14 more comments
13
Don't know why, but installer of PHP 5.3.15 doesn't add the lineAddType application/x-httpd-php .php
. Thanks a lot!!
– MatuDuke
Jul 25 '12 at 2:03
7
@shmeeps: Where have you seen that short tags are deprecated? I've done some searching and can only find recommendations against them, nothing about deprecation. Granted for applications which are to be distributed it is better to use <?php in case the hosting server doesn't have them enabled, but for apps where you have full control over the server they're going to be on I don't see any reason not to use them.
– ClarkeyBoy
Oct 28 '13 at 16:35
3
point no 6 worked for me.. local access doesn't use the apache server
– KawaiKx
Jul 6 '14 at 15:24
6
point 2 worked for me the safe way -apt-get purge apache2; apt-get install apache2 libapache-mod-php5
– ulkas
Sep 16 '14 at 20:41
1
@full_prog_full Try uploading a file with a.php
extension with the contents<?php echo("Success"); ?>
and see if accessing the file through a web browser results in "Success" being displayed without the associated PHP code.
– shmeeps
Apr 18 '16 at 3:29
13
13
Don't know why, but installer of PHP 5.3.15 doesn't add the line
AddType application/x-httpd-php .php
. Thanks a lot!!– MatuDuke
Jul 25 '12 at 2:03
Don't know why, but installer of PHP 5.3.15 doesn't add the line
AddType application/x-httpd-php .php
. Thanks a lot!!– MatuDuke
Jul 25 '12 at 2:03
7
7
@shmeeps: Where have you seen that short tags are deprecated? I've done some searching and can only find recommendations against them, nothing about deprecation. Granted for applications which are to be distributed it is better to use <?php in case the hosting server doesn't have them enabled, but for apps where you have full control over the server they're going to be on I don't see any reason not to use them.
– ClarkeyBoy
Oct 28 '13 at 16:35
@shmeeps: Where have you seen that short tags are deprecated? I've done some searching and can only find recommendations against them, nothing about deprecation. Granted for applications which are to be distributed it is better to use <?php in case the hosting server doesn't have them enabled, but for apps where you have full control over the server they're going to be on I don't see any reason not to use them.
– ClarkeyBoy
Oct 28 '13 at 16:35
3
3
point no 6 worked for me.. local access doesn't use the apache server
– KawaiKx
Jul 6 '14 at 15:24
point no 6 worked for me.. local access doesn't use the apache server
– KawaiKx
Jul 6 '14 at 15:24
6
6
point 2 worked for me the safe way -
apt-get purge apache2; apt-get install apache2 libapache-mod-php5
– ulkas
Sep 16 '14 at 20:41
point 2 worked for me the safe way -
apt-get purge apache2; apt-get install apache2 libapache-mod-php5
– ulkas
Sep 16 '14 at 20:41
1
1
@full_prog_full Try uploading a file with a
.php
extension with the contents <?php echo("Success"); ?>
and see if accessing the file through a web browser results in "Success" being displayed without the associated PHP code.– shmeeps
Apr 18 '16 at 3:29
@full_prog_full Try uploading a file with a
.php
extension with the contents <?php echo("Success"); ?>
and see if accessing the file through a web browser results in "Success" being displayed without the associated PHP code.– shmeeps
Apr 18 '16 at 3:29
|
show 14 more comments
php7 :
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
sudo service apache2 restart
16
While this code snippet may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.
– Toby Speight
Feb 6 '17 at 18:31
4
This answer is linux related the topicstarter is clearly using windows.
– Raymond Nijland
Apr 24 '17 at 11:53
3
@RaymondNijland true but this is canonical and I found this question and it saved me after over an hour of troubleshooting.
– Goose
May 5 '17 at 20:57
How and Why: This happens when PHP7 doesn't configure the default fast-CGI service in the make script.sudo a2enmod proxy_fcgi setenvif
creates three new mods/mods-available/proxy.conf proxy_fcgi.load proxy.load
Likewise,sudo a2enconf php7.0-fpm
creates a config file/conf-available/php7.0-fpm.conf
Once this is done and Apache2 can then run the PHP7 module as a fast-CGI service.
– Talvi Watia
Nov 21 '17 at 12:49
1
worked for linux mint
– zzapper
Jan 20 '18 at 23:41
add a comment
|
php7 :
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
sudo service apache2 restart
16
While this code snippet may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.
– Toby Speight
Feb 6 '17 at 18:31
4
This answer is linux related the topicstarter is clearly using windows.
– Raymond Nijland
Apr 24 '17 at 11:53
3
@RaymondNijland true but this is canonical and I found this question and it saved me after over an hour of troubleshooting.
– Goose
May 5 '17 at 20:57
How and Why: This happens when PHP7 doesn't configure the default fast-CGI service in the make script.sudo a2enmod proxy_fcgi setenvif
creates three new mods/mods-available/proxy.conf proxy_fcgi.load proxy.load
Likewise,sudo a2enconf php7.0-fpm
creates a config file/conf-available/php7.0-fpm.conf
Once this is done and Apache2 can then run the PHP7 module as a fast-CGI service.
– Talvi Watia
Nov 21 '17 at 12:49
1
worked for linux mint
– zzapper
Jan 20 '18 at 23:41
add a comment
|
php7 :
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
sudo service apache2 restart
php7 :
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
sudo service apache2 restart
answered Feb 6 '17 at 15:06
sj59sj59
1,1552 gold badges14 silver badges21 bronze badges
1,1552 gold badges14 silver badges21 bronze badges
16
While this code snippet may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.
– Toby Speight
Feb 6 '17 at 18:31
4
This answer is linux related the topicstarter is clearly using windows.
– Raymond Nijland
Apr 24 '17 at 11:53
3
@RaymondNijland true but this is canonical and I found this question and it saved me after over an hour of troubleshooting.
– Goose
May 5 '17 at 20:57
How and Why: This happens when PHP7 doesn't configure the default fast-CGI service in the make script.sudo a2enmod proxy_fcgi setenvif
creates three new mods/mods-available/proxy.conf proxy_fcgi.load proxy.load
Likewise,sudo a2enconf php7.0-fpm
creates a config file/conf-available/php7.0-fpm.conf
Once this is done and Apache2 can then run the PHP7 module as a fast-CGI service.
– Talvi Watia
Nov 21 '17 at 12:49
1
worked for linux mint
– zzapper
Jan 20 '18 at 23:41
add a comment
|
16
While this code snippet may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.
– Toby Speight
Feb 6 '17 at 18:31
4
This answer is linux related the topicstarter is clearly using windows.
– Raymond Nijland
Apr 24 '17 at 11:53
3
@RaymondNijland true but this is canonical and I found this question and it saved me after over an hour of troubleshooting.
– Goose
May 5 '17 at 20:57
How and Why: This happens when PHP7 doesn't configure the default fast-CGI service in the make script.sudo a2enmod proxy_fcgi setenvif
creates three new mods/mods-available/proxy.conf proxy_fcgi.load proxy.load
Likewise,sudo a2enconf php7.0-fpm
creates a config file/conf-available/php7.0-fpm.conf
Once this is done and Apache2 can then run the PHP7 module as a fast-CGI service.
– Talvi Watia
Nov 21 '17 at 12:49
1
worked for linux mint
– zzapper
Jan 20 '18 at 23:41
16
16
While this code snippet may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.
– Toby Speight
Feb 6 '17 at 18:31
While this code snippet may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.
– Toby Speight
Feb 6 '17 at 18:31
4
4
This answer is linux related the topicstarter is clearly using windows.
– Raymond Nijland
Apr 24 '17 at 11:53
This answer is linux related the topicstarter is clearly using windows.
– Raymond Nijland
Apr 24 '17 at 11:53
3
3
@RaymondNijland true but this is canonical and I found this question and it saved me after over an hour of troubleshooting.
– Goose
May 5 '17 at 20:57
@RaymondNijland true but this is canonical and I found this question and it saved me after over an hour of troubleshooting.
– Goose
May 5 '17 at 20:57
How and Why: This happens when PHP7 doesn't configure the default fast-CGI service in the make script.
sudo a2enmod proxy_fcgi setenvif
creates three new mods /mods-available/proxy.conf proxy_fcgi.load proxy.load
Likewise, sudo a2enconf php7.0-fpm
creates a config file /conf-available/php7.0-fpm.conf
Once this is done and Apache2 can then run the PHP7 module as a fast-CGI service.– Talvi Watia
Nov 21 '17 at 12:49
How and Why: This happens when PHP7 doesn't configure the default fast-CGI service in the make script.
sudo a2enmod proxy_fcgi setenvif
creates three new mods /mods-available/proxy.conf proxy_fcgi.load proxy.load
Likewise, sudo a2enconf php7.0-fpm
creates a config file /conf-available/php7.0-fpm.conf
Once this is done and Apache2 can then run the PHP7 module as a fast-CGI service.– Talvi Watia
Nov 21 '17 at 12:49
1
1
worked for linux mint
– zzapper
Jan 20 '18 at 23:41
worked for linux mint
– zzapper
Jan 20 '18 at 23:41
add a comment
|
I'm running Apache on Ubuntu and my issue was that the /etc/apache2/mods-available/php5.conf
file was missing this:
<FilesMatch ".+.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
I added it back in and php was parsing php files correctly.
add a comment
|
I'm running Apache on Ubuntu and my issue was that the /etc/apache2/mods-available/php5.conf
file was missing this:
<FilesMatch ".+.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
I added it back in and php was parsing php files correctly.
add a comment
|
I'm running Apache on Ubuntu and my issue was that the /etc/apache2/mods-available/php5.conf
file was missing this:
<FilesMatch ".+.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
I added it back in and php was parsing php files correctly.
I'm running Apache on Ubuntu and my issue was that the /etc/apache2/mods-available/php5.conf
file was missing this:
<FilesMatch ".+.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
I added it back in and php was parsing php files correctly.
edited Mar 21 '16 at 14:37
Flow
19.5k12 gold badges83 silver badges131 bronze badges
19.5k12 gold badges83 silver badges131 bronze badges
answered Mar 19 '13 at 13:34
Matt McDonaldMatt McDonald
4306 silver badges5 bronze badges
4306 silver badges5 bronze badges
add a comment
|
add a comment
|
note for php 7 users, add this to your httpd.conf file:
# PHP 7 specific configuration
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
2
Just to help other people with this issue. Thehttpd.conf
file is located in/etc/apache2/httpd.conf
If you're using Ubuntu, it would beapache2.conf
in the same directory that needs to be modified for PHP7.
– Ahmed Sagarwala
Aug 14 '18 at 19:07
add a comment
|
note for php 7 users, add this to your httpd.conf file:
# PHP 7 specific configuration
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
2
Just to help other people with this issue. Thehttpd.conf
file is located in/etc/apache2/httpd.conf
If you're using Ubuntu, it would beapache2.conf
in the same directory that needs to be modified for PHP7.
– Ahmed Sagarwala
Aug 14 '18 at 19:07
add a comment
|
note for php 7 users, add this to your httpd.conf file:
# PHP 7 specific configuration
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
note for php 7 users, add this to your httpd.conf file:
# PHP 7 specific configuration
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
answered Aug 15 '16 at 9:32
EdCEdC
8539 silver badges8 bronze badges
8539 silver badges8 bronze badges
2
Just to help other people with this issue. Thehttpd.conf
file is located in/etc/apache2/httpd.conf
If you're using Ubuntu, it would beapache2.conf
in the same directory that needs to be modified for PHP7.
– Ahmed Sagarwala
Aug 14 '18 at 19:07
add a comment
|
2
Just to help other people with this issue. Thehttpd.conf
file is located in/etc/apache2/httpd.conf
If you're using Ubuntu, it would beapache2.conf
in the same directory that needs to be modified for PHP7.
– Ahmed Sagarwala
Aug 14 '18 at 19:07
2
2
Just to help other people with this issue. The
httpd.conf
file is located in /etc/apache2/httpd.conf
If you're using Ubuntu, it would be apache2.conf
in the same directory that needs to be modified for PHP7.– Ahmed Sagarwala
Aug 14 '18 at 19:07
Just to help other people with this issue. The
httpd.conf
file is located in /etc/apache2/httpd.conf
If you're using Ubuntu, it would be apache2.conf
in the same directory that needs to be modified for PHP7.– Ahmed Sagarwala
Aug 14 '18 at 19:07
add a comment
|
I found another problem causing this issue and already solved it. I accidentally saved my script in UTF-16
encoding. It seems that PHP5 can't recognize <?php
tag in 16 bit encoding by default.
add a comment
|
I found another problem causing this issue and already solved it. I accidentally saved my script in UTF-16
encoding. It seems that PHP5 can't recognize <?php
tag in 16 bit encoding by default.
add a comment
|
I found another problem causing this issue and already solved it. I accidentally saved my script in UTF-16
encoding. It seems that PHP5 can't recognize <?php
tag in 16 bit encoding by default.
I found another problem causing this issue and already solved it. I accidentally saved my script in UTF-16
encoding. It seems that PHP5 can't recognize <?php
tag in 16 bit encoding by default.
answered Apr 4 '13 at 18:17
ArrviArrvi
3993 silver badges12 bronze badges
3993 silver badges12 bronze badges
add a comment
|
add a comment
|
I'm posting this answer because my Virtualmin/Webmin admin interface decided it was a good idea to disable my PHP engine.. took me a while to find the solution, so I thought I'd share it with you guys:
Also, be sure to check that none of your website config files related to this specific host or virtualhost have any php_admin_value's in them that turn off PHP, like this:
php_admin_value engine Off
When in doubt, comment it...
# php_admin_value engine Off
And restart your webserver.
Where are these config settings exactly?
– cronoklee
Jul 27 '16 at 14:43
2
@cronoklee In vHost settings of httpd.conf. For existing hosts, you need to edit apache config in webmin. For future hosts, go to virtualmin > server template > apache website. Eitherway, this is not as secure as fastcgi - virtualmin's default. So the correct approach should be to troubleshoot why fcgi doesn't work, for example it may be caused by file permissions.
– Sheepy
Sep 9 '16 at 3:43
If you're using a version of Apache that doesn't have httpd.conf, look in/etc/apache2/mods-enabled/php7.conf
orphp5.conf
– Sam Malayek
Oct 20 '16 at 22:53
When in doubt about the location of a certain configuration setting, you can always use grep to find what you're looking for by (for example in this case) typing:sudo grep php_admin_value /etc/* -R
– Henry van Megen
May 23 '18 at 11:05
add a comment
|
I'm posting this answer because my Virtualmin/Webmin admin interface decided it was a good idea to disable my PHP engine.. took me a while to find the solution, so I thought I'd share it with you guys:
Also, be sure to check that none of your website config files related to this specific host or virtualhost have any php_admin_value's in them that turn off PHP, like this:
php_admin_value engine Off
When in doubt, comment it...
# php_admin_value engine Off
And restart your webserver.
Where are these config settings exactly?
– cronoklee
Jul 27 '16 at 14:43
2
@cronoklee In vHost settings of httpd.conf. For existing hosts, you need to edit apache config in webmin. For future hosts, go to virtualmin > server template > apache website. Eitherway, this is not as secure as fastcgi - virtualmin's default. So the correct approach should be to troubleshoot why fcgi doesn't work, for example it may be caused by file permissions.
– Sheepy
Sep 9 '16 at 3:43
If you're using a version of Apache that doesn't have httpd.conf, look in/etc/apache2/mods-enabled/php7.conf
orphp5.conf
– Sam Malayek
Oct 20 '16 at 22:53
When in doubt about the location of a certain configuration setting, you can always use grep to find what you're looking for by (for example in this case) typing:sudo grep php_admin_value /etc/* -R
– Henry van Megen
May 23 '18 at 11:05
add a comment
|
I'm posting this answer because my Virtualmin/Webmin admin interface decided it was a good idea to disable my PHP engine.. took me a while to find the solution, so I thought I'd share it with you guys:
Also, be sure to check that none of your website config files related to this specific host or virtualhost have any php_admin_value's in them that turn off PHP, like this:
php_admin_value engine Off
When in doubt, comment it...
# php_admin_value engine Off
And restart your webserver.
I'm posting this answer because my Virtualmin/Webmin admin interface decided it was a good idea to disable my PHP engine.. took me a while to find the solution, so I thought I'd share it with you guys:
Also, be sure to check that none of your website config files related to this specific host or virtualhost have any php_admin_value's in them that turn off PHP, like this:
php_admin_value engine Off
When in doubt, comment it...
# php_admin_value engine Off
And restart your webserver.
answered Oct 15 '13 at 17:58
Henry van MegenHenry van Megen
1,2372 gold badges16 silver badges30 bronze badges
1,2372 gold badges16 silver badges30 bronze badges
Where are these config settings exactly?
– cronoklee
Jul 27 '16 at 14:43
2
@cronoklee In vHost settings of httpd.conf. For existing hosts, you need to edit apache config in webmin. For future hosts, go to virtualmin > server template > apache website. Eitherway, this is not as secure as fastcgi - virtualmin's default. So the correct approach should be to troubleshoot why fcgi doesn't work, for example it may be caused by file permissions.
– Sheepy
Sep 9 '16 at 3:43
If you're using a version of Apache that doesn't have httpd.conf, look in/etc/apache2/mods-enabled/php7.conf
orphp5.conf
– Sam Malayek
Oct 20 '16 at 22:53
When in doubt about the location of a certain configuration setting, you can always use grep to find what you're looking for by (for example in this case) typing:sudo grep php_admin_value /etc/* -R
– Henry van Megen
May 23 '18 at 11:05
add a comment
|
Where are these config settings exactly?
– cronoklee
Jul 27 '16 at 14:43
2
@cronoklee In vHost settings of httpd.conf. For existing hosts, you need to edit apache config in webmin. For future hosts, go to virtualmin > server template > apache website. Eitherway, this is not as secure as fastcgi - virtualmin's default. So the correct approach should be to troubleshoot why fcgi doesn't work, for example it may be caused by file permissions.
– Sheepy
Sep 9 '16 at 3:43
If you're using a version of Apache that doesn't have httpd.conf, look in/etc/apache2/mods-enabled/php7.conf
orphp5.conf
– Sam Malayek
Oct 20 '16 at 22:53
When in doubt about the location of a certain configuration setting, you can always use grep to find what you're looking for by (for example in this case) typing:sudo grep php_admin_value /etc/* -R
– Henry van Megen
May 23 '18 at 11:05
Where are these config settings exactly?
– cronoklee
Jul 27 '16 at 14:43
Where are these config settings exactly?
– cronoklee
Jul 27 '16 at 14:43
2
2
@cronoklee In vHost settings of httpd.conf. For existing hosts, you need to edit apache config in webmin. For future hosts, go to virtualmin > server template > apache website. Eitherway, this is not as secure as fastcgi - virtualmin's default. So the correct approach should be to troubleshoot why fcgi doesn't work, for example it may be caused by file permissions.
– Sheepy
Sep 9 '16 at 3:43
@cronoklee In vHost settings of httpd.conf. For existing hosts, you need to edit apache config in webmin. For future hosts, go to virtualmin > server template > apache website. Eitherway, this is not as secure as fastcgi - virtualmin's default. So the correct approach should be to troubleshoot why fcgi doesn't work, for example it may be caused by file permissions.
– Sheepy
Sep 9 '16 at 3:43
If you're using a version of Apache that doesn't have httpd.conf, look in
/etc/apache2/mods-enabled/php7.conf
or php5.conf
– Sam Malayek
Oct 20 '16 at 22:53
If you're using a version of Apache that doesn't have httpd.conf, look in
/etc/apache2/mods-enabled/php7.conf
or php5.conf
– Sam Malayek
Oct 20 '16 at 22:53
When in doubt about the location of a certain configuration setting, you can always use grep to find what you're looking for by (for example in this case) typing:
sudo grep php_admin_value /etc/* -R
– Henry van Megen
May 23 '18 at 11:05
When in doubt about the location of a certain configuration setting, you can always use grep to find what you're looking for by (for example in this case) typing:
sudo grep php_admin_value /etc/* -R
– Henry van Megen
May 23 '18 at 11:05
add a comment
|
You're just opening your php file into browser. You have to open it using localhost url. if you open a file directly from your directory it will not execute the php code in any case.
use: http://locahost/index.php
or http:127.0.0.1/index.php
Enable php short code. In your case, you are using <?
which is php short code for <?php
. By default php short codes are disabled.
Also use: sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
if you are a ubuntu user.
1
Why is mcrypt required when i'm just including a file? You should noticed that this question is old and the short tags issue was mentioned 16 times, also in the top comment of my question.
– Gui
Dec 6 '16 at 16:20
1
I just share my solution, I was also facing the same error and after executing this command of mcrypt my issue solved. you may also try.
– Hasan Baig
Dec 7 '16 at 7:43
by default php short codes are enabled. short_open_tag=On (Default Value=ON) in php 5.6
– zond
Jan 26 '17 at 13:38
This was my problem, my virtualmin/apache configuration was for 127.0.0.2 but i was putting my external ip address in the browser, i just updated my v/a config and now its working
– Hayden Thring
Jan 15 at 20:14
add a comment
|
You're just opening your php file into browser. You have to open it using localhost url. if you open a file directly from your directory it will not execute the php code in any case.
use: http://locahost/index.php
or http:127.0.0.1/index.php
Enable php short code. In your case, you are using <?
which is php short code for <?php
. By default php short codes are disabled.
Also use: sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
if you are a ubuntu user.
1
Why is mcrypt required when i'm just including a file? You should noticed that this question is old and the short tags issue was mentioned 16 times, also in the top comment of my question.
– Gui
Dec 6 '16 at 16:20
1
I just share my solution, I was also facing the same error and after executing this command of mcrypt my issue solved. you may also try.
– Hasan Baig
Dec 7 '16 at 7:43
by default php short codes are enabled. short_open_tag=On (Default Value=ON) in php 5.6
– zond
Jan 26 '17 at 13:38
This was my problem, my virtualmin/apache configuration was for 127.0.0.2 but i was putting my external ip address in the browser, i just updated my v/a config and now its working
– Hayden Thring
Jan 15 at 20:14
add a comment
|
You're just opening your php file into browser. You have to open it using localhost url. if you open a file directly from your directory it will not execute the php code in any case.
use: http://locahost/index.php
or http:127.0.0.1/index.php
Enable php short code. In your case, you are using <?
which is php short code for <?php
. By default php short codes are disabled.
Also use: sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
if you are a ubuntu user.
You're just opening your php file into browser. You have to open it using localhost url. if you open a file directly from your directory it will not execute the php code in any case.
use: http://locahost/index.php
or http:127.0.0.1/index.php
Enable php short code. In your case, you are using <?
which is php short code for <?php
. By default php short codes are disabled.
Also use: sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
if you are a ubuntu user.
edited Jan 3 at 16:35
isherwood
39.2k14 gold badges88 silver badges118 bronze badges
39.2k14 gold badges88 silver badges118 bronze badges
answered Dec 6 '16 at 13:36
Hasan BaigHasan Baig
3705 silver badges15 bronze badges
3705 silver badges15 bronze badges
1
Why is mcrypt required when i'm just including a file? You should noticed that this question is old and the short tags issue was mentioned 16 times, also in the top comment of my question.
– Gui
Dec 6 '16 at 16:20
1
I just share my solution, I was also facing the same error and after executing this command of mcrypt my issue solved. you may also try.
– Hasan Baig
Dec 7 '16 at 7:43
by default php short codes are enabled. short_open_tag=On (Default Value=ON) in php 5.6
– zond
Jan 26 '17 at 13:38
This was my problem, my virtualmin/apache configuration was for 127.0.0.2 but i was putting my external ip address in the browser, i just updated my v/a config and now its working
– Hayden Thring
Jan 15 at 20:14
add a comment
|
1
Why is mcrypt required when i'm just including a file? You should noticed that this question is old and the short tags issue was mentioned 16 times, also in the top comment of my question.
– Gui
Dec 6 '16 at 16:20
1
I just share my solution, I was also facing the same error and after executing this command of mcrypt my issue solved. you may also try.
– Hasan Baig
Dec 7 '16 at 7:43
by default php short codes are enabled. short_open_tag=On (Default Value=ON) in php 5.6
– zond
Jan 26 '17 at 13:38
This was my problem, my virtualmin/apache configuration was for 127.0.0.2 but i was putting my external ip address in the browser, i just updated my v/a config and now its working
– Hayden Thring
Jan 15 at 20:14
1
1
Why is mcrypt required when i'm just including a file? You should noticed that this question is old and the short tags issue was mentioned 16 times, also in the top comment of my question.
– Gui
Dec 6 '16 at 16:20
Why is mcrypt required when i'm just including a file? You should noticed that this question is old and the short tags issue was mentioned 16 times, also in the top comment of my question.
– Gui
Dec 6 '16 at 16:20
1
1
I just share my solution, I was also facing the same error and after executing this command of mcrypt my issue solved. you may also try.
– Hasan Baig
Dec 7 '16 at 7:43
I just share my solution, I was also facing the same error and after executing this command of mcrypt my issue solved. you may also try.
– Hasan Baig
Dec 7 '16 at 7:43
by default php short codes are enabled. short_open_tag=On (Default Value=ON) in php 5.6
– zond
Jan 26 '17 at 13:38
by default php short codes are enabled. short_open_tag=On (Default Value=ON) in php 5.6
– zond
Jan 26 '17 at 13:38
This was my problem, my virtualmin/apache configuration was for 127.0.0.2 but i was putting my external ip address in the browser, i just updated my v/a config and now its working
– Hayden Thring
Jan 15 at 20:14
This was my problem, my virtualmin/apache configuration was for 127.0.0.2 but i was putting my external ip address in the browser, i just updated my v/a config and now its working
– Hayden Thring
Jan 15 at 20:14
add a comment
|
I know it should sound silly... but seldom it happens.
Check if you are trying to execute php from
**http://localhost/info.php**
and not from
file:///var/www/info.php
ps> you can notice that if you write from shell
php info.php
it answer with the code (it means php functions)..
PHP works fine (checked using command line). but, when I access the file using URL, it shows PHP code.
– muaaz
Jun 17 '15 at 8:08
add a comment
|
I know it should sound silly... but seldom it happens.
Check if you are trying to execute php from
**http://localhost/info.php**
and not from
file:///var/www/info.php
ps> you can notice that if you write from shell
php info.php
it answer with the code (it means php functions)..
PHP works fine (checked using command line). but, when I access the file using URL, it shows PHP code.
– muaaz
Jun 17 '15 at 8:08
add a comment
|
I know it should sound silly... but seldom it happens.
Check if you are trying to execute php from
**http://localhost/info.php**
and not from
file:///var/www/info.php
ps> you can notice that if you write from shell
php info.php
it answer with the code (it means php functions)..
I know it should sound silly... but seldom it happens.
Check if you are trying to execute php from
**http://localhost/info.php**
and not from
file:///var/www/info.php
ps> you can notice that if you write from shell
php info.php
it answer with the code (it means php functions)..
answered Jan 31 '14 at 11:15
user3257072user3257072
911 silver badge1 bronze badge
911 silver badge1 bronze badge
PHP works fine (checked using command line). but, when I access the file using URL, it shows PHP code.
– muaaz
Jun 17 '15 at 8:08
add a comment
|
PHP works fine (checked using command line). but, when I access the file using URL, it shows PHP code.
– muaaz
Jun 17 '15 at 8:08
PHP works fine (checked using command line). but, when I access the file using URL, it shows PHP code.
– muaaz
Jun 17 '15 at 8:08
PHP works fine (checked using command line). but, when I access the file using URL, it shows PHP code.
– muaaz
Jun 17 '15 at 8:08
add a comment
|
This just happened to me again, along with the server downloading html files, rather than processing. I had not use the webserver apache for some time on the computer and meanwhile Ubuntu updated like two more versions from originally installed LTS. Now it is
$ cat /etc/issue
Ubuntu 16.04 LTS
So the php worked after like so:
$ sudo apt-get install lamp-server^
$ sudo a2enmod php7.0
$ sudo service apache2 restart
The webserver was now parsing the php. Maybe now got to update some webs since php7.0 now running where as it was before running php5. Oh well.
2
you just reinstalled entire server..
– RozzA
May 10 '17 at 21:38
add a comment
|
This just happened to me again, along with the server downloading html files, rather than processing. I had not use the webserver apache for some time on the computer and meanwhile Ubuntu updated like two more versions from originally installed LTS. Now it is
$ cat /etc/issue
Ubuntu 16.04 LTS
So the php worked after like so:
$ sudo apt-get install lamp-server^
$ sudo a2enmod php7.0
$ sudo service apache2 restart
The webserver was now parsing the php. Maybe now got to update some webs since php7.0 now running where as it was before running php5. Oh well.
2
you just reinstalled entire server..
– RozzA
May 10 '17 at 21:38
add a comment
|
This just happened to me again, along with the server downloading html files, rather than processing. I had not use the webserver apache for some time on the computer and meanwhile Ubuntu updated like two more versions from originally installed LTS. Now it is
$ cat /etc/issue
Ubuntu 16.04 LTS
So the php worked after like so:
$ sudo apt-get install lamp-server^
$ sudo a2enmod php7.0
$ sudo service apache2 restart
The webserver was now parsing the php. Maybe now got to update some webs since php7.0 now running where as it was before running php5. Oh well.
This just happened to me again, along with the server downloading html files, rather than processing. I had not use the webserver apache for some time on the computer and meanwhile Ubuntu updated like two more versions from originally installed LTS. Now it is
$ cat /etc/issue
Ubuntu 16.04 LTS
So the php worked after like so:
$ sudo apt-get install lamp-server^
$ sudo a2enmod php7.0
$ sudo service apache2 restart
The webserver was now parsing the php. Maybe now got to update some webs since php7.0 now running where as it was before running php5. Oh well.
answered Jun 12 '16 at 11:04
ndasusersndasusers
6295 silver badges12 bronze badges
6295 silver badges12 bronze badges
2
you just reinstalled entire server..
– RozzA
May 10 '17 at 21:38
add a comment
|
2
you just reinstalled entire server..
– RozzA
May 10 '17 at 21:38
2
2
you just reinstalled entire server..
– RozzA
May 10 '17 at 21:38
you just reinstalled entire server..
– RozzA
May 10 '17 at 21:38
add a comment
|
I've solved this by uninstalling XAMPP, and installing WAMP.
Thanks for the help.
I am xampp but it works fine. did you find why it was showing php code @Gui
– Pie
Jun 13 at 18:18
add a comment
|
I've solved this by uninstalling XAMPP, and installing WAMP.
Thanks for the help.
I am xampp but it works fine. did you find why it was showing php code @Gui
– Pie
Jun 13 at 18:18
add a comment
|
I've solved this by uninstalling XAMPP, and installing WAMP.
Thanks for the help.
I've solved this by uninstalling XAMPP, and installing WAMP.
Thanks for the help.
edited Jun 18 '15 at 12:40
Dummy00001
12.9k3 gold badges27 silver badges54 bronze badges
12.9k3 gold badges27 silver badges54 bronze badges
answered Feb 25 '11 at 19:38
GuiGui
3,93510 gold badges35 silver badges51 bronze badges
3,93510 gold badges35 silver badges51 bronze badges
I am xampp but it works fine. did you find why it was showing php code @Gui
– Pie
Jun 13 at 18:18
add a comment
|
I am xampp but it works fine. did you find why it was showing php code @Gui
– Pie
Jun 13 at 18:18
I am xampp but it works fine. did you find why it was showing php code @Gui
– Pie
Jun 13 at 18:18
I am xampp but it works fine. did you find why it was showing php code @Gui
– Pie
Jun 13 at 18:18
add a comment
|
on my ubuntu 14.04, apache 2.4, php 5.5.9 install, I tried with a sample.php on /var/www/html (default document root) and it worked ok.
So the problem was on my Virtual Servers config.
The solution was to include, on the Directory def containing the .php, this line:
php_admin_flag engine on
and where should I add this line in Apache file in httpd.conf of my virtual server? and I am using Webmin
– suresh pareek
Aug 21 '17 at 12:45
add a comment
|
on my ubuntu 14.04, apache 2.4, php 5.5.9 install, I tried with a sample.php on /var/www/html (default document root) and it worked ok.
So the problem was on my Virtual Servers config.
The solution was to include, on the Directory def containing the .php, this line:
php_admin_flag engine on
and where should I add this line in Apache file in httpd.conf of my virtual server? and I am using Webmin
– suresh pareek
Aug 21 '17 at 12:45
add a comment
|
on my ubuntu 14.04, apache 2.4, php 5.5.9 install, I tried with a sample.php on /var/www/html (default document root) and it worked ok.
So the problem was on my Virtual Servers config.
The solution was to include, on the Directory def containing the .php, this line:
php_admin_flag engine on
on my ubuntu 14.04, apache 2.4, php 5.5.9 install, I tried with a sample.php on /var/www/html (default document root) and it worked ok.
So the problem was on my Virtual Servers config.
The solution was to include, on the Directory def containing the .php, this line:
php_admin_flag engine on
edited Mar 29 '16 at 15:29
answered Mar 28 '16 at 19:16
RogelioRogelio
1,7241 gold badge13 silver badges12 bronze badges
1,7241 gold badge13 silver badges12 bronze badges
and where should I add this line in Apache file in httpd.conf of my virtual server? and I am using Webmin
– suresh pareek
Aug 21 '17 at 12:45
add a comment
|
and where should I add this line in Apache file in httpd.conf of my virtual server? and I am using Webmin
– suresh pareek
Aug 21 '17 at 12:45
and where should I add this line in Apache file in httpd.conf of my virtual server? and I am using Webmin
– suresh pareek
Aug 21 '17 at 12:45
and where should I add this line in Apache file in httpd.conf of my virtual server? and I am using Webmin
– suresh pareek
Aug 21 '17 at 12:45
add a comment
|
I faced this issue on php 7.1 that comes with High Sierra (OS X 10.13.5), editing /etc/apache2/httpd.conf
with following changes helped:
Uncomment this line
LoadModule php7_module libexec/apache2/libphp7.so
Paste following at the end
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
Like same can you pls suggest Wamp 3 version same error. There is no /etc/apache2/httpd.conf folder path in wamp 3. @AamirR
– Gem
Jan 9 at 7:00
add a comment
|
I faced this issue on php 7.1 that comes with High Sierra (OS X 10.13.5), editing /etc/apache2/httpd.conf
with following changes helped:
Uncomment this line
LoadModule php7_module libexec/apache2/libphp7.so
Paste following at the end
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
Like same can you pls suggest Wamp 3 version same error. There is no /etc/apache2/httpd.conf folder path in wamp 3. @AamirR
– Gem
Jan 9 at 7:00
add a comment
|
I faced this issue on php 7.1 that comes with High Sierra (OS X 10.13.5), editing /etc/apache2/httpd.conf
with following changes helped:
Uncomment this line
LoadModule php7_module libexec/apache2/libphp7.so
Paste following at the end
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
I faced this issue on php 7.1 that comes with High Sierra (OS X 10.13.5), editing /etc/apache2/httpd.conf
with following changes helped:
Uncomment this line
LoadModule php7_module libexec/apache2/libphp7.so
Paste following at the end
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
answered Jun 8 '18 at 16:49
AamirRAamirR
6,7102 gold badges34 silver badges45 bronze badges
6,7102 gold badges34 silver badges45 bronze badges
Like same can you pls suggest Wamp 3 version same error. There is no /etc/apache2/httpd.conf folder path in wamp 3. @AamirR
– Gem
Jan 9 at 7:00
add a comment
|
Like same can you pls suggest Wamp 3 version same error. There is no /etc/apache2/httpd.conf folder path in wamp 3. @AamirR
– Gem
Jan 9 at 7:00
Like same can you pls suggest Wamp 3 version same error. There is no /etc/apache2/httpd.conf folder path in wamp 3. @AamirR
– Gem
Jan 9 at 7:00
Like same can you pls suggest Wamp 3 version same error. There is no /etc/apache2/httpd.conf folder path in wamp 3. @AamirR
– Gem
Jan 9 at 7:00
add a comment
|
i had similar problem but in my case solution was different.
my file that held php code was called "somename.html"
changed it to "somename.php" worked fine
This also solved it for me. Does anyone know if the sever will execute php in a .html file or does the file ending always have to be changed to .php when there's a line of php to be executed?
– full_prog_full
Nov 10 '16 at 14:42
depends upon the server settings, for most cases php code that existing in anyfile.html will execute. and if it does not, it can be changed, although idk how :P
– Netrus
Dec 4 '16 at 16:49
add a comment
|
i had similar problem but in my case solution was different.
my file that held php code was called "somename.html"
changed it to "somename.php" worked fine
This also solved it for me. Does anyone know if the sever will execute php in a .html file or does the file ending always have to be changed to .php when there's a line of php to be executed?
– full_prog_full
Nov 10 '16 at 14:42
depends upon the server settings, for most cases php code that existing in anyfile.html will execute. and if it does not, it can be changed, although idk how :P
– Netrus
Dec 4 '16 at 16:49
add a comment
|
i had similar problem but in my case solution was different.
my file that held php code was called "somename.html"
changed it to "somename.php" worked fine
i had similar problem but in my case solution was different.
my file that held php code was called "somename.html"
changed it to "somename.php" worked fine
answered Mar 20 '16 at 17:59
NetrusNetrus
6910 bronze badges
6910 bronze badges
This also solved it for me. Does anyone know if the sever will execute php in a .html file or does the file ending always have to be changed to .php when there's a line of php to be executed?
– full_prog_full
Nov 10 '16 at 14:42
depends upon the server settings, for most cases php code that existing in anyfile.html will execute. and if it does not, it can be changed, although idk how :P
– Netrus
Dec 4 '16 at 16:49
add a comment
|
This also solved it for me. Does anyone know if the sever will execute php in a .html file or does the file ending always have to be changed to .php when there's a line of php to be executed?
– full_prog_full
Nov 10 '16 at 14:42
depends upon the server settings, for most cases php code that existing in anyfile.html will execute. and if it does not, it can be changed, although idk how :P
– Netrus
Dec 4 '16 at 16:49
This also solved it for me. Does anyone know if the sever will execute php in a .html file or does the file ending always have to be changed to .php when there's a line of php to be executed?
– full_prog_full
Nov 10 '16 at 14:42
This also solved it for me. Does anyone know if the sever will execute php in a .html file or does the file ending always have to be changed to .php when there's a line of php to be executed?
– full_prog_full
Nov 10 '16 at 14:42
depends upon the server settings, for most cases php code that existing in anyfile.html will execute. and if it does not, it can be changed, although idk how :P
– Netrus
Dec 4 '16 at 16:49
depends upon the server settings, for most cases php code that existing in anyfile.html will execute. and if it does not, it can be changed, although idk how :P
– Netrus
Dec 4 '16 at 16:49
add a comment
|
Check all the packages you have installed for php using:
yum list installed | grep remi
Install all relevant php packages, especially php-devel on your machine.
add a comment
|
Check all the packages you have installed for php using:
yum list installed | grep remi
Install all relevant php packages, especially php-devel on your machine.
add a comment
|
Check all the packages you have installed for php using:
yum list installed | grep remi
Install all relevant php packages, especially php-devel on your machine.
Check all the packages you have installed for php using:
yum list installed | grep remi
Install all relevant php packages, especially php-devel on your machine.
edited Apr 11 '18 at 8:45
Jai Kumar Rajput
2,3952 gold badges24 silver badges46 bronze badges
2,3952 gold badges24 silver badges46 bronze badges
answered Dec 4 '13 at 23:34
Chaitanya ShivadeChaitanya Shivade
6425 silver badges14 bronze badges
6425 silver badges14 bronze badges
add a comment
|
add a comment
|
This was in my .htaccess
DirectoryIndex index.html index.htm
index.html contained PHP code. By default, PHP won't process files with extentions like htm* as PHP code.
You can override this, by adding the following to .htaccess:
<FilesMatch ".+.html$">
SetHandler application/x-httpd-php
</FilesMatch>
add a comment
|
This was in my .htaccess
DirectoryIndex index.html index.htm
index.html contained PHP code. By default, PHP won't process files with extentions like htm* as PHP code.
You can override this, by adding the following to .htaccess:
<FilesMatch ".+.html$">
SetHandler application/x-httpd-php
</FilesMatch>
add a comment
|
This was in my .htaccess
DirectoryIndex index.html index.htm
index.html contained PHP code. By default, PHP won't process files with extentions like htm* as PHP code.
You can override this, by adding the following to .htaccess:
<FilesMatch ".+.html$">
SetHandler application/x-httpd-php
</FilesMatch>
This was in my .htaccess
DirectoryIndex index.html index.htm
index.html contained PHP code. By default, PHP won't process files with extentions like htm* as PHP code.
You can override this, by adding the following to .htaccess:
<FilesMatch ".+.html$">
SetHandler application/x-httpd-php
</FilesMatch>
answered Dec 4 '16 at 13:40
JahmicJahmic
7,0387 gold badges47 silver badges60 bronze badges
7,0387 gold badges47 silver badges60 bronze badges
add a comment
|
add a comment
|
For fresh setup of LAMP running php 7
edit the file /etc/httpd/conf/httpd.conf
Note: make sure to make backup for it before changing anything.
Paste this at the very bottom of the file:
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Then, search for LoadModule and paste the following line:
LoadModule php7_module modules/libphp7.so
This line will simply ask httpd to load the php 7 module
Then restart httpd
add a comment
|
For fresh setup of LAMP running php 7
edit the file /etc/httpd/conf/httpd.conf
Note: make sure to make backup for it before changing anything.
Paste this at the very bottom of the file:
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Then, search for LoadModule and paste the following line:
LoadModule php7_module modules/libphp7.so
This line will simply ask httpd to load the php 7 module
Then restart httpd
add a comment
|
For fresh setup of LAMP running php 7
edit the file /etc/httpd/conf/httpd.conf
Note: make sure to make backup for it before changing anything.
Paste this at the very bottom of the file:
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Then, search for LoadModule and paste the following line:
LoadModule php7_module modules/libphp7.so
This line will simply ask httpd to load the php 7 module
Then restart httpd
For fresh setup of LAMP running php 7
edit the file /etc/httpd/conf/httpd.conf
Note: make sure to make backup for it before changing anything.
Paste this at the very bottom of the file:
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Then, search for LoadModule and paste the following line:
LoadModule php7_module modules/libphp7.so
This line will simply ask httpd to load the php 7 module
Then restart httpd
answered Jun 16 '17 at 3:03
Eric LibayEric Libay
517 bronze badges
517 bronze badges
add a comment
|
add a comment
|
Make sure the script contains
<?php
before the code that should be executed. There should be no space between <?
and php
in this.
add a comment
|
Make sure the script contains
<?php
before the code that should be executed. There should be no space between <?
and php
in this.
add a comment
|
Make sure the script contains
<?php
before the code that should be executed. There should be no space between <?
and php
in this.
Make sure the script contains
<?php
before the code that should be executed. There should be no space between <?
and php
in this.
answered Jun 1 '18 at 4:42
BarmarBarmar
468k38 gold badges289 silver badges392 bronze badges
468k38 gold badges289 silver badges392 bronze badges
add a comment
|
add a comment
|
I think the problem that it is showing code instead of the result is that it is not going to local host . recheck what address u r going in. are u going to a local file directory or to the local host.
from the screenshot u sent it is going to ur computer not to the localhost.
"file:/// " it should be "localhost/"
add a comment
|
I think the problem that it is showing code instead of the result is that it is not going to local host . recheck what address u r going in. are u going to a local file directory or to the local host.
from the screenshot u sent it is going to ur computer not to the localhost.
"file:/// " it should be "localhost/"
add a comment
|
I think the problem that it is showing code instead of the result is that it is not going to local host . recheck what address u r going in. are u going to a local file directory or to the local host.
from the screenshot u sent it is going to ur computer not to the localhost.
"file:/// " it should be "localhost/"
I think the problem that it is showing code instead of the result is that it is not going to local host . recheck what address u r going in. are u going to a local file directory or to the local host.
from the screenshot u sent it is going to ur computer not to the localhost.
"file:/// " it should be "localhost/"
answered May 27 '16 at 1:02
NavNav
419 bronze badges
419 bronze badges
add a comment
|
add a comment
|
Reinstalling the mcrypt
module worked for me.
$sudo apt-get install php5-mcrypt
$sudo php5enmod mcrypt
It honestly did, maybe because I hadn't configured the PHP properly on my system.But, since the question I asked regarding the same issue has been marked as a duplicate to this question, I only could answer it here. I wonder why the down vote.
– b.g
Oct 17 '16 at 13:06
This answer is linux related the topicstarter is clearly using windows
– Raymond Nijland
Apr 24 '17 at 11:55
add a comment
|
Reinstalling the mcrypt
module worked for me.
$sudo apt-get install php5-mcrypt
$sudo php5enmod mcrypt
It honestly did, maybe because I hadn't configured the PHP properly on my system.But, since the question I asked regarding the same issue has been marked as a duplicate to this question, I only could answer it here. I wonder why the down vote.
– b.g
Oct 17 '16 at 13:06
This answer is linux related the topicstarter is clearly using windows
– Raymond Nijland
Apr 24 '17 at 11:55
add a comment
|
Reinstalling the mcrypt
module worked for me.
$sudo apt-get install php5-mcrypt
$sudo php5enmod mcrypt
Reinstalling the mcrypt
module worked for me.
$sudo apt-get install php5-mcrypt
$sudo php5enmod mcrypt
answered Oct 17 '16 at 5:46
b.gb.g
1211 gold badge1 silver badge11 bronze badges
1211 gold badge1 silver badge11 bronze badges
It honestly did, maybe because I hadn't configured the PHP properly on my system.But, since the question I asked regarding the same issue has been marked as a duplicate to this question, I only could answer it here. I wonder why the down vote.
– b.g
Oct 17 '16 at 13:06
This answer is linux related the topicstarter is clearly using windows
– Raymond Nijland
Apr 24 '17 at 11:55
add a comment
|
It honestly did, maybe because I hadn't configured the PHP properly on my system.But, since the question I asked regarding the same issue has been marked as a duplicate to this question, I only could answer it here. I wonder why the down vote.
– b.g
Oct 17 '16 at 13:06
This answer is linux related the topicstarter is clearly using windows
– Raymond Nijland
Apr 24 '17 at 11:55
It honestly did, maybe because I hadn't configured the PHP properly on my system.But, since the question I asked regarding the same issue has been marked as a duplicate to this question, I only could answer it here. I wonder why the down vote.
– b.g
Oct 17 '16 at 13:06
It honestly did, maybe because I hadn't configured the PHP properly on my system.But, since the question I asked regarding the same issue has been marked as a duplicate to this question, I only could answer it here. I wonder why the down vote.
– b.g
Oct 17 '16 at 13:06
This answer is linux related the topicstarter is clearly using windows
– Raymond Nijland
Apr 24 '17 at 11:55
This answer is linux related the topicstarter is clearly using windows
– Raymond Nijland
Apr 24 '17 at 11:55
add a comment
|
I had a case that I accidentally started untaring my files directory in root. It added the .htaccess file from my files folder that would block all php
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
Bottom line check the .htaccess file on root.
add a comment
|
I had a case that I accidentally started untaring my files directory in root. It added the .htaccess file from my files folder that would block all php
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
Bottom line check the .htaccess file on root.
add a comment
|
I had a case that I accidentally started untaring my files directory in root. It added the .htaccess file from my files folder that would block all php
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
Bottom line check the .htaccess file on root.
I had a case that I accidentally started untaring my files directory in root. It added the .htaccess file from my files folder that would block all php
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
Bottom line check the .htaccess file on root.
answered Dec 2 '16 at 23:01
albertskialbertski
1,14811 silver badges30 bronze badges
1,14811 silver badges30 bronze badges
add a comment
|
add a comment
|
If you have configuration like this:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example.com"
<FilesMatch ".php$">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</VirtualHost>
Uncomment next lines in your httpd.conf
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
It works for me
add a comment
|
If you have configuration like this:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example.com"
<FilesMatch ".php$">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</VirtualHost>
Uncomment next lines in your httpd.conf
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
It works for me
add a comment
|
If you have configuration like this:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example.com"
<FilesMatch ".php$">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</VirtualHost>
Uncomment next lines in your httpd.conf
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
It works for me
If you have configuration like this:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example.com"
<FilesMatch ".php$">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</VirtualHost>
Uncomment next lines in your httpd.conf
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
It works for me
answered Feb 27 '18 at 14:21
user3890355user3890355
6038 silver badges12 bronze badges
6038 silver badges12 bronze badges
add a comment
|
add a comment
|
Add AddType application/x-httpd-php .php
to your httpd.conf file if you are using Apache 2.4
add a comment
|
Add AddType application/x-httpd-php .php
to your httpd.conf file if you are using Apache 2.4
add a comment
|
Add AddType application/x-httpd-php .php
to your httpd.conf file if you are using Apache 2.4
Add AddType application/x-httpd-php .php
to your httpd.conf file if you are using Apache 2.4
answered May 4 '18 at 13:56
AshahmaliAshahmali
837 bronze badges
837 bronze badges
add a comment
|
add a comment
|
Just spent hours of trying to get PHP 5 to run with Apache 2.4 on Windows 10. Finally for me it was a typo in httpd.conf LoadModule
. Drew attention to writing and exact module path through the last answer in this apachelounge thread of denny2018. Thank you!
After two nights I discovered... My directory was written
c:
(lower case)
I had LoadModule php5_module "c:/php/php5apache2.dll"
but correct for apache 2.4 is:
LoadModule php5_module "C:/php/php5apache2_4.dll"
So I also missed the _4
before (for apache 2.4). The full snippet that worked for me:
# PHP
LoadModule php5_module "C:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Just tried PHP 7. There the LoadModule
line in httpd.conf for Apache 2.4 reads
LoadModule php7_module "C:/php/php7apache2_4.dll"
Currently php manual shows up c:/php/php5apache2.dll
which of course needs to be adjusted.
add a comment
|
Just spent hours of trying to get PHP 5 to run with Apache 2.4 on Windows 10. Finally for me it was a typo in httpd.conf LoadModule
. Drew attention to writing and exact module path through the last answer in this apachelounge thread of denny2018. Thank you!
After two nights I discovered... My directory was written
c:
(lower case)
I had LoadModule php5_module "c:/php/php5apache2.dll"
but correct for apache 2.4 is:
LoadModule php5_module "C:/php/php5apache2_4.dll"
So I also missed the _4
before (for apache 2.4). The full snippet that worked for me:
# PHP
LoadModule php5_module "C:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Just tried PHP 7. There the LoadModule
line in httpd.conf for Apache 2.4 reads
LoadModule php7_module "C:/php/php7apache2_4.dll"
Currently php manual shows up c:/php/php5apache2.dll
which of course needs to be adjusted.
add a comment
|
Just spent hours of trying to get PHP 5 to run with Apache 2.4 on Windows 10. Finally for me it was a typo in httpd.conf LoadModule
. Drew attention to writing and exact module path through the last answer in this apachelounge thread of denny2018. Thank you!
After two nights I discovered... My directory was written
c:
(lower case)
I had LoadModule php5_module "c:/php/php5apache2.dll"
but correct for apache 2.4 is:
LoadModule php5_module "C:/php/php5apache2_4.dll"
So I also missed the _4
before (for apache 2.4). The full snippet that worked for me:
# PHP
LoadModule php5_module "C:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Just tried PHP 7. There the LoadModule
line in httpd.conf for Apache 2.4 reads
LoadModule php7_module "C:/php/php7apache2_4.dll"
Currently php manual shows up c:/php/php5apache2.dll
which of course needs to be adjusted.
Just spent hours of trying to get PHP 5 to run with Apache 2.4 on Windows 10. Finally for me it was a typo in httpd.conf LoadModule
. Drew attention to writing and exact module path through the last answer in this apachelounge thread of denny2018. Thank you!
After two nights I discovered... My directory was written
c:
(lower case)
I had LoadModule php5_module "c:/php/php5apache2.dll"
but correct for apache 2.4 is:
LoadModule php5_module "C:/php/php5apache2_4.dll"
So I also missed the _4
before (for apache 2.4). The full snippet that worked for me:
# PHP
LoadModule php5_module "C:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Just tried PHP 7. There the LoadModule
line in httpd.conf for Apache 2.4 reads
LoadModule php7_module "C:/php/php7apache2_4.dll"
Currently php manual shows up c:/php/php5apache2.dll
which of course needs to be adjusted.
edited Sep 8 '18 at 13:20
answered Sep 6 '18 at 14:36
bobble bubblebobble bubble
7,8351 gold badge17 silver badges31 bronze badges
7,8351 gold badge17 silver badges31 bronze badges
add a comment
|
add a comment
|
in my case (Apache/2.4.34),
after uncommenting the specific module
"LoadModule php7_module libexec/apache2/libphp7.so"
from
"/etc/apache2/httpd.conf"
my problem was gone.
add a comment
|
in my case (Apache/2.4.34),
after uncommenting the specific module
"LoadModule php7_module libexec/apache2/libphp7.so"
from
"/etc/apache2/httpd.conf"
my problem was gone.
add a comment
|
in my case (Apache/2.4.34),
after uncommenting the specific module
"LoadModule php7_module libexec/apache2/libphp7.so"
from
"/etc/apache2/httpd.conf"
my problem was gone.
in my case (Apache/2.4.34),
after uncommenting the specific module
"LoadModule php7_module libexec/apache2/libphp7.so"
from
"/etc/apache2/httpd.conf"
my problem was gone.
answered Oct 3 '18 at 4:49
sh6210sh6210
1,2981 gold badge15 silver badges12 bronze badges
1,2981 gold badge15 silver badges12 bronze badges
add a comment
|
add a comment
|
the file that you put in /var/www/html/ should have .php
forexample example.php if it is example it is not working but if you change it to example.php it works.
add a comment
|
the file that you put in /var/www/html/ should have .php
forexample example.php if it is example it is not working but if you change it to example.php it works.
add a comment
|
the file that you put in /var/www/html/ should have .php
forexample example.php if it is example it is not working but if you change it to example.php it works.
the file that you put in /var/www/html/ should have .php
forexample example.php if it is example it is not working but if you change it to example.php it works.
answered Apr 28 at 5:47
yasin lachiniyasin lachini
8161 gold badge4 silver badges19 bronze badges
8161 gold badge4 silver badges19 bronze badges
add a comment
|
add a comment
|
protected by Community♦ Jun 10 '15 at 1:01
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
41
Are you using short tags
<?
instead of<?php
?– Dan Grossman
Feb 25 '11 at 19:09
2
Yes, i'm using <? ...
– Gui
Feb 25 '11 at 19:12
25
Don't EVER use short tags. (
<?
). They are deprecated, don't really work in a lot of places, and are otherwise completely unneccessary. Saving three keystrokes is not a valid reason to allow potential for your code to fail on probably half of the servers it may run on.– mopsyd
Feb 11 '15 at 19:53
7
@mopsyd Where does it say that short tags are deprecated? Please note that short tags are not the same as short echo tags, and short echo tags have been supported by default since PHP 5.4, regardless of the
short_open_tag
setting.– Kyle Anderson
Mar 15 '16 at 19:23
2
I am aware that short tags are not short echo tags, which is why I specified which I was talking about in the comment. At the time of writing, short tags were flagged for deprecation for the php 6 release, though that has apparently changed since. The problem still exists that a lot of servers have them disabled, which makes your code significantly less portable. This does not apply to short echo tags (
<?=
), which should run fine on php 5.4+ regardless of server settings.– mopsyd
Mar 18 '16 at 0:44