PHP script not executing on Apache server
I have just reinstalled Apache and PHP5 but when I visit my doc root it just downloads a "download" file. And when I try documentroot/index.php it just downloads the PHP file.
I have PHP installed but Apache doesn't seem to want to execute it.
People suggested adding a 'Load Module' line to my httpd.conf
but I don't have that file.
apache2 php
add a comment |
I have just reinstalled Apache and PHP5 but when I visit my doc root it just downloads a "download" file. And when I try documentroot/index.php it just downloads the PHP file.
I have PHP installed but Apache doesn't seem to want to execute it.
People suggested adding a 'Load Module' line to my httpd.conf
but I don't have that file.
apache2 php
add a comment |
I have just reinstalled Apache and PHP5 but when I visit my doc root it just downloads a "download" file. And when I try documentroot/index.php it just downloads the PHP file.
I have PHP installed but Apache doesn't seem to want to execute it.
People suggested adding a 'Load Module' line to my httpd.conf
but I don't have that file.
apache2 php
I have just reinstalled Apache and PHP5 but when I visit my doc root it just downloads a "download" file. And when I try documentroot/index.php it just downloads the PHP file.
I have PHP installed but Apache doesn't seem to want to execute it.
People suggested adding a 'Load Module' line to my httpd.conf
but I don't have that file.
apache2 php
apache2 php
edited Nov 5 at 14:48
Yufenyuy Veyeh Dider
1,5254924
1,5254924
asked Apr 20 '14 at 23:46
user2919631
410265
410265
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
Typing:
sudo apt-get install apache2 php5 libapache2-mod-php5
will install everything you need and will start the apache server with support for PHP.
To verify that the php module is loaded, type:
a2query -m php5
if not enabled, then load with:
sudo a2enmod php5
and restart apache:
sudo service apache2 restart
Update for php7.0, tested on Ubuntu 16.04 and 16.10
Thanks to the comments, I update the answer for php7.
Install:
sudo apt-get install apache2 php7.0 libapache2-mod-php7.0
Verify:
a2query -m php7.0
Load:
sudo a2enmod php7.0
Restart apache:
sudo service apache2 restart
It would be better to usea2enmod
than to copy the file manually between mods-available and mods-enabled.a2enmod
creates a symlink and so you'll only have one copy of the configuration.
– jkt123
Apr 21 '14 at 2:17
@jkt123 you're right. thanks for the advice, i edit my answer.
– girardengo
Apr 21 '14 at 8:20
In my case, it says "ERROR:module php5 does not exist!" it is installed
– Marian Klühspies
Mar 8 '15 at 2:07
3
for ubuntu 16.04 with php7 I have executed these commands in orderapt-get install libapache2-mod-php
,a2query -m php7.0
,service apache2 restart
– marlo
Jun 9 '16 at 10:24
For ubuntu 14.04 : # a2query -m php7.0 php7.0 (enabled by site administrator) Still php code is not executing
– Ashish Karpe
Oct 25 '16 at 12:57
|
show 3 more comments
Another common cause is that php short tags <?
are not enabled by the default php.ini configuration, so after an upgrade or reinstall, that setting may be turned off and php code may depend on it. Try replacing <?
with <?php
.
(Credit)
add a comment |
Ubuntu 16.04 has moved to PHP 7. This single command will do the job for you:
sudo apt-get install apache2 php libapache2-mod-php
Here libapache2-mod-php
is a meta-package that installs libapache2-mod-php7.
add a comment |
Open php.ini
with nano
in terminal:
sudo nano /etc/php/php5.6/apache2/php.ini
Then change:
short_open_tag = Off
to
short_open_tag = On
Then save and then restart apache2:
sudo systemctl restart apache2
Or fix the PHP scripts :-)This directive determines whether or not PHP will recognize code between <? and ?> tags as PHP source which should be processed as such. It is generally recommended that <?php and ?> should be used and that this feature should be disabled [...]
– Nicolas Raoul
May 17 at 3:39
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f451708%2fphp-script-not-executing-on-apache-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Typing:
sudo apt-get install apache2 php5 libapache2-mod-php5
will install everything you need and will start the apache server with support for PHP.
To verify that the php module is loaded, type:
a2query -m php5
if not enabled, then load with:
sudo a2enmod php5
and restart apache:
sudo service apache2 restart
Update for php7.0, tested on Ubuntu 16.04 and 16.10
Thanks to the comments, I update the answer for php7.
Install:
sudo apt-get install apache2 php7.0 libapache2-mod-php7.0
Verify:
a2query -m php7.0
Load:
sudo a2enmod php7.0
Restart apache:
sudo service apache2 restart
It would be better to usea2enmod
than to copy the file manually between mods-available and mods-enabled.a2enmod
creates a symlink and so you'll only have one copy of the configuration.
– jkt123
Apr 21 '14 at 2:17
@jkt123 you're right. thanks for the advice, i edit my answer.
– girardengo
Apr 21 '14 at 8:20
In my case, it says "ERROR:module php5 does not exist!" it is installed
– Marian Klühspies
Mar 8 '15 at 2:07
3
for ubuntu 16.04 with php7 I have executed these commands in orderapt-get install libapache2-mod-php
,a2query -m php7.0
,service apache2 restart
– marlo
Jun 9 '16 at 10:24
For ubuntu 14.04 : # a2query -m php7.0 php7.0 (enabled by site administrator) Still php code is not executing
– Ashish Karpe
Oct 25 '16 at 12:57
|
show 3 more comments
Typing:
sudo apt-get install apache2 php5 libapache2-mod-php5
will install everything you need and will start the apache server with support for PHP.
To verify that the php module is loaded, type:
a2query -m php5
if not enabled, then load with:
sudo a2enmod php5
and restart apache:
sudo service apache2 restart
Update for php7.0, tested on Ubuntu 16.04 and 16.10
Thanks to the comments, I update the answer for php7.
Install:
sudo apt-get install apache2 php7.0 libapache2-mod-php7.0
Verify:
a2query -m php7.0
Load:
sudo a2enmod php7.0
Restart apache:
sudo service apache2 restart
It would be better to usea2enmod
than to copy the file manually between mods-available and mods-enabled.a2enmod
creates a symlink and so you'll only have one copy of the configuration.
– jkt123
Apr 21 '14 at 2:17
@jkt123 you're right. thanks for the advice, i edit my answer.
– girardengo
Apr 21 '14 at 8:20
In my case, it says "ERROR:module php5 does not exist!" it is installed
– Marian Klühspies
Mar 8 '15 at 2:07
3
for ubuntu 16.04 with php7 I have executed these commands in orderapt-get install libapache2-mod-php
,a2query -m php7.0
,service apache2 restart
– marlo
Jun 9 '16 at 10:24
For ubuntu 14.04 : # a2query -m php7.0 php7.0 (enabled by site administrator) Still php code is not executing
– Ashish Karpe
Oct 25 '16 at 12:57
|
show 3 more comments
Typing:
sudo apt-get install apache2 php5 libapache2-mod-php5
will install everything you need and will start the apache server with support for PHP.
To verify that the php module is loaded, type:
a2query -m php5
if not enabled, then load with:
sudo a2enmod php5
and restart apache:
sudo service apache2 restart
Update for php7.0, tested on Ubuntu 16.04 and 16.10
Thanks to the comments, I update the answer for php7.
Install:
sudo apt-get install apache2 php7.0 libapache2-mod-php7.0
Verify:
a2query -m php7.0
Load:
sudo a2enmod php7.0
Restart apache:
sudo service apache2 restart
Typing:
sudo apt-get install apache2 php5 libapache2-mod-php5
will install everything you need and will start the apache server with support for PHP.
To verify that the php module is loaded, type:
a2query -m php5
if not enabled, then load with:
sudo a2enmod php5
and restart apache:
sudo service apache2 restart
Update for php7.0, tested on Ubuntu 16.04 and 16.10
Thanks to the comments, I update the answer for php7.
Install:
sudo apt-get install apache2 php7.0 libapache2-mod-php7.0
Verify:
a2query -m php7.0
Load:
sudo a2enmod php7.0
Restart apache:
sudo service apache2 restart
edited Oct 20 '16 at 10:21
answered Apr 21 '14 at 1:02
girardengo
3,7421526
3,7421526
It would be better to usea2enmod
than to copy the file manually between mods-available and mods-enabled.a2enmod
creates a symlink and so you'll only have one copy of the configuration.
– jkt123
Apr 21 '14 at 2:17
@jkt123 you're right. thanks for the advice, i edit my answer.
– girardengo
Apr 21 '14 at 8:20
In my case, it says "ERROR:module php5 does not exist!" it is installed
– Marian Klühspies
Mar 8 '15 at 2:07
3
for ubuntu 16.04 with php7 I have executed these commands in orderapt-get install libapache2-mod-php
,a2query -m php7.0
,service apache2 restart
– marlo
Jun 9 '16 at 10:24
For ubuntu 14.04 : # a2query -m php7.0 php7.0 (enabled by site administrator) Still php code is not executing
– Ashish Karpe
Oct 25 '16 at 12:57
|
show 3 more comments
It would be better to usea2enmod
than to copy the file manually between mods-available and mods-enabled.a2enmod
creates a symlink and so you'll only have one copy of the configuration.
– jkt123
Apr 21 '14 at 2:17
@jkt123 you're right. thanks for the advice, i edit my answer.
– girardengo
Apr 21 '14 at 8:20
In my case, it says "ERROR:module php5 does not exist!" it is installed
– Marian Klühspies
Mar 8 '15 at 2:07
3
for ubuntu 16.04 with php7 I have executed these commands in orderapt-get install libapache2-mod-php
,a2query -m php7.0
,service apache2 restart
– marlo
Jun 9 '16 at 10:24
For ubuntu 14.04 : # a2query -m php7.0 php7.0 (enabled by site administrator) Still php code is not executing
– Ashish Karpe
Oct 25 '16 at 12:57
It would be better to use
a2enmod
than to copy the file manually between mods-available and mods-enabled. a2enmod
creates a symlink and so you'll only have one copy of the configuration.– jkt123
Apr 21 '14 at 2:17
It would be better to use
a2enmod
than to copy the file manually between mods-available and mods-enabled. a2enmod
creates a symlink and so you'll only have one copy of the configuration.– jkt123
Apr 21 '14 at 2:17
@jkt123 you're right. thanks for the advice, i edit my answer.
– girardengo
Apr 21 '14 at 8:20
@jkt123 you're right. thanks for the advice, i edit my answer.
– girardengo
Apr 21 '14 at 8:20
In my case, it says "ERROR:module php5 does not exist!" it is installed
– Marian Klühspies
Mar 8 '15 at 2:07
In my case, it says "ERROR:module php5 does not exist!" it is installed
– Marian Klühspies
Mar 8 '15 at 2:07
3
3
for ubuntu 16.04 with php7 I have executed these commands in order
apt-get install libapache2-mod-php
, a2query -m php7.0
, service apache2 restart
– marlo
Jun 9 '16 at 10:24
for ubuntu 16.04 with php7 I have executed these commands in order
apt-get install libapache2-mod-php
, a2query -m php7.0
, service apache2 restart
– marlo
Jun 9 '16 at 10:24
For ubuntu 14.04 : # a2query -m php7.0 php7.0 (enabled by site administrator) Still php code is not executing
– Ashish Karpe
Oct 25 '16 at 12:57
For ubuntu 14.04 : # a2query -m php7.0 php7.0 (enabled by site administrator) Still php code is not executing
– Ashish Karpe
Oct 25 '16 at 12:57
|
show 3 more comments
Another common cause is that php short tags <?
are not enabled by the default php.ini configuration, so after an upgrade or reinstall, that setting may be turned off and php code may depend on it. Try replacing <?
with <?php
.
(Credit)
add a comment |
Another common cause is that php short tags <?
are not enabled by the default php.ini configuration, so after an upgrade or reinstall, that setting may be turned off and php code may depend on it. Try replacing <?
with <?php
.
(Credit)
add a comment |
Another common cause is that php short tags <?
are not enabled by the default php.ini configuration, so after an upgrade or reinstall, that setting may be turned off and php code may depend on it. Try replacing <?
with <?php
.
(Credit)
Another common cause is that php short tags <?
are not enabled by the default php.ini configuration, so after an upgrade or reinstall, that setting may be turned off and php code may depend on it. Try replacing <?
with <?php
.
(Credit)
edited May 23 '17 at 12:39
Community♦
1
1
answered Apr 15 '15 at 13:48
tufelkinder
27123
27123
add a comment |
add a comment |
Ubuntu 16.04 has moved to PHP 7. This single command will do the job for you:
sudo apt-get install apache2 php libapache2-mod-php
Here libapache2-mod-php
is a meta-package that installs libapache2-mod-php7.
add a comment |
Ubuntu 16.04 has moved to PHP 7. This single command will do the job for you:
sudo apt-get install apache2 php libapache2-mod-php
Here libapache2-mod-php
is a meta-package that installs libapache2-mod-php7.
add a comment |
Ubuntu 16.04 has moved to PHP 7. This single command will do the job for you:
sudo apt-get install apache2 php libapache2-mod-php
Here libapache2-mod-php
is a meta-package that installs libapache2-mod-php7.
Ubuntu 16.04 has moved to PHP 7. This single command will do the job for you:
sudo apt-get install apache2 php libapache2-mod-php
Here libapache2-mod-php
is a meta-package that installs libapache2-mod-php7.
edited Mar 4 '17 at 5:58
answered Oct 16 '16 at 7:47
daltonfury42
3,32222052
3,32222052
add a comment |
add a comment |
Open php.ini
with nano
in terminal:
sudo nano /etc/php/php5.6/apache2/php.ini
Then change:
short_open_tag = Off
to
short_open_tag = On
Then save and then restart apache2:
sudo systemctl restart apache2
Or fix the PHP scripts :-)This directive determines whether or not PHP will recognize code between <? and ?> tags as PHP source which should be processed as such. It is generally recommended that <?php and ?> should be used and that this feature should be disabled [...]
– Nicolas Raoul
May 17 at 3:39
add a comment |
Open php.ini
with nano
in terminal:
sudo nano /etc/php/php5.6/apache2/php.ini
Then change:
short_open_tag = Off
to
short_open_tag = On
Then save and then restart apache2:
sudo systemctl restart apache2
Or fix the PHP scripts :-)This directive determines whether or not PHP will recognize code between <? and ?> tags as PHP source which should be processed as such. It is generally recommended that <?php and ?> should be used and that this feature should be disabled [...]
– Nicolas Raoul
May 17 at 3:39
add a comment |
Open php.ini
with nano
in terminal:
sudo nano /etc/php/php5.6/apache2/php.ini
Then change:
short_open_tag = Off
to
short_open_tag = On
Then save and then restart apache2:
sudo systemctl restart apache2
Open php.ini
with nano
in terminal:
sudo nano /etc/php/php5.6/apache2/php.ini
Then change:
short_open_tag = Off
to
short_open_tag = On
Then save and then restart apache2:
sudo systemctl restart apache2
edited Sep 29 '17 at 10:40
Benny
3,11411026
3,11411026
answered Sep 29 '17 at 4:52
Satrio Prasojo
211
211
Or fix the PHP scripts :-)This directive determines whether or not PHP will recognize code between <? and ?> tags as PHP source which should be processed as such. It is generally recommended that <?php and ?> should be used and that this feature should be disabled [...]
– Nicolas Raoul
May 17 at 3:39
add a comment |
Or fix the PHP scripts :-)This directive determines whether or not PHP will recognize code between <? and ?> tags as PHP source which should be processed as such. It is generally recommended that <?php and ?> should be used and that this feature should be disabled [...]
– Nicolas Raoul
May 17 at 3:39
Or fix the PHP scripts :-)
This directive determines whether or not PHP will recognize code between <? and ?> tags as PHP source which should be processed as such. It is generally recommended that <?php and ?> should be used and that this feature should be disabled [...]
– Nicolas Raoul
May 17 at 3:39
Or fix the PHP scripts :-)
This directive determines whether or not PHP will recognize code between <? and ?> tags as PHP source which should be processed as such. It is generally recommended that <?php and ?> should be used and that this feature should be disabled [...]
– Nicolas Raoul
May 17 at 3:39
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f451708%2fphp-script-not-executing-on-apache-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown