whmapi1 sethostname hostname=new_hostname
Category Archives: Hosting
linux make website read only
find /some/path/ \( -type f -exec chmod a=r {} \; \) -o \( -type d -exec chmod a=rx {} \; \)
many php extensions at once
apt install php7.2-{mysql,curl,json,xsl,gd,xml,zip,xsl,soap,bcmath,mbstring,gettext,imagick}
wireguard-ui without docker
wget wireguard-ui:
https://github.com/ngoduykhanh/wireguard-ui/releases
tar -xvzf wireguard-ui-*.tar.gz
mkdir /opt/wireguard-ui
mv wireguard-ui /opt/wireguard-ui/
vim /opt/wireguard-ui/.env
SESSION_SECRET=
WGUI_USERNAME=
WGUI_PASSWORD=
vim /opt/wireguard-ui/postup.sh
#!/usr/bin/bash
# /opt/wireguard-ui/postup.sh
ufw route allow in on wg0 out on eth0
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
vim /opt/wireguard-ui/postdown.sh
#!/usr/bin/bash
# /opt/wireguard-ui/postdown.sh
ufw route delete allow in on wg0 out on eth0
iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
chmod +x /opt/wireguard-ui/post*.sh
vim /etc/systemd/system/wireguard-ui-daemon.service
[Unit]
Description=WireGuard UI Daemon
Wants=network-online.target
After=network-online.target
[Service]
User=root
Group=root
Type=simple
systemctl daemon-reload
systemctl start wireguard-ui-daemon.service
vim /etc/systemd/system/wgui.service
[Unit]
Description=Restart WireGuard
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart [email protected]
[Install]
RequiredBy=wgui.path
vim /etc/systemd/system/wgui.path
[Unit]
Description=Watch /etc/wireguard/wg0.conf for changes
[Path]
PathModified=/etc/wireguard/wg0.conf
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable wgui.{path,service}
systemctl start wgui.{path,service}
Nginx proxy:
add_header Cache-Control no-cache;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:5000/;
PMM
Percona Monitoring and Management (PMM) is an open-source database monitoring, management, and observability solution for MySQL, PostgreSQL, and MongoDB.
mysql grant all except mysql
SELECT CONCAT("GRANT SELECT ON ",SCHEMA_NAME,".* TO 'test_user'@'localhost';")
FROM information_schema.SCHEMATA
WHERE SCHEMA_NAME NOT LIKE 'mysql';
bash do not create file if empty result
tee empty file
use ifne
grep -ri website /etc/apache2 | ifne tee /tmp/outout.log
rm also can help:
grep -ri website /etc/apache2 > /tmp/outout.log ; [[ $? -ne 0 ]] && 'rm' -f /tmp/outout.log
curl list index elasticsearch
curl 'localhost:9200/_cat/indices?v'
nginx plugin certbot
apt install certbot python3-certbot-nginx
docker-compose latest version
VERSION=$(curl –silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po ‘”tag_name”: “\K.*\d’)
curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
certbot cloudflare manual dns
certbot certonly --manual --server https://acme-v02.api.letsencrypt.org/directory --preferred-challenges dns-01 -d "*.
[ERROR] Exception occured: ISPConfigOSException -> Command mount -o remount
wget -O - https://get.ispconfig.org | sh -s --
[ERROR] Exception occured: ISPConfigOSException -> Command mount -o remount / 2>&1 && quotaoff -avug 2>&1 && quotacheck -avugm 2>&1 && quotaon -avug 2>&1 failed. (/ispconfig.ai.php:15)
Fix OpenVZ install issue
sed -i 's/mount -o remount/echo/' /tmp/ispconfig-ai/lib/os/class.ISPConfigDebianOS.inc.php
php -f /tmp/ispconfig-ai/ispconfig.ai.php
WARNING! This script will reconfigure your complete server!
It should be run on a freshly installed server and all current configuration that you have done will most likely be lost!
Type 'yes' if you really want to continue:
yes
SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
DEBIAN/UBUNTU
apt-get install ca-certificates
FEDORA/CENTOS
dnf install ca-certificates.noarch
yum install ca-certificates.noarch
X-Frame-Options SAMEORIGIN
Configuring Apache
Header always append X-Frame-Options SAMEORIGIN
Configuring nginx
add_header X-Frame-Options SAMEORIGIN;
apache change document root based on url
ServerName testdomain.com
ServerAlias *.testdomain.com
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteCond ${lowercase:%{SERVER_NAME}} ^[a-z0-9-]+\.testdomain\.com$
RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1 [C]
RewriteRule ^([a-z0-9-]+)\.testdomain\.com/(.*) /var/www/vhost/testdomain.com/httpdocs/$1/$2