Installing PHP 7.4 Nginx on CentOS8

sudo yum install yum-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
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/mysite.com/html
sudo chown -R $USER:$USER /var/www/mysite.com/html
sudo chmod -R 755 /var/www/mysite.com/html
sudo touch /var/www/mysite.com/html/index.html
sudo vi /etc/nginx/conf.d/mysite.com.conf

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

root /var/www/mysite.com/html;
index index.php index.html index.htm;
server_name mysite.com www.mysite.com;

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/mysite.com.access.log;
error_log /var/log/nginx/mysite.com.error.log;
}

sudo nginx -t
sudo systemctl restart nginx

cd /var/www/mysite.com/
ls
sudo yum -y install wget zip
wget https://wordpress.org/latest.zip
unzip latest.zip
mv html/ html-
mv wordpress/ html/
cd /var/www/mysite.com/
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