Monday, February 20, 2023

How to Install Nginx, MariaDB, PHP and Create Virtual Server Block with Nginx on AlmaLinux 8

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

Sunday, February 19, 2023

503 Service Unavailable : PHP-FPM issue

Error: 503 Service Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Solution: 

systemctl start php80-php-fpm (if face the error follow the next command )

systemctl status php80-php-fpm.service

ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)

netstat -tulpn | grep -w 9000 

tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      884/php-fpm: master 

kill 884

systemctl start php80-php-fpm


Note: Use your PHP version, PID and Port in the command. if netstat not works install net-tools first: yum install net-tools

How to Install PHP 8.0/8.1on Linux Centos 7

Method-1 for PHP 8.0

Remi Repository
# yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

PHP 8.0 install
# yum install -y --enablerepo=remi-php80 php php-cli

Exntesions:
#yum install -y --enablerepo=remi-php80 php-mysqlnd

Method-1 for PHP 8.1

yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --disable 'remi-php*'
yum-config-manager --enable remi-php81
yum repolist
yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json,opcache,redis,memcache}

Thursday, February 16, 2023

How to test PowerMTA SMTP using telnet

telnet localhost 25

ehlo localhost

mail from: username@from-domain.tld

rcpt to: username@to-domain.tld

data

Subject: PMTA SMTP Check

This is just an SMTP conf Check. You may disregard.

.

quit


tail -f /var/log/pmta/pmta.log

pmta show queues

How to Send an email using Telnet in CentOS

sudo apt install telnet

sudo yum install telnet


telnet targetserver.tld 25


HELO sourceserver.tld 

MAIL FROM: username@sourcedomain.tld

RCPT TO: username@example.com

DATA 
Subject: Sending an email using  SMTP through telnet 
Hi, 
This is just a Test Email ? You may disregard this? 

regards;
Mr. Y

.

Note: We can start writing some subject and body. To do that we need to use the DATA command. First type DATA followed by Subject: and the body. Once done, enter " . "  (without quote)to send the email to be queued.

Wednesday, February 15, 2023

Stop and Disable Firewalld on CentOS 7

sudo firewall-cmd --state

sudo systemctl stop firewalld

sudo systemctl disable firewalld

sudo systemctl mask --now firewalld

Monday, February 13, 2023

Create and Install Self-Signed SSL Certificate on CentOS

yum install openssl

mkdir /etc/[webserver]/ssl

openssl genrsa -out “/etc/[webserver]/ssl/example.key” 2048

openssl req -new -key “/etc/[webserver]/ssl/example.key” \ -out “/etc/[webserver]/ssl/example.csr”


Country Name (2 letter code) [AU]:xx

State or Province Name (full name) [Some-State]:xx xx

Locality Name (eg, city) []:xx

Organization Name (eg, company) [Internet Widgits Pty Ltd]:xx

Organizational Unit Name (eg, section) []:xx

Common Name (e.g. server FQDN or YOUR name) []:example.com

Email Address []:xxx@gmail.com

openssl x509 -req -days 365 -in “/etc/[webserver]/ssl/example.csr” \ -signkey “/etc/[webserver]/ssl/example.key” \ -out “/etc/[webserver]/ssl/example.crt”


Office 2021 Activation using command

  @echo off title Activate Microsoft Office 2021 (ALL versions) for FREE - office.com&cls&echo =====================================...