When that installation completes, start and enable PHP with the commands:
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
https://www.opencli.com/linux/redhat-centos-8-setup-apache-mariadb-php
https://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-install-linux-apache-mariadb-php-lamp-stack-on-rhel-8.html
跟以往不同, 在 RHEL 8 / CentOS 8 的 Apache, 預設不會使用 mod_php 執行 PHP, 而會預設使用 PHP-FPM 執行 PHP, 所以需要啟動 PHP-FPM:
# systemctl start php-fpm
# systemctl enable php-fpm
安裝及設定好 PHP 後需要重新啟動 Apache 才會生效:
# systemctl restart httpd
另外也需要執行以下指令, 讓 SELinux 允許 Apache 透過 PHP-FPM 執行 PHP 程式碼:
# setsebool -P httpd_execmem 1
要測試 PHP, 可以放一個簡單的 PHP Script 到 Apache DocumentRoot 目錄, 預設是 /var/www/html/, 執行以下指令:
# vi /var/www/html/info.php
然後輸入以下幾行程式碼:
phpinfo();
?>
https://www.opencli.com/linux/redhat-centos-8-setup-apache-mariadb-php
|