Wednesday, April 19, 2023

How to add an additional IP address in Centos 7

Method -1:

Create file /etc/sysconfig/network-scripts/ifcfg-eth0:0 with the following content:

DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.11
NETMASK=255.255.255.255

service network restart

Method-2:

Run the following command
ipadd your_ip

Example: ipadd 192.168.0.1

Thursday, April 6, 2023

Sovled ! Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

 # sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*

# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*


or


# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*

# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-Linux-*

Thursday, March 30, 2023

How to set up VSFTPD Server and FTP Account in AlmaLinux

sudo dnf install vsftpd

sudo mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf_original

sudo vi /etc/vsftpd/vsftpd.conf

Add the following code to vsftpd.conf:

-------------------------------

anonymous_enable=NO

connect_from_port_20=YES

dirmessage_enable=YES

local_enable=YES

local_umask=022

listen=NO

listen_ipv6=YES

pam_service_name=vsftpd

userlist_enable=YES

write_enable=YES

xferlog_enable=YES

xferlog_std_format=YES

-------------------------------

cat /etc/vsftpd/vsftpd.conf 

sudo firewall-cmd --zone=public --add-service=ftp --permanent

sudo firewall-cmd --reload

sudo systemctl restart vsftpd

sudo useradd -m testftpuser

sudo passwd testftpuser

sudo bash -c "echo TO CHECK WORKING OF FTP > /home/baycombd/FTP_CHECK"

chown -R testftpuser /home/testftpuser

Note: Up to this user can access FTP files via ftp client application like FileZilla

Sunday, March 5, 2023

Remove header and footer text when click print button in Codeigniter

Add the following CSS for print area html tag:

@media print { @page { margin-top: 0; margin-bottom: 0; } body { padding-top: 5px; padding-bottom: 5px ; } }

Wednesday, March 1, 2023

Generate specific range of numbers having specific digit in excel

 The following function is for generating 8 digit unique number in excel and masked with 123:

=RANDBETWEEN(12300000,12399999)

Wednesday, February 22, 2023

Solved : Unable to guess the MIME type as no guessers are available (have you enabled the php_fileinfo extension?).

Issues: 
1. Image doesn't load correctly or shows broken
2. File (i.e: csv, xlsx etc.) will not be downloaded or cannot be exported

Solution:
in WHM:
  1. Navigate to Software -> EasyApache4
  2. Click the button that says Customize next to Currently Installed Packages
  3. Click PHP Extensions
  4. Search for Fileinfo in the search bar and select the extensions you would like to install
  5. Click Review
  6. After looking over the proposed changes, scroll to the bottom of the screen and click provision.




In cPanel using PHP Selector (if not works even installed in WHM):




In cPanel using ini file (if not works even installed in WHM):




Other:
  1. Install PHP FIleInfo Extension (if not installed)
  2. Enable php_fileinfo in php.ini 
extension=php_fileinfo.dll (Windows)
extension=php_fileinfo.so (Linux)

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

How to get Ranking of the Students in Excel using RANK Function

=RANK(number,ref,[order]) To rank in descending order, we will use the formula =RANK(B2,($C$5:$C$10),0) If we want unique ranks, we can use...