PHP Script to Find GeoIP info
Install GeoIP Apache Module in CentOS
Install GeoIP PHP Module in Ubuntu
Country Blocking with nginx GeoIP on Ubuntu/Debian
Category: Linux
-
Virtualmin Hosting Control Panel
To install Virtualmin on Ubuntu, run
wget http://software.virtualmin.com/gpl/scripts/install.sh bash install.sh
To install with Nginx, run
wget http://software.virtualmin.com/gpl/scripts/install.sh bash install.sh --bundle LEMP
- Virtualmin Downloading PHP file
- Install SSL Certificate in Virtualmin
- Change PHP version in Virtualmin Server
- Change MySQL root password in Virtualmin
- How to Delete Website (Virtual Server) in Virtualmin
Auto Script install
/usr/share/webmin/virtual-server/scripts
To bakup a site using the command line
virtualmin backup-domain --domain serverok.in --dest /backup/ --all-features --newformat
Back to Hosting Control Panel
-
Enable LetsEncrypt SSL in ISPConfig
Login to ISPConfig at
https://your-server-ip:8080
On main menu, click on “Sites”. It will show all available web sites on your server.
Click on the domain on which you need LetsEncrypt SSL installed.
On Next page, click the check boxes “SSL” and “LetsEncrypt”.
Click “Save” button. In few minutes you will get SSL installed on your web site.
See LetsEncrypt
-
Install tmux on CentOS 6
tmux is a terminal emulator. It work like screen, but have more features.
CentOS 6 do not come with tmux, you need to enable rpmforge repository.
On CentOS 6 64 bit, run
rpm -ivh http://repository.it4i.cz/mirrors/repoforge/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm yum install tmux
-
webmin
Webmin is an open source control panel to manage Linux and FreeBSD servers.
Download Latest source distribution from
http://www.webmin.com/download.html
To install webmin in Ubuntu/debian, edit
vi /etc/apt/sources.list
Add
deb https://download.webmin.com/download/repository sarge contrib
On Debian 11, Ubuntu 22.04 or higher, add the following
deb [signed-by=/usr/share/keyrings/jcameron-key.gpg] https://download.webmin.com/download/repository sarge contrib
Add GPG key
cd /root wget https://download.webmin.com/jcameron-key.asc apt-key add jcameron-key.asc
On Debian 11, Ubuntu 22.04 or higher.
cd /root wget https://download.webmin.com/jcameron-key.asc cat jcameron-key.asc | gpg --dearmor >/usr/share/keyrings/jcameron-key.gpg
Install webmin with apt
apt-get update apt-get install apt-transport-https apt-get install webmin
webmin access log
/var/webmin/webmin.log
LetsEncrypt SSL for webmin server
Webmin create new admin user from command line
Change MySQL root password in Virtualmin -
sar
View Past Performance Data With sar
To see stats for the previous day, run
sar -f /var/log/sysstat/saDD
Where DD is day of the month. For example, to see stats for 10th, run
sar -f /var/log/sysstat/sa10
-
Enable sar in Ubuntu
On Ubuntu, when i run sar, i get error
root@localhost:~# sar Cannot open /var/log/sysstat/sa31: No such file or directory Please check if data collecting is enabled root@localhost:~#
This is because sysstat is not enabled by default on Ubuntu, to enable, edit file
vi /etc/default/sysstat
Find
ENABLED="false"
Replace with
ENABLED="true"
Now restart sysstat
systemctl restart sysstat
See sar
-
Backup with tar
To backup a site using tar, i created a shell script.
mkdir /usr/serverok/ vi /usr/serverok/backup-daily.sh
With following content
#!/bin/bash /bin/tar zcvhf /backup/daily/backup.tgz /home/serverok.in/public_html/
For weekly backup
cp /usr/serverok/backup-daily.sh /usr/serverok/backup-weekly.sh sed -i 's/daily/weekly/g' /usr/serverok/backup-weekly.sh
Make it executable
chmod 755 /usr/serverok/backup-daily.sh chmod 755 /usr/serverok/backup-weekly.sh
Create backup folders
mkdir -p /backup/weekly mkdir -p /backup/daily
Set cronjob
crontab -e
Add
@weekly /usr/serverok/backup-weekly.sh > /var/log/backup-weekly.log 2>&1 @daily /usr/serverok/backup-daily.sh > /var/log/backup-daily.log 2>&1
See backup
-
automysqlbackup
Auto backup all your MySQL databases daily, weekly and monthly.
To install on Debian/Ubuntu, run
apt install automysqlbackup -y
To manually backup, run
automysqlbackup
MySQL backups will be stored in folder
/var/lib/automysqlbackup/
See backup
-
zfs
Install zfs file system on Ubuntu
apt install -y zfs
Listing ZFS file systems
root@ns3048991:~# zfs list NAME USED AVAIL REFER MOUNTPOINT rpool 1.12T 654G 104K /rpool rpool/ROOT 5.50G 654G 96K /rpool/ROOT rpool/ROOT/pve-1 5.50G 654G 5.50G / rpool/data 1.11T 654G 96K /rpool/data rpool/data/vm-101-disk-0 103G 748G 9.29G - rpool/data/vm-101-disk-1 1.01T 1.65T 56K - rpool/swap 4.25G 658G 289M - root@ns3048991:~#
List pools
root@ns3048991:~# zpool list NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT rpool 1.81T 15.4G 1.80T - 0% 0% 1.00x ONLINE - root@ns3048991:~#
Show current IO usage
root@ns3048991:~# zpool iostat capacity operations bandwidth pool alloc free read write read write ---------- ----- ----- ----- ----- ----- ----- rpool 15.8G 1.80T 28 46 319K 2.14M root@ns3048991:~#
To see status
root@ns3048991:~# zpool status pool: rpool state: ONLINE status: Some supported features are not enabled on the pool. The pool can still be used, but some features are unavailable. action: Enable all features using 'zpool upgrade'. Once this is done, the pool may no longer be accessible by software that does not support the features. See zpool-features(5) for details. scan: none requested config: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 sda2 ONLINE 0 0 0 sdb2 ONLINE 0 0 0 errors: No known data errors root@ns3048991:~#
-
sendmail
To test mail using sendmail, use
sendmail -f [email protected] [email protected] From: Sender Name
Subject: Test Mail This is a test message. . Dot in last time tell sendmail that message body is ended and it can send mail.
-
maldet
Sent maldet scan report to email
To install maldet, run
cd /usr/local/src wget http://www.rfxn.com/downloads/maldetect-current.tar.gz tar xvf maldetect-current.tar.gz cd maldetect-1* ./install.sh
Configure Maldet to sent email
sed -i 's/email_alert="0"/email_alert="1"/g' /usr/local/maldetect/conf.maldet sed -i 's/email_addr="[email protected]"/email_addr="[email protected]"/g' /usr/local/maldetect/conf.maldet
Update Maldet
maldet -d && maldet -u
To scan everything, run
maldet -a
To scan a folder
maldet -a /path/to/folder
To scan all public_html folders
maldet --scan-all /home?/?/public_html
To scan content created/modified in last 10 days, run
maldet --scan-recent /home?/?/public_html 10