Installing PHP 7.4 Nginx on CentOS8

sudo yum install yum-utils
sudo yum module list php
sudo yum module enable php:remi-7.4

sudo yum install php php-fpm
sudo yum -y install php-fpm php-common php-cli

php -v

sudo systemctl enable php-fpm.service
sudo systemctl start php-fpm.service
sudo systemctl status php-fpm.service
sudo systemctl stop php-fpm.service
sudo systemctl restart php-fpm.service

cat /etc/nginx/conf.d/php-fpm.conf
ls -l /run/php-fpm/www.sock
cat /etc/nginx/default.d/php.conf
sudo systemctl restart nginx.service

sudo dnf -y install nginx
sudo systemctl start nginx
sudo touch /usr/share/nginx/html/hello.php
curl -I http://localhost/hello.php

sudo dnf -y install mariadb-server
sudo systemctl start mariadb
sudo mysql_secure_installation
sudo dnf -y install php-mysqlnd

# password to mysql

sudo mkdir -p /var/www/
sudo chown -R $USER:$USER /var/www/
sudo chmod -R 755 /var/www/
sudo touch /var/www/
sudo vi /etc/nginx/conf.d/

server {
listen 80;
listen [::]:80;

root /var/www/;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
try_files $uri =404;
fastcgi_intercept_errors on;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php-fpm;
access_log /var/log/nginx/;
error_log /var/log/nginx/;

sudo nginx -t
sudo systemctl restart nginx

cd /var/www/
sudo yum -y install wget zip
mv html/ html-
mv wordpress/ html/
cd /var/www/
chown -R nginx:nginx wp-content/
sudo systemctl restart php-fpm
sudo systemctl start nginx
sudo systemctl start mariadb
sudo systemctl restart nginx

# change user from apache to ngnix
sudo vi /etc/php-fpm.d/www.conf
sudo systemctl restart php-fpm

Leave a Reply