PHP not executing

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm running Ubuntu 14.04 with Apache2 and PHP7.

For some reason,probably after I updated the PHP version,it is no longer executing. This is the output of

php -v:

PHP 7.0.8-3+deb.sury.org~trusty+1 (cli) ( NTS ) Copyright (c)
1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016
Zend Technologies with Zend OPcache v7.0.8-3+deb.sury.org~trusty+1,
Copyright (c) 1999-2016, by Zend Technologies

The root folder is /var/www/html

The PHP.conf is configured correctly,I believe.

When I add

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps 

And try to load a PHP script then it gets downloaded and not loaded in the browser.

Any ideas?

I appreciate it!

profilepic.png
manpreet 2 years ago

You should be able to fix your problem by running the following commands

sudo apt-get install libapache2-mod-php7.0
sudo a2dismod php*
sudo a2enmod php7.0
sudo apache2ctl restart

After adding Ondrej's repository, installing PHP 7 may not be enough as you will also need to install and enable Apache's PHP module for the version of PHP you need.

This may be reason why PHP works in CLI mode, but not with Apache.

Note: I haven't tested sudo a2dismod php* on Ubuntu 14.04, but in case it doesn't work, just type sudo a2dismod php and tap the tab button so php auto-completes to whichever PHP version is enabled.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community