About

This is a brief description of yourself or your site, to change this text go to the admin panel, settings, plugins, and configure the plugin "about".

Static Pages

GRAV with NGINX, Debian 12


Install, PHP, DB, Nginx first.

$ adduser nginx
$ adduser nginx sudo
$ su - nginx
$ exit

$ cd /var/www/html
$ sudo wget https://getgrav.org/download/core/grav-admin/1.7.48
$ sudo unzip 1.7.48
$ sudo mv grav-admin grav
$ sudo chown -R www-data:www-data /var/www/html/grav

Nginx Config File

$ sudo nano /etc/nginx/conf.d/grav.conf

server {
listen 80;
server_name grav.example.com;
root /var/www/html/grav;
index index.html index.php;
location / {
   try_files $uri $uri/ /index.php?$query_string;
 }
   location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
   location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
   location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
   location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }

location ~ \.php$ {
   fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_index index.php;
   include fastcgi_params;
   fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
 }
}

$ sudo nginx -t
$ sudo systemctl restart nginx
$ sudo systemctl status nginx

If you find issues with the scheduler in Grav, run the following command:
$ sudo crontab -u www-data -e
And add this line to the bottom of the file:
cd /var/www/html/grav;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1


Virtualmin


apt-get update --allow-releaseinfo-change  
apt-get install --reinstall ca-certificates  
apt-get upgrade --fix-missing
apt-get install nano wget perl sudo -y

sudo apt dist-upgrade
sudo apt --purge autoremove
sudo apt update && sudo apt upgrade
apt -y purge Apache2* bind* exim* ufw* firewalld*

wget http://software.virtualmin.com/gpl/scripts/install.sh
chmod +x install.sh
sudo /bin/sh install.sh --minimal
sudo /bin/sh install.sh --bundle LEMP --minimal
wget https://raw.githubusercontent.com/virtualmin/virtualmin-install/master/virtualmin-install.sh
(Good for Debian 10, 11, Ubuntu 18,20,22 Alma, RockyLinux) 
chmod a+x virtualmin-install.sh 
sudo ./virtualmin-install.sh --minimal

apt -y remove bind* fail2ban* clamav* firewalld* proftpd* spamassassin* usermin* Quota* ufw
➔iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 10000 -j ACCEPT
dpkg --get-selections | grep -i php //important!!
(see if php7.3-mysql is installed, if not sudo apt -y install php7.3-mysql)    

sudo apt -y update && sudo apt -y upgrade
$ sudo apt -y install php software-properties-common 
$ sudo apt -y install php-common php-mysql php-xml php-xmlrpc php-curl php-gd php-imagick php-cli php-fpm php-json 
$ sudo apt -y install php-imap php-mbstring php-opcache php-soap php-dev php-cgi php-zip php-intl php-bcmath php-pear 
$ sudo apt -y install libmcrypt-dev libreadline-dev mcrypt 
sudo apt -y install php8.2 php8.2-fpm php8.2-common php8.2-mysql php8.2-xml php8.2-xmlrpc  php8.2-curl php8.2-gd php8.2-cli php8.2-dev php8.2-imap php8.2-mbstring
sudo apt -y install php8.2-soap php8.2-zip php8.2-cgi
apt -y update && apt -y upgrade
apt -y autoremove
sudo a2enmod rewrite or
sudo a2dismod rewrite
systemctl restart apache2

**if it doesn't have space, check */var/cache/* and **/var/log(except Apache2)** clean crap!**

# sudo /etc/init.d/networking restart
or
# sudo /etc/init.d/networking stop
# sudo /etc/init.d/networking start
else
# sudo systemctl restart networking
Install php5.6 among other versions

apt -y install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | 
sudo tee /etc/apt/sources.list.d/php.list

in Ubuntu: LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
apt -y update && apt -y upgrade
pecl install timezonedb zip
apt -y install libmcrypt-dev libreadline-dev mcrypt php-pear libapache2-mod-fcgid

//"! Very Important"
apt -y install php5.6 php5.6-cgi php5.6-mysql php5.6-mbstring php5.6-gd php5.6-dom php5.6-common
apt -y install php5.6-json php5.6-curl libapache2-mod-php5.6

sudo apt -y install php5.6-cli php5.6-pdo php5.6-fpm php5.6-mcrypt php5.6-imap php5.6-intl 
sudo apt -y install php5.6-recode php5.6-sqlite3 php5.6-tidy php5.6-xmlrpc php5.6-xsl php5.6-zip
sudo apt -y install php5.6-opcache php5.6-readline php5.6-xml php5.6-imagick php5.6-pspell 
php5.6-soap

systemctl restart apache2
sudo systemctl start php5.6-fpm
sudo systemctl status php5.6-fpm
systemctl restart apache2
sudo apt-get -y purge php8.*
sudo apt-get -y purge php7.3*
sudo apt-get -y autoclean
sudo apt-get -y autoremove   
systemctl restart apache2
php5.6 is a metapackage that can be used to run PHP applications.
php5.6-fpm provides the Fast Process Manager interpreter receives Fast/CGI requests.
php5.6-mysql connects PHP to the MySQL database.
libapahce2-mod-php5.6 provides the PHP module for the Apache webserver.
libapache2-mod-fcgid contains a mod_fcgid starts CGI programs to handle concurrent requests.
Set Default PHP Version

sudo update-alternatives --set php /usr/bin/php5.6 
sudo update-alternatives --set php /usr/bin/php7.4
php -v

php -i | grep "Loaded Configuration File"

a2dismod php5.6
a2enmod php5.6
systemctl restart apache2
Install Node.js via Debian Repository

apt show nodejs
apt-get update -y
apt-get install nodejs npm -y
node --version
v12.22.5
uninstall the Node.js:

apt-get remove nodejs npm --purge
apt-get autoremove
apt-get clean
Upgrade Ubuntu 20 to 22

sudo apt update -y && sudo apt upgrade -y && sudo apt dist-upgrade -y
sudo apt autoremove -y && sudo apt autoclean -y
sudo reboot
apt install update-manager-core
do-release-upgrade -d
reboot

sudo apt autoremove --purge

sudo apt install software-properties-commonsudo 
sudo add-apt-repository ppa:ondrej/php

    sudo apt -y install php5.6
    sudo apt -y install php5.6-fpm php5.6-common php5.6-mysql php5.6-xml php5.6-xmlrpc php5.6-curl 
    sudo apt -y install hp5.6-gd php5.6-cli php5.6-dev php5.6-imap php5.6-mbstring php5.6-cgi 
    sudo apt -y install php5.6-soap php5.6-zip php8.2-common php8.2-mysql php8.2-xml php8.2-xmlrpc 
sudo apt -y installphp8.2-curl php8.2-gd php8.2-imagick php8.2-cli php8.2-dev php8.2-imap 
sudo apt -y installphp8.2-opcache php8.2-soap php8.2-zip php8.2-redis php8.2-intl php8.2-mbstring 

Verify PHP Version
You can easily verify PHP version using the below command.

php -v
Output
PHP 8.2.0 (cli) (built: Jan 04 2023 09:13:42) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.0, Copyright (c), by Zend Technologies

    systemctl restart apache2
Set Permanent DNS Nameservers On Debian 11.3

apt install resolvconf
systemctl start resolvconf.service
systemctl enable resolvconf.service
systemctl status resolvconf.service 

nano /etc/resolvconf/resolv.conf.d/head
 nameserver 8.8.4.4
 nameserver 8.8.8.8

resolvconf -u
nano /etc/resolv.conf

Sources.List


Upgrade from Debian 10 to 11 to 12:  Always start from lowest and upgrade and ALWAYS choose 1st.Y

do debian 10 source list change and update
change debian 11,12 source list, update & upgrade.

Start from Debian 10,
sudo apt update && sudo apt upgrade

$ cat /proc/cpuinfo 
$ sudo dpkg --configure -a
$ sudo nano /etc/hosts
$ sudo hostnamectl set-hostname new-one
$ newgrp

ChangeLanguage
# env | grep LANG
# export LANG=en_EN.UTF-8
# dpkg-reconfigure locales
# sudo reboot
# fdisk -l df -h resize2fs /dev/vda df -h You should see the storage as expected.

$ nano /etc/apt/sources.list for debian 11

deb http://deb.debian.org/debian bullseye main
deb-src http://deb.debian.org/debian bullseye main
deb http://security.debian.org/debian-security bullseye-security main
deb-src http://security.debian.org/debian-security bullseye-security main
deb http://deb.debian.org/debian bullseye-updates main
deb-src http://deb.debian.org/debian bullseye-updates main
deb http://deb.debian.org/debian bullseye-backports main
deb-src http://deb.debian.org/debian bullseye-backports main

$ nano /etc/apt/sources.list for debian 12

deb http://deb.debian.org/debian bookworm main
deb-src http://deb.debian.org/debian bookworm main
deb http://security.debian.org/debian-security bookworm-security main
deb-src http://security.debian.org/debian-security bookworm-security main
deb http://deb.debian.org/debian bookworm-updates main
deb-src http://deb.debian.org/debian bookworm-updates main
deb http://deb.debian.org/debian bookworm-backports main
deb-src http://deb.debian.org/debian bookworm-backports main

From CD Rom version

deb http://ftp.debian.org/debian bookworm main non-free-firmware
deb-src http://ftp.debian.org/debian bookworm main non-free-firmware

deb http://security.debian.org/debian-security bookworm-security main non-free-firmware
deb-src http://security.debian.org/debian-security bookworm-security main non-free-firmware

deb http://ftp.debian.org/debian bookworm-updates main non-free-firmware
deb-src http://ftp.debian.org/debian bookworm-updates main non-free-firmware

For Ubuntu, start from Ubuntu20 to 22LTS

$ nano /etc/apt/sources.list

deb http://archive.ubuntu.com/ubuntu jammy main restricted
deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted
deb http://archive.ubuntu.com/ubuntu jammy universe
deb http://archive.ubuntu.com/ubuntu jammy-updates universe
deb http://archive.ubuntu.com/ubuntu jammy multiverse
deb http://archive.ubuntu.com/ubuntu jammy-updates multiverse
deb http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu jammy partner
deb http://archive.ubuntu.com/ubuntu jammy-security main restricted
deb http://archive.ubuntu.com/ubuntu jammy-security universe
deb http://archive.ubuntu.com/ubuntu jammy-security multiverse

$ apt-get update --allow-releaseinfo-change  
$ apt-get install --reinstall ca-certificates  
$ apt-get upgrade --fix-missing
$ apt-get install nano wget perl sudo -y

$ sudo apt dist-upgrade
$ sudo apt --purge autoremove
$ sudo apt update && sudo apt upgrade
$ apt -y purge Apache2* bind* exim* ufw* firewalld*

$ wget http://software.virtualmin.com/gpl/scripts/install.sh
$ chmod +x install.sh
$ sudo /bin/sh install.sh --minimal
$ sudo /bin/sh install.sh --bundle LEMP --minimal

$ wget https://raw.githubusercontent.com/virtualmin/virtualmin-install/master/virtualmin-install.sh
(Good for Debian 10, 11, Ubuntu 18,20,22 Alma, RockyLinux) 
$ chmod a+x virtualmin-install.sh 
$ sudo ./virtualmin-install.sh --minimal

$ apt -y remove bind* fail2ban* clamav* firewalld* proftpd* spamassassin* usermin* Quota* ufw
➔iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 10000 -j ACCEPT
$ dpkg --get-selections | grep -i php //important!!
(see if php7.3-mysql is installed, if not sudo apt -y install php7.3-mysql)    

$ sudo apt -y update && sudo apt -y upgrade
$ sudo apt -y install php software-properties-common
$ sudo apt -y install php-common php-mysql php-xml php-xmlrpc php-curl php-gd php-imagick php-cli
$ sudo apt -y install php-imap php-mbstring php-opcache php-soap php-dev php-cgi php-zip php-intl
$ sudo apt -y install libmcrypt-dev libreadline-dev mcrypt php-pear libapache2-mod-fcgid

$ sudo apt -y install php8.2 php8.2-fpm php8.2-common php8.2-mysql php8.2-xml php8.2-xmlrpc
$ sudo apt -y install php8.2-curl php8.2-gd php8.2-cli php8.2-dev php8.2-imap php8.2-mbstring
$ sudo apt -y install php8.2-soap php8.2-zip php8.2-cgi

$ apt -y update && apt -y upgrade
$ apt -y autoremove
$ sudo a2enmod rewrite or
$ sudo a2dismod rewrite
$ systemctl restart apache2

**if it doesn't have space, check */var/cache/* and **/var/log(except Apache2)** clean crap!**

# sudo /etc/init.d/networking restart
or
# sudo /etc/init.d/networking stop
# sudo /etc/init.d/networking start
else
# sudo systemctl restart networking
Install php5.6 among other versions

apt -y install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | 
sudo tee /etc/apt/sources.list.d/php.list

in Ubuntu: LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
apt -y update && apt -y upgrade
pecl install timezonedb zip
apt -y install libmcrypt-dev libreadline-dev mcrypt php-pear libapache2-mod-fcgid

//"! Very Important"
apt -y install php5.6 php5.6-cgi php5.6-mysql php5.6-mbstring php5.6-gd php5.6-dom php5.6-common
apt -y install php5.6-json php5.6-curl libapache2-mod-php5.6

sudo apt -y install php5.6-cli php5.6-pdo php5.6-fpm php5.6-mcrypt php5.6-imap php5.6-intl 
sudo apt -y install php5.6-recode php5.6-sqlite3 php5.6-tidy php5.6-xmlrpc php5.6-xsl php5.6-zip
sudo apt -y install php5.6-opcache php5.6-readline php5.6-xml php5.6-imagick php5.6-pspell 
php5.6-soap

systemctl restart apache2
sudo systemctl start php5.6-fpm
sudo systemctl status php5.6-fpm
systemctl restart apache2
sudo apt-get -y purge php8.*
sudo apt-get -y purge php7.3*
sudo apt-get -y autoclean
sudo apt-get -y autoremove   
systemctl restart apache2
php5.6 is a metapackage that can be used to run PHP applications.
php5.6-fpm provides the Fast Process Manager interpreter receives Fast/CGI requests.
php5.6-mysql connects PHP to the MySQL database.
libapahce2-mod-php5.6 provides the PHP module for the Apache webserver.
libapache2-mod-fcgid contains a mod_fcgid starts CGI programs to handle concurrent requests.
Set Default PHP Version

sudo update-alternatives --set php /usr/bin/php5.6 
sudo update-alternatives --set php /usr/bin/php7.4
php -v

php -i | grep "Loaded Configuration File"

a2dismod php5.6
a2enmod php5.6
systemctl restart apache2
Install Node.js via Debian Repository

apt show nodejs
apt-get update -y
apt-get install nodejs npm -y
node --version
v12.22.5
uninstall the Node.js:

apt-get remove nodejs npm --purge
apt-get autoremove
apt-get clean
Upgrade Ubuntu 20 to 22

sudo apt update -y && sudo apt upgrade -y && sudo apt dist-upgrade -y
sudo apt autoremove -y && sudo apt autoclean -y
sudo reboot
apt install update-manager-core
do-release-upgrade -d
reboot

sudo apt autoremove --purge

sudo apt install software-properties-commonsudo 
sudo add-apt-repository ppa:ondrej/php

    sudo apt -y install php5.6
    sudo apt -y install php5.6-fpm php5.6-common php5.6-mysql php5.6-xml php5.6-xmlrpc php5.6-curl 
    sudo apt -y install hp5.6-gd php5.6-cli php5.6-dev php5.6-imap php5.6-mbstring php5.6-cgi 
    sudo apt -y install php5.6-soap php5.6-zip php8.2-common php8.2-mysql php8.2-xml php8.2-xmlrpc 
sudo apt -y installphp8.2-curl php8.2-gd php8.2-imagick php8.2-cli php8.2-dev php8.2-imap 
sudo apt -y installphp8.2-opcache php8.2-soap php8.2-zip php8.2-redis php8.2-intl php8.2-mbstring 

Verify PHP Version
You can easily verify PHP version using the below command.

php -v
Output
PHP 8.2.0 (cli) (built: Jan 04 2023 09:13:42) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.0, Copyright (c), by Zend Technologies

    systemctl restart apache2
Set Permanent DNS Nameservers On Debian 11.3

apt install resolvconf
systemctl start resolvconf.service
systemctl enable resolvconf.service
systemctl status resolvconf.service 

nano /etc/resolvconf/resolv.conf.d/head
 nameserver 8.8.4.4
 nameserver 8.8.8.8

resolvconf -u
nano /etc/resolv.conf

L.A.M.P


prerequisite

$ cat /proc/cpuinfo 
$ sudo dpkg --configure -a
$ sudo nano /etc/hosts
$ sudo hostnamectl set-hostname new-one
$ newgrp 

$ apt-get update --allow-releaseinfo-change
$ apt-get install --reinstall ca-certificates
$ apt-get upgrade -y
$ apt-get install nano wget curl perl sudo -y

$ sudo apt dist-upgrade
$ sudo apt --purge autoremove
$ sudo apt update && sudo apt upgrade
$ apt -y purge Apache2* bind* exim* ufw* firewalld*

================Install Apache==========================================
$ sudo apt -y install apache2 apache2-utils
$ apache2 -v
$ systemctl status apache2
$ systemctl reload apache2

=================PHP=====================
$ sudo apt -y install php software-properties-common 
$ sudo apt -y install php-common php-mysql php-xml php-xmlrpc php-curl php-gd php-imagick php-cli php-fpm php-json php-imap php-mbstring php-opcache php-soap php-dev php-cgi php-zip php-intl php-bcmath php-pear
$ sudo apt -y install libmcrypt-dev libreadline-dev mcrypt 
$ sudo apt -y install php8.2 php8.2-fpm php8.2-common php8.2-mysql php8.2-xml php8.2-xmlrpc php8.2-curl php8.2-gd php8.2-cli php8.2-dev php8.2-imap php8.2-mbstring php8.2-soap php8.2-zip php8.2-cgi 

$ sudo apt -y install php7.4 php7.4-fpm php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc 
$ sudo apt -y install php7.4-curl php7.4-gd php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring 
$ sudo apt -y install php7.4-soap php7.4-zip php7.4-cgi
================MySql==========================================
$ apt install -y mariadb-server mariadb-client
$ systemctl status mariadb
$ mysql_secure_installation
$ mysql -u root -p
--Enter password:
Maria DB [(none)]>
> CREATE DATABASE rome;
> CREATE USER 'user_name'@localhost IDENTIFIED BY 'password';
> GRANT ALL PRIVILEGES ON *.* TO 'db_name'@localhost IDENTIFIED BY 'password';
> FLUSH PRIVILEGES;
> SHOW GRANTS FOR 'db_name'@localhost;
> SHOW DATABASES;
> Exit;

===============Setting website========================
$ mkdir -p /var/www/website
$ chmod -R 755 /var/www/website
$ nano /var/www/website/index.php
$ cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/website.conf
$ nano /etc/apache2/sites-available/website.conf

<VirtualHost *:80> 
    ServerName your_domain
    ServerAlias www.your_domain 
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost> 

$ a2dissite 000-default.conf
$ a2ensite website.conf
$ systemctl reload apache2

$ sudo apachectl configtest
Output Syntax OK
$ systemctl reload apache2

==========Using php-fpm===========
$ sudo systemctl start php8.2-fpm
$ sudo systemctl status php8.2-fpm
$ sudo systemctl reload apache2
$ sudo chown -R www-data:www-data /var/www/website
$ sudo chmod -R 755 /var/www/website
$ nano /etc/apache2/sites-available/website.conf

<VirtualHost *:80> 
ServerAdmin [email protected]
ServerName website.com
DocumentRoot /var/www/website
DirectoryIndex index.php index.html
<Directory /var/www/website> 
     Options Indexes FollowSymLinks MultiViews
     AllowOverride All
     Order allow,deny
     allow from all
</Directory> 
<FilesMatch \.php$> 
     SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost"
</FilesMatch> 
     ErrorLog ${APACHE_LOG_DIR}/site1_error.log
     CustomLog ${APACHE_LOG_DIR}/site1_access.log combined
</VirtualHost> 

$ sudo apachectl configtest
  Output Syntax OK
$ sudo a2ensite website
$ sudo a2dissite 000-default.conf
$ sudo systemctl reload apache2

================Webmin===================

$ sudo apt -y install curl
$ curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
$ sh setup-repos.sh
$ apt -y install webmin --install-recommends
( change port: $ sudo nano -w /etc/webmin/miniserv.conf )

===============phpMyAdmin=======================

sudo apt install phpmyadmin -y
sudo dpkg --configure -a
sudo apt -y autoremove
sudo apt install phpmyadmin -y
$ sudo ln -s /usr/share/phpmyadmin/ /var/www/html/
$ cd /var/www/html/phpmyadmin
$ ls
$ sudo cp config.sample.inc.php config.inc.php
$ sudo nano config.inc.php
  $cfg['blowfish_secret'] = '';
$ sudo chown -R www-data:www-data /var/www/html
$ sudo rm -rf /var/www/html/phpmyadmin/setup
http://i.p addr/phpmyadmin