Skip to content

Commit aabd227

Browse files
authored
Lots of Updates
Adjusted some configuration files and ran many scripts through AI filters in a search for improvements, bug fixes, and typos.
1 parent 739f629 commit aabd227

21 files changed

Lines changed: 410 additions & 198 deletions

config/etc/mysql/mariadb.cnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ innodb_buffer_pool_size = SEDMYSQL45PERCENTM
112112
innodb_log_buffer_size = SEDLBSM
113113
innodb_file_per_table = 1
114114
innodb_open_files = SEDINOF
115-
innodb_io_capacity = 400
115+
#innodb_io_capacity = 1000
116116
innodb_flush_method = O_DIRECT
117117
innodb_use_native_aio=1
118118

config/etc/nginx/nginx.conf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ events {
2424
http {
2525
# Main Logs
2626
log_format main '$remote_addr - $remote_user [$time_local] $request '
27-
'"$status" $body_bytes_sent "$http_referer" '
28-
'"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'
29-
'"$connection" "$connection_requests" "$request_time" $http_cf_ray '
30-
'$ssl_protocol $ssl_cipher';
27+
'"$status" $body_bytes_sent "$http_referer" '
28+
'"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'
29+
'"$connection" "$connection_requests" "$request_time" $http_cf_ray '
30+
'$ssl_protocol $ssl_cipher';
3131

3232
#log_format main_json escape=json '{'
3333
# '"connection": "$connection", ' # connection serial number
@@ -52,10 +52,10 @@ http {
5252
# HTTP_Proxy exploit log
5353
# https://www.nginx.com/blog/mitigating-the-httpoxy-vulnerability-with-nginx
5454
#log_format proxylog '$remote_addr - $remote_user [$time_local] '
55-
#'"$request" $status $body_bytes_sent '
56-
#'"$http_referer" "$http_user_agent" '
57-
#'"$http_proxy"';
58-
55+
#'"$request" $status $body_bytes_sent '
56+
#'"$http_referer" "$http_user_agent" '
57+
#'"$http_proxy"';
58+
5959
# Enable access log if you want to use ngxtop to monitor traffic
6060
access_log off;
6161
#access_log /dev/null crit;

config/etc/php/php.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ max_execution_time = 120
141141
max_input_time = 60
142142
;max_input_nesting_level = 64
143143
max_input_vars = 4666
144-
memory_limit = SEDPHPVERMEMLIMIT
144+
memory_limit = SEDPHPMEMLIMIT
145145

146146
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
147147
; Error handling and logging ;

config/etc/redis/redis.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ maxmemory-policy allkeys-lru
112112

113113
############################# LAZY FREEING ####################################
114114

115-
lazyfree-lazy-eviction no
116-
lazyfree-lazy-expire no
117-
lazyfree-lazy-server-del no
118-
replica-lazy-flush no
119-
lazyfree-lazy-user-del no
115+
lazyfree-lazy-eviction yes
116+
lazyfree-lazy-expire yes
117+
lazyfree-lazy-server-del yes
118+
replica-lazy-flush yes
119+
lazyfree-lazy-user-del yes
120120

121121
################################ THREADED I/O #################################
122122

config/etc/sysctl.d/60-enginescript.conf

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
### GENERAL SYSTEM SECURITY OPTIONS ###
22

3-
# Disable SysRq keyboard shortcuts : Credit SlickStack
4-
kernel.sysrq = 0
5-
63
# Controls the number of system-wide asynchronous io requests
74
fs.aio-max-nr = 1048576
85

@@ -41,11 +38,11 @@ kernel.kptr_restrict = 1
4138
# Increase size of file handles and inode cache
4239
fs.file-max = 209708
4340

44-
## Protect system hard/soft links : Credit SlickStack
41+
# Protect system hard/soft links : Credit SlickStack
4542
fs.protected_hardlinks = 1
4643
fs.protected_symlinks = 1
4744

48-
## Big performance boost (published by PostgreSQL community) : Credit SlickStack
45+
# Big performance boost (published by PostgreSQL community) : Credit SlickStack
4946
kernel.sched_migration_cost_ns = 5000000
5047
kernel.sched_autogroup_enabled = 0
5148

@@ -57,6 +54,9 @@ vm.dirty_background_ratio = 5
5754
# Specifies the minimum virtual address that a process is allowed to mmap
5855
vm.mmap_min_addr = 4096
5956

57+
# Specifies the maximum number of memory map areas that a process can have
58+
vm.max_map_count = 262144
59+
6060
# 50% overcommitment of available memory
6161
# Allow memory overcommit required for redis
6262
vm.overcommit_ratio = 40
@@ -95,7 +95,7 @@ net.ipv6.conf.default.forwarding = 0
9595

9696
# Disables IP source routing
9797
net.ipv4.conf.all.send_redirects = 0
98-
net.ipv4.conf.default.send_redirects = 0
98+
net.ipv4.conf.default.send_redirects = 0
9999
net.ipv4.conf.all.accept_source_route = 0
100100
net.ipv4.conf.default.accept_source_route = 0
101101
net.ipv6.conf.all.accept_source_route = 0
@@ -123,9 +123,9 @@ net.ipv4.conf.default.log_martians = 1
123123
net.ipv4.tcp_fin_timeout = 10
124124

125125
# Decrease the time default value for connections to keep alive
126-
net.ipv4.tcp_keepalive_time = 300
127-
net.ipv4.tcp_keepalive_probes = 5
128126
net.ipv4.tcp_keepalive_intvl = 15
127+
net.ipv4.tcp_keepalive_probes = 5
128+
net.ipv4.tcp_keepalive_time = 300
129129

130130
# Don't relay bootp
131131
net.ipv4.conf.all.bootp_relay = 0
@@ -136,7 +136,7 @@ net.ipv4.conf.all.proxy_arp = 0
136136
# Turn on the tcp_timestamps, accurate timestamp make TCP congestion control algorithms work better
137137
net.ipv4.tcp_timestamps = 1
138138

139-
# # Enable select acknowledgments
139+
# Enable select acknowledgments
140140
net.ipv4.tcp_sack = 1
141141

142142
# Don't ignore directed pings
@@ -156,16 +156,16 @@ net.ipv6.ip_local_port_range = 1024 65535
156156
net.ipv4.tcp_rfc1337 = 1
157157

158158
# Do not auto-configure IPv6
159-
net.ipv6.conf.all.autoconf=0
160-
net.ipv6.conf.all.accept_ra=0
161-
net.ipv6.conf.default.autoconf=0
162-
net.ipv6.conf.default.accept_ra=0
163-
net.ipv6.conf.eth0.autoconf=0
164-
net.ipv6.conf.eth0.accept_ra=0
159+
net.ipv6.conf.all.accept_ra = 0
165160
net.ipv6.conf.all.accept_ra_defrtr = 0
166-
net.ipv6.conf.default.accept_ra_defrtr = 0
167161
net.ipv6.conf.all.accept_ra_pinfo = 0
162+
net.ipv6.conf.all.autocon f = 0
163+
net.ipv6.conf.default.accept_ra = 0
164+
net.ipv6.conf.default.accept_ra_defrtr = 0
168165
net.ipv6.conf.default.accept_ra_pinfo = 0
166+
net.ipv6.conf.default.autoconf = 0
167+
net.ipv6.conf.eth0.accept_ra = 0
168+
net.ipv6.conf.eth0.autoconf = 0
169169

170170
### TUNING NETWORK PERFORMANCE ###
171171

@@ -207,17 +207,16 @@ net.core.somaxconn = 65535
207207
# Increase number of incoming connections backlog
208208
net.core.netdev_max_backlog = 32801
209209
net.core.dev_weight = 64
210-
net.core.netdev_budget = 1200
211-
net.core.netdev_budget_usecs = 8000
210+
net.core.netdev_budget = 3600
211+
net.core.netdev_budget_usecs = 4000
212212

213213
# Increase the maximum amount of option memory buffers
214214
net.core.optmem_max = 25165824
215215

216216
# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
217-
net.ipv4.tcp_max_tw_buckets = 400000
217+
net.ipv4.tcp_max_tw_buckets = 600000
218218

219219
# Try to reuse time-wait connections, but don't recycle them (recycle can break clients behind NAT)
220-
net.ipv4.tcp_tw_recycle = 0
221220
net.ipv4.tcp_tw_reuse = 1
222221

223222
# Limit number of orphans, each orphan can eat up to 16M (max wmem) of unswappable memory
@@ -275,6 +274,13 @@ net.ipv6.route.flush = 1
275274

276275
# References
277276
# https://wiki.archlinux.org/title/Sysctl
277+
# https://www.kernel.org/doc/Documentation/sysctl/
278+
# https://github.com/klaver/sysctl/blob/master/sysctl.conf
278279
# https://medium.com/@moaminsharifi/tuning-your-linux-kernel-for-io-intensive-applications-2e059dd5f813
279280
# https://ntk148v.github.io/posts/linux-network-performance-ultimate-guide/
280281
# https://raw.githubusercontent.com/littlebizzy/slickstack/master/modules/ubuntu/24.04/sysctl.txt
282+
# https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/monitoring_and_managing_system_status_and_performance/tuning-the-network-performance_monitoring-and-managing-system-status-and-performance
283+
# https://bastakiss.com/blog/linux-7/best-practices-for-managing-linux-servers-in-2025-517
284+
# https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
285+
# https://discourse.ubuntu.com/t/boosting-the-vm-max-map-count-in-ubuntu/33863/7
286+
# https://fasterdata.es.net/host-tuning/linux/

config/opt/kernel-samepage-merging/ksm-service.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,13 @@
44
#----------------------------------------------------------------------------
55
# Website: https://EngineScript.com
66
# GitHub: https://github.com/Enginescript/EngineScript
7-
# Company: VisiStruct / EngineScript
87
# License: GPL v3.0
98
#----------------------------------------------------------------------------
109

1110
# EngineScript Variables
1211
source /usr/local/bin/enginescript/enginescript-variables.txt
1312
source /home/EngineScript/enginescript-install-options.txt
1413

15-
# Check current user's ID. If user is not 0 (root), exit.
16-
if [ "${EUID}" != 0 ];
17-
then
18-
echo "${BOLD}ALERT:${NORMAL}"
19-
echo "EngineScript should be executed as the root user."
20-
exit
21-
fi
22-
2314
#----------------------------------------------------------------------------
2415
# Start Main Script
2516

enginescript-variables.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#-#-#-#-#-#-#-# Edit These At Your Own Risk #-#-#-#-#-#-#-#
77

88
# EngineScript Version
9-
VARIABLES_DATE="FEB2425"
9+
VARIABLES_DATE="MAR0125"
1010

1111
# Software Versions
1212
LIBURING_VER="2.9"
@@ -25,18 +25,24 @@ ZLIB_VER="1.3.1"
2525
OLDPHP="8.0"
2626
OLDPCRE="8.45"
2727

28-
# EngineScript Variables
28+
# System Information
2929
BIT_TYPE="$(uname -m)"
3030
CPU_COUNT="$(nproc --all)"
3131
DT="$(date +"%m-%d-%y")"
3232
IP_ADDRESS="$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')"
3333
UBUNTU_TYPE="$(lsb_release -si)"
34+
UBUNTU_CODENAME="$(lsb_release -sc)"
35+
UBUNTU_VERSION="$(lsb_release -sr)"
36+
37+
# Random Characters
3438
RAND_CHAR2="$(pwgen -A01 2)"
35-
RAND_CHAR4="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)"
39+
RAND_CHAR4="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 4 | head -n 1)"
3640
RAND_CHAR8="$(pwgen -1Bcns 8)"
37-
RAND_CHAR16="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)"
41+
RAND_CHAR16="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 16 | head -n 1)"
3842
RAND_CHAR24="$(date +%s | sha256sum | base64 | head -c 24)"
39-
RAND_CHAR32="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9_' | fold -w 32 | head -n 1)"
43+
RAND_CHAR32="$(tr -dc 'a-zA-Z0-9_' < /dev/urandom | fold -w 32 | head -n 1)"
44+
45+
# Server Memory Calculations
4046
SERVER_MEMORY_TOTAL_01="$(free -m | awk 'NR==2{printf "%d", $2*0.01 }')"
4147
SERVER_MEMORY_TOTAL_02="$(free -m | awk 'NR==2{printf "%d", $2*0.02 }')"
4248
SERVER_MEMORY_TOTAL_03="$(free -m | awk 'NR==2{printf "%d", $2*0.03 }')"
@@ -49,9 +55,7 @@ SERVER_MEMORY_TOTAL_09="$(free -m | awk 'NR==2{printf "%d", $2*0.09 }')"
4955
SERVER_MEMORY_TOTAL_10="$(free -m | awk 'NR==2{printf "%d", $2*0.10 }')"
5056
SERVER_MEMORY_TOTAL_80="$(free -m | awk 'NR==2{printf "%d", $2*0.80 }')"
5157
SERVER_MEMORY_TOTAL_100="$(free -m | awk 'NR==2{printf "%d", $2*1 }')"
52-
UBUNTU_CODENAME="$(lsb_release -sc)"
53-
UBUNTU_VERSION="$(lsb_release -sr)"
5458

55-
# Shell text
59+
# Shell text formatting
5660
BOLD="$(tput bold)"
5761
NORMAL="$(tput sgr0)"

scripts/functions/alias/alias-cache.sh

Lines changed: 77 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,82 @@ echo -e "\nClearing Caches\n\n"
2727
# Include config
2828
source /home/EngineScript/sites-list/sites.sh
2929

30-
# Clear Transients on all sites
31-
for i in "${SITES[@]}"
32-
do
33-
echo "Deleting ${i} Transients"
34-
cd "/var/www/sites/$i/html"
35-
wp transient delete-all --allow-root
36-
done
37-
38-
# Clear Nginx fastCGI cache
39-
echo "Clearing Nginx Cache"
40-
for i in "${SITES[@]}"
41-
do
42-
echo "Deleting ${i} Transients"
43-
cd "/var/www/sites/$i/html"
44-
wp nginx-helper purge-all --allow-root
45-
done
46-
rm -rf /var/cache/nginx/*
47-
48-
# Clear PHP OpCache
49-
echo "Clearing PHP OpCache"
50-
rm -rf /var/cache/opcache/*
51-
52-
# Clear Redis object cache
53-
echo "Clearing Redis Object Cache"
54-
redis-cli FLUSHALL ASYNC
30+
# Function to clear transients on all sites
31+
clear_transients() {
32+
for site in "${SITES[@]}"; do
33+
echo "Deleting ${site} Transients"
34+
cd "/var/www/sites/$site/html" || {
35+
echo "Error: Failed to change directory to /var/www/sites/$site/html"
36+
}
37+
wp transient delete-all --allow-root || {
38+
echo "Error: Failed to delete transients for ${site}"
39+
}
40+
done
41+
}
42+
43+
# Function to clear Nginx cache
44+
clear_nginx_cache() {
45+
echo "Clearing Nginx Cache"
46+
for site in "${SITES[@]}"; do
47+
echo "Purging Nginx Cache for ${site}"
48+
cd "/var/www/sites/$site/html" || {
49+
echo "Error: Failed to change directory to /var/www/sites/$site/html"
50+
}
51+
wp nginx-helper purge-all --allow-root || {
52+
echo "Error: Failed to purge Nginx cache for ${site}"
53+
}
54+
done
55+
rm -rf /var/cache/nginx/* || {
56+
echo "Error: Failed to clear Nginx cache"
57+
}
58+
}
59+
60+
# Function to clear PHP OpCache
61+
clear_php_opcache() {
62+
echo "Clearing PHP OpCache"
63+
rm -rf /var/cache/opcache/* || {
64+
echo "Error: Failed to clear PHP OpCache"
65+
}
66+
}
67+
68+
# Function to clear Redis object cache
69+
clear_redis_cache() {
70+
echo "Clearing Redis Object Cache"
71+
redis-cli FLUSHALL ASYNC || {
72+
echo "Error: Failed to clear Redis cache"
73+
}
74+
}
75+
76+
# Function to restart a service
77+
restart_service() {
78+
local service_name=$1
79+
echo "Restarting ${service_name}"
80+
service ${service_name} restart || {
81+
echo "Error: Failed to restart ${service_name}"
82+
}
83+
}
84+
85+
# Function to restart PHP-FPM service
86+
restart_php_fpm() {
87+
local php_versions=("8.1" "8.2" "8.3" "8.4")
88+
for version in "${php_versions[@]}"; do
89+
if systemctl is-active --quiet php${version}-fpm; then
90+
restart_service "php${version}-fpm"
91+
return
92+
fi
93+
done
94+
echo "Error: No active PHP-FPM service found."
95+
}
96+
97+
# Clear caches
98+
clear_transients
99+
clear_nginx_cache
100+
clear_php_opcache
101+
clear_redis_cache
55102

56103
# Restart services
57-
echo "Restarting Nginx"
58-
service nginx restart
59-
echo "Restarting PHP-FPM"
60-
service php${PHP_VER}-fpm restart
61-
echo "Restarting Redis"
62-
service redis-server restart
104+
restart_service "nginx"
105+
restart_php_fpm
106+
restart_service "redis-server"
107+
108+
echo "All caches cleared and services restarted successfully."

0 commit comments

Comments
 (0)