Score:0

How to install PHP on CentOS has preinstalled Apache HTTPD?

pk flag

I'm using CentOS 7. I wanted to install PHP 7 so I used remi-php (latest PHP version of yum is 5.4). Since the HTTPD version of yum is too old, I compiled the latest HTTPD version from the source code.

HTTPD compilation goes perfectly, however, when I try to install remi-php using the following command:

yum --enablerepo=remi-php71 install php php-cli php-intl php-mbstring php-mcrypt php-mysqlnd

To install php, yum will also install the old version of httpd (although I have compiled and used the latest HTTPD version). If I continue with the installation, my HTTPD will throw an error (and won't start), but if I don't continue with the installation, I won't have the php*.so file and apache won't parse the .php files.

So, how do I install php without affecting the Apache HTTPD that I have compiled before? I don't want my server to have two instances of Apache HTTPD at the same time and may have problems in the future.

Your answer given will be very helpful to me.

I will appreciate your answer.

Michael Hampton avatar
cz flag
Why are you using CentOS 7?!
Tần Quảng avatar
pk flag
@MichaelHampton I'm used to using CentOS 7 and my server provider only supports CentOS 6 and 7.
Michael Hampton avatar
cz flag
You definitely need a new provider then, and CentOS 8. It's crazy to keep using CentOS 7 for web sites these days.
Tần Quảng avatar
pk flag
@MichaelHampton They provide servers with huge resources and very cheap prices. I see no problem with CentOS 7.
Michael Hampton avatar
cz flag
You are already having the problem with CentOS 7!
Score:2
jp flag

"mod_php" (the main "php" package) is build with system httpd, so cannot be installed without it.

Using FPM (php-fpm) you can use any webserver.

I recommend you read PHP Configuration Tips which explain how to switch to FPM, and why it is better.

Notice:

  • httpd 2.4 in CentOS 7 is maintained and have all security fixes, see Backporting Security Fixes
  • More recent version is also available, with new features in the httpd24 Software Collections, maintain by the SCLo SIG from RHSCL.
  • httpd 2.4 in CentOS 8 is also more recent (and use FPM by default)
Tần Quảng avatar
pk flag
httpd version on centos 7 when using my `yum` is 2.4.6-97 and php is 5.4.16-48. Do you think it's safe?
Remi Collet avatar
jp flag
safe, yes. Updating to a new version is only mandatory if you need new features.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.