如何关闭php-fpm并在Apache Web服务器上改用常规php?

huangapple go评论68阅读模式
英文:

How to turn off php-fpm and use regular php instead on Apache web server?

问题

我正在设置一个新的Web LAMP VPS,它默认配置了默认设置的php-fpm,而我长时间以来一直在使用常规的php,对php-fpm不太熟悉,所以我想知道是否可以禁用php-fpm并切换到常规的php。

所以问题是,通过SSH终端,如何在不卸载它的情况下禁用php-fpm并切换到常规php?

服务器正在使用Ubuntu 22.04、PHP 8.2.6、Apache 2.4.52和MariaDB 10。

我运行了php -v命令,输出如下:

PHP 8.2.6(cli)(构建时间:2023年5月12日06:24:00)(NTS)
版权所有(c)PHP组
Zend引擎v4.2.6,版权所有(c)Zend Technologies
使用Zend Technologies的Zend OPcache v8.2.6版权所有(c)
使用Derick Rethans的Xdebug v3.2.0版权所有(c)2002-2022年

另外,php-fpm是php的一部分,对吗?我假设常规的php已经安装好了,因为fpm是可用的,所以我不需要安装其他东西来切换,对吗?

更新:为了更清楚地阐述问题。我正在使用LAMP服务器来托管WordPress网站,我想禁用php-fpm以使用常规的PHP,这样我就不必更改虚拟主机文件或配置www-fpm。

英文:

I'm setting up a new web LAMP VPS that happened to include php-fpm configured by default with the default settings and I've been using regular php for a long time, and I'm not familiar with php-fpm, so I'm wondering if it's possible to disable php-fpm and switch to regular php.

So the question is, using the terminal via SSH, how to disable php-fpm without uninstalling it and switching to regular php?

The server is using Ubuntu 22.04, PHP 8.2.6, Apache 2.4.52, and MariaDB 10.

I have run the php -v command, and the output was:

PHP 8.2.6 (cli) (built: May 12 2023 06:24:00) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.6, Copyright (c) Zend Technologies
with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies
with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans

Also, is php-fpm part of php, right? I'm assuming that the regular php is already installed since fpm is available, so I don't have to install anything else to switch, correct?

Update: To add a little more clarity to the question. I'm a LAMP server to host a WordPress site, and I want to disable php-fpm to use the regular PHP so I don't have to change the virtual host files or configure the www-fpm.

答案1

得分: 1

有4种不同的方式,我知道可以将PHP与Apache集成 - 我不知道你指的其他3种中哪一种是"常规PHP"。但是,既然你在谈论WordPress,我认为你可能不会喜欢CGI/suPHP的性能,这只留下了mod_php。

虽然mod_php在性能上略微有优势于php-fpm,但它会显著影响服务器的容量(特别是如果你不知道如何进行调整)。它还可以避免Apache和PHP扩展中的MPM模块之间的任何冲突。这引出了一个问题,你希望通过这样做实现什么?

我不必搞虚拟主机配置和www.conf配置。

但你说它是预配置的?

首先,检查你的Apache httpd是否以预分叉方式运行。如果不是,你需要更改它。接下来,检查Apache/PHP堆栈是否通过apt安装 - 如果没有,那么你需要手动解开它。由于(我相信)mod_php不再在标准的Ubuntu存储库中可用,你需要获取相关的软件 - 添加一个PPA比使用tar文件更明智。然后卸载php-fpm包并安装mod_php包。

撇开性能特性的变化不谈,mod_php会给你带来比继续使用PHP-FPM更多的工作。

英文:

There are 4 different ways I know of to integrate PHP with Apache - I don't which of the other 3 you refer to as "regular PHP". However since you're talking about WordPress, then I don't think you'd like the performance of CGI / suPHP, which just leaves mod_php.

While mod_php has a very slight performance advantage of php-fpm, it significantly impacts the capacity of your server (particularly if you don't know how to tune it). It also avoids any conflicts between the MPM modules in your Apache and your PHP extensions. Which rather begs the question what do you expect to achieve by doing this?

> I don't have to mess with the virtual host configuration and www.conf configuration.

But you said it came pre-configured?

First check that your Apache httpd is running as pre-fork. If not you'll need to change that. Next, check if the Apache/PHP stack is installed via apt - if it's not, then you'll need to unpick it all manually. Since (I believe) mod_php is no longer available in the standard Ubuntu repos you'll need to source the relevant software - adding a PPA would be more sensible than using tarballs. Then uninstall the php-fpm package and install the mod_php package.

Leaving aside the changes to the performance characteristics, mod_php is going to create a LOT more work for you than sticking with PHP_FPM.

答案2

得分: 0

之前在PHP-FPM出现之前,PHP通常作为Apache本身的一个模块运行,称为mod_php。这种方法在PHP 5之前很常见,但PHP-FPM的引入导致了显著的性能改进,使其成为首选选择。

然而,这仍然可以与Apache 2一起使用,如php.net中所记录的。

虽然这是可能的,请注意,在与WordPress配对时,php-fpm没有造成任何问题,并且问题可能存在于其他地方。

英文:

While it may be that your problem lies somewhere other than with PHP-FPM, it is noteworthy that previous to PHP-FPM, PHP would run as a module to Apache itself known as mod_php.
This approach was common up until PHP 5 but the introduction of PHP-FPM resulted in significant performance improvements, making it a preferred choice.

However, this is still a possibility to use with Apache 2, as documented in php.net.

While this is possible, please note that php-fpm is not known to cause any issues when paired with WordPress, and that the problem may exist elsewhere.

huangapple
  • 本文由 发表于 2023年6月5日 19:15:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76405878.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定