在Ubuntu系统中,要在PHP-FPM和Apache之间切换,你需要执行以下步骤:
sudo apt-get update
sudo apt-get install apache2
sudo apt-get install php-fpm
sudo systemctl start apache2
sudo systemctl start php-fpm
/etc/php/7.x/fpm/pool.d/www.conf
文件(将7.x替换为你的PHP版本),找到以下行:;listen = /run/php/php7.x-fpm.sock
取消注释(删除前面的分号)以启用Unix套接字监听:
listen = /run/php/php7.x-fpm.sock
/etc/apache2/mods-enabled/dir.conf
文件,找到以下行:DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
在行尾添加index.php
以确保Apache在处理PHP文件时使用PHP-FPM:
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm index.php
sudo a2dismod php7.x-mod_php
sudo a2enmod proxy_fcgi setenvif
将7.x替换为你的PHP版本。
sudo systemctl restart apache2
现在,Apache应该已经切换到使用PHP-FPM来处理PHP文件了。
如果你想要在PHP-FPM和Apache之间切换回Apache的mod_php模块,只需执行以下步骤:
sudo a2dismod proxy_fcgi setenvif
sudo a2enmod php7.x-mod_php
将7.x替换为你的PHP版本。
sudo systemctl restart apache2
现在,Apache应该已经切换回使用mod_php来处理PHP文件了。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:Ubuntu PHP-FPM与Apache如何配合