0

I have a fresh installation on CentOS 7 with httpd and following remi's wizard I installed php 5.4 as single version (I know it's old, but part of my requirements !!).
My problem is that httpd cannot run php scripts (simple like phpinfo) just as described in this question: PHP not working with Apache on Centos 7
Apart from that problem, things that I find very very strange are:

  • there is no php module in httpd:

httpd -M | grep php shows nothing!! There should be php5_module, or not ??

  • there is no php.conf file in httpd:
[user@pc ~]]$ ls -l /etc/httpd/conf.d/
total 16
-rw-r--r--. 1 root root 2926 Apr  2 16:13 autoindex.conf
-rw-r--r--. 1 root root  366 Apr  2 16:14 README
-rw-r--r--. 1 root root 1252 Nov 27 17:58 userdir.conf
-rw-r--r--. 1 root root  824 Nov 27 17:58 welcome.conf
  • but the same time, php is installed as described (remi-wizard):
[user@pc ~]$ php --version
PHP 5.4.45 (cli) (built: Oct 22 2019 13:26:02)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
  • php packages are there (only those I installed obviously) :
[user@pc ~]$ rpm -qa 'php*' | sort
php-cli-5.4.45-18.el7.remi.x86_64
php-common-5.4.45-18.el7.remi.x86_64

Similar question I found here and the provided solution is installation of mod_php. Sounds right... but here comes my other question: when attempting yum install mod_php the system prompts me for php installation (though I have it installed) !!

sudo yum install mod_php
...
--> Running transaction check
---> Package php.x86_64 0:5.4.45-18.el7.remi will be installed
--> Finished Dependency Resolution

(it's the same with)

sudo yum install php
...
--> Running transaction check
---> Package php.x86_64 0:5.4.45-18.el7.remi will be installed
--> Finished Dependency Resolution

Am I doing something wrong here or missing something ??

2

You have php-cli and php-common packages installed. That means you've installed only cli version. Cli (console) version is the one you run with php command from shell. Those packages don't provide apache module that's why you don't see it.

While sudo yum install php (or outdated mod_php, which is now an alias only) offers you to install php package, which does includes shared apache module & config.

So your assumption "(though I have it installed) " is not quite correct. Just do sudo yum install php and accept all packages it wants to install and you'll be fine.

| improve this answer | |
  • But, having php-cli doesn't imply that php is installed ? In fact, in remi wizard, after enabling remi-php54, the instructions says yum update and after that "install php additional packages" ? I thought php was there already!! Isn't that misleading ? – alexxtasi May 8 at 22:32
  • @alexxtasi no, php-cli doesn't implies that php are installed. Those are separate packages. Just install php package and do rpm -qa 'php*' | sort again to see this. And remi instructions just offers a way to update packages you have installed already, it doesn't offers a way to install new packages. So if you didn't had php installed before it simply won't appears. – NStorm May 8 at 23:10
  • With "php-cli", you have php command installed, and there is various other ways to use PHP (SAPI), pdbg, cgi, fpm, mod_php..., so you "really" need to install what you need, as for extension, only a mininal set is installed, so you have to install each one you need (mbstring, intl, zip, json...) – Remi Collet May 9 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.