yum install nginx -y
systemctl start nginx
systemctl enable nginx
systemctl status nginx
nginx -v
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
chown nginx:nginx /usr/share/nginx/html -R
################ MariaDB ##############################
yum install mariadb-server mariadb -y
systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb
mysql_secure_installation
mysql -e "SHOW DATABASES;" -p
################ PHP installation ##########################
yum install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring php-json -y
################### For Specific PHP Version #################
sudo dnf config-manager --set-enabled crb
sudo dnf install epel-release -y
sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-9.rpm
sudo dnf update -y
sudo dnf module list php
sudo dnf -y install yum-utils
sudo dnf module enable php:remi-8.2 -y
########################################################
systemctl start php-fpm
systemctl enable php-fpm
systemctl status php-fpm
vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx
systemctl reload php-fpm
echo "<?php phpinfo() ?>" > /usr/share/nginx/html/info.php
systemctl restart nginx php-fpm
########################################################
Host File
=====================================================
sudo vi /etc/hosts
IP_ADDRESS mt.baycombd.com
chown nginx:nginx /var/www/example.com/public_html -R
echo "<?php phpinfo() ?>" > /var/www/example.com/public_html/info.php
======================================================
Custom Public_html Directory
=====================================================
sudo mkdir -p /var/www/example.com/public_html
sudo chown -R nginx:nginx /var/www/example.com/public_html
sudo chmod -R +x /var/www
sudo chcon -t httpd_sys_content_t /var/www/example.com -R
sudo chcon -t httpd_sys_rw_content_t /var/www/example.com -R
=====================================================
Create Custom Server Block
=====================================================
touch /etc/nginx/conf.d/example.com.conf
# Web root location & port listining
server
{
listen 80;
root /var/www/example.com/public_html;
index index.php index.html index.htm;
server_name example.com www.example.com;
access_log /var/www/example.com/access.log;
error_log /var/www/example.com/error.log;
# Redirect server error pages to the static page
location /
{
try_files $uri $uri/ /index.php;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root /var/www/example.com/public_html;
}
# Pass the PHP scripts to FastCGI server
location ~ \.php$
{
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri =404;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
======================================================
systemctl restart nginx php-fpm
nginx -t