Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
22cb83f
20.04
enoch85 Apr 27, 2020
1b6ff79
get all the latest functions and variables
enoch85 Oct 21, 2020
4d528d8
update install script
enoch85 Oct 21, 2020
ca9e48d
update startup script
enoch85 Oct 21, 2020
1191463
add folders
enoch85 Oct 21, 2020
d4f73b5
add folders
enoch85 Oct 21, 2020
cbe673b
add missing redis var
enoch85 Oct 21, 2020
74611b7
fix apps
enoch85 Oct 21, 2020
fed3b1d
remove scripts
enoch85 Oct 21, 2020
9037430
remove scripts
enoch85 Oct 21, 2020
0fbf97b
Merge branch 'master' into 20.04_testing
enoch85 Oct 21, 2020
7d08493
change branch
enoch85 Oct 21, 2020
26650d7
travis
enoch85 Oct 21, 2020
3cf1b3a
travis
enoch85 Oct 21, 2020
e90b24e
remove old redis script
enoch85 Oct 21, 2020
2b6a61b
adopt wp to redis
enoch85 Oct 21, 2020
4f7b178
travis
enoch85 Oct 21, 2020
e39e394
use new function
enoch85 Oct 22, 2020
330d88f
minor changes
enoch85 Oct 22, 2020
c638b3c
remove geoblock
enoch85 Oct 22, 2020
a2a2565
run_script
enoch85 Oct 22, 2020
5aa4d61
smaller fixes
enoch85 Oct 22, 2020
f252fa5
ln -s
enoch85 Oct 22, 2020
4615eb6
10.5
enoch85 Oct 22, 2020
a35b044
add begining and end
enoch85 Oct 22, 2020
b55638d
fix redis
enoch85 Oct 22, 2020
a10cd22
don't install redis two times
enoch85 Oct 22, 2020
02bc187
fpm sock
enoch85 Oct 22, 2020
b8809be
try to fix wp error
enoch85 Oct 22, 2020
5328aef
Merge branch '20.04_testing' of github.com:techandme/wordpress-vm int…
enoch85 Oct 22, 2020
8ec4ee6
fix expect
enoch85 Oct 22, 2020
b93bfbc
fix nginx_def
enoch85 Oct 22, 2020
b05768f
install_if_not
enoch85 Oct 22, 2020
5952057
Update wordpress-startup-script.sh
enoch85 Oct 23, 2020
d24497f
Update activate-ssl.sh
enoch85 Oct 23, 2020
bf269e3
Rename activate-ssl.sh to activate-tls.sh
enoch85 Oct 23, 2020
293c74d
Update test-new-config.sh
enoch85 Oct 23, 2020
ac25ca1
change to functions
enoch85 Oct 23, 2020
7fbe61e
change to functions
enoch85 Oct 23, 2020
f4e116e
Rename techandme.sh to wordpress.sh
enoch85 Oct 23, 2020
6679f52
Rename nextcloud_configuration.sh to wordpress_configuration.sh
enoch85 Oct 23, 2020
1181c9e
fix bugs
enoch85 Oct 23, 2020
d498ac7
minor fixes
enoch85 Oct 24, 2020
e9110ac
some more fixes
enoch85 Oct 24, 2020
340b41e
some more fixes
enoch85 Oct 24, 2020
aa64c7e
lib fixes
enoch85 Oct 24, 2020
992285d
bug
enoch85 Oct 24, 2020
1315c6b
menu fixes
enoch85 Oct 24, 2020
1b102ec
fixes
enoch85 Oct 24, 2020
e92aaf6
fixes
enoch85 Oct 24, 2020
74225f3
automatic updates
enoch85 Oct 24, 2020
ffc9e87
fixes
enoch85 Oct 24, 2020
36008a5
fix secure bug
enoch85 Oct 24, 2020
64cb560
more fixes
enoch85 Oct 24, 2020
9f9b62b
travis
enoch85 Oct 24, 2020
d68a238
travis
enoch85 Oct 24, 2020
7050272
remove wget
enoch85 Oct 24, 2020
86ccaf8
travis
enoch85 Oct 24, 2020
889256c
always ask for alias
enoch85 Oct 24, 2020
1e5a519
travis
enoch85 Oct 24, 2020
d09906a
Update wordpress_update.sh
enoch85 Oct 24, 2020
926c00e
wording
enoch85 Oct 24, 2020
a007f18
wpath
enoch85 Oct 24, 2020
3fc4a50
maintenance mode
enoch85 Oct 24, 2020
3667f8c
nextcloud wordpress
enoch85 Oct 24, 2020
968d9ad
fix source
enoch85 Oct 25, 2020
73cac37
remove scripts
enoch85 Oct 25, 2020
71d5aa4
improve wp_cli_cmd
enoch85 Oct 25, 2020
77b0155
improve wp_cli_cmd
enoch85 Oct 25, 2020
37d9471
set maintenance earlier
enoch85 Oct 25, 2020
c9ce5c6
fix adminer
enoch85 Oct 25, 2020
06038a0
fix netdata
enoch85 Oct 25, 2020
2a54b9c
travis
enoch85 Oct 25, 2020
4a8df8f
fail2ban
enoch85 Oct 25, 2020
d3bd108
fail2ban
enoch85 Oct 25, 2020
e75c7db
fail2ban
enoch85 Oct 25, 2020
ecf2c39
fix maria db repo
enoch85 Oct 25, 2020
6b832f0
use unix socket for mariadb
enoch85 Oct 25, 2020
78cbe97
fix path
enoch85 Oct 25, 2020
fc99b16
fix more bugs
enoch85 Oct 25, 2020
8d65883
fix more bugs
enoch85 Oct 25, 2020
eba42c1
change vhost
enoch85 Oct 25, 2020
4d2e806
fix more bugs
enoch85 Oct 25, 2020
e832224
fix more bugs
enoch85 Oct 25, 2020
d29f3cc
fix more bugs
enoch85 Oct 25, 2020
83e83cf
fix more bugs
enoch85 Oct 25, 2020
bec49bf
change branch to master
enoch85 Oct 25, 2020
9d8117a
change versions
enoch85 Oct 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
### https://www.hanssonit.se/wordpress-vm/

- Ubuntu 18.04
- MariaDB 10.2
- NGINX 1.16
- PHP-FPM 7.2
- MariaDB 10.5
- NGINX 1.18
- PHP-FPM 7.4
- Latest Wordpress (updates automatically)
- WP-CLI
- Redis Cache
- Igbinary for PHP
- APCu Cache
- and [more](https://docs.hanssonit.se/s/W6fMouPiqQz3_Mog/virtual-machines-vm/d/W7jL1OPiqQz3_MtV/wordpress-vm-machine-configuration).
45 changes: 45 additions & 0 deletions addons/automatic_updates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/

# shellcheck disable=2034,2059
true
SCRIPT_NAME="Automatic Updates"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh)

print_text_in_color "$ICyan" "Configuring automatic updates..."

# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode

# Check if root
root_check

msg_box "This option will update your server every week on Saturdays at $AUT_UPDATES_TIME:00.
The update will run the built in script '$SCRIPTS/update.sh' which will update both the server packages and Wordpress itself.

Please keep in mind that automatic updates might fail hence it's
important to have a proper backup in place if you plan to run this option.

You can disable the automatic updates by entering the crontab file like this:
'sudo crontab -e -u root'
Then just put a hash (#) in front of the row that you want to disable.

In the next step you will be able to choose to proceed or exit." "$SUBTITLE"

if yesno_box_yes "Do you want to enable automatic updates?"
then
# TODO: delete the following line after a few releases. It was copied to the install-script.
touch $VMLOGS/update.log
crontab -u root -l | { cat; echo "0 $AUT_UPDATES_TIME * * 6 $SCRIPTS/update.sh >> $VMLOGS/update.log"; } | crontab -u root -
if yesno_box_yes "Do you want to reboot your server after every update? *recommended*"
then
sed -i "s|exit|/sbin/shutdown -r +1|g" "$SCRIPTS"/update.sh
echo "exit" >> "$SCRIPTS"/update.sh
fi
msg_box "Please remember to keep backups in case something should go wrong, you never know." "$SUBTITLE"
fi
44 changes: 44 additions & 0 deletions addons/locales.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/

# shellcheck disable=2034,2059,1091
true
SCRIPT_NAME="Locales"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh)

# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode

# Must be root
root_check

##################################################################

# Set locales
print_text_in_color "$ICyan" "Setting locales..."
if [ "$KEYBOARD_LAYOUT" = "us" ]
then
print_text_in_color "$ICyan" "US locales are already set."
elif [ "$KEYBOARD_LAYOUT" = "se" ]
then
sudo locale-gen "sv_SE.UTF-8" && sudo dpkg-reconfigure --frontend=noninteractive locales
elif [ "$KEYBOARD_LAYOUT" = "de" ]
then
sudo locale-gen "de_DE.UTF-8" && sudo dpkg-reconfigure --frontend=noninteractive locales
elif [ "$KEYBOARD_LAYOUT" = "us" ]
then
sudo locale-gen "en_US.UTF-8" && sudo dpkg-reconfigure --frontend=noninteractive locales
elif [ "$KEYBOARD_LAYOUT" = "fr" ]
then
sudo locale-gen "fr_FR.UTF-8" && sudo dpkg-reconfigure --frontend=noninteractive locales
elif [ "$KEYBOARD_LAYOUT" = "ch" ]
then
sudo locale-gen "de_CH.UTF-8" && sudo dpkg-reconfigure --frontend=noninteractive locales
fi

# TODO: "localectl list-x11-keymap-layouts" and pair with "cat /etc/locale.gen | grep UTF-8"
58 changes: 58 additions & 0 deletions addons/locate_mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/

# shellcheck disable=2034,2059
true
SCRIPT_NAME="Locate Mirror"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh)

# Must be root
root_check

# Use another method if the new one doesn't work
if [ -z "$REPO" ]
then
REPO=$(apt update -q4 && apt-cache policy | grep http | tail -1 | awk '{print $2}')
fi

# Check where the best mirrors are and update
msg_box "To make downloads as fast as possible when updating Ubuntu \
you should have download mirrors that are as close to you as possible.

Please note that there are no gurantees that the download mirrors \
this script will find are staying up for the lifetime of this server.
Because of this, we don't recommend to change the mirror, except you live far away from the default mirror.

This is the method used: https://github.com/jblakeman/apt-select"
msg_box "Your current server repository is: $REPO"

if ! yesno_box_no "Do you want to try to find a better mirror?"
then
print_text_in_color "$ICyan" "Keeping $REPO as mirror..."
sleep 1
else
if [[ "$KEYBOARD_LAYOUT" =~ ,|/|_ ]]
then
msg_box "Your keymap contains more than one language, or a special character. ($KEYBOARD_LAYOUT)
This script can only handle one keymap at the time.\nThe default mirror ($REPO) will be kept."
exit 1
fi
print_text_in_color "$ICyan" "Locating the best mirrors..."
curl_to_dir https://bootstrap.pypa.io get-pip.py /tmp
install_if_not python3
install_if_not python3-testresources
install_if_not python3-distutils
cd /tmp && python3 get-pip.py
pip install \
--upgrade pip \
apt-select
check_command apt-select -m up-to-date -t 4 -c -C "$KEYBOARD_LAYOUT"
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup && \
if [ -f sources.list ]
then
sudo mv sources.list /etc/apt/
fi
msg_box "The apt-mirror was successfully changed."
fi
51 changes: 24 additions & 27 deletions static/redis-server-ubuntu.sh → addons/redis-server-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
# shellcheck disable=2034,2059
true
SCRIPT_NAME="Redis Server Ubuntu"
# shellcheck source=lib.sh
. <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh)
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh)

# T&M Hansson IT AB © - 2019, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/

# Check for errors + debug code and abort if something isn't right
# 1 = ON
Expand All @@ -16,26 +17,24 @@ debug_mode
root_check

# Check Ubuntu version
print_text_in_color "$ICyan" "Checking server OS and version..."
if [ "$OS" != 1 ]
if ! version 16.04 "$DISTRO" 20.04.6
then
print_text_in_color "$IRed" "Ubuntu Server is required to run this script."
print_text_in_color "$IRed" "Please install that distro and try again."
msg_box "Your current Ubuntu version is $DISTRO but must be between 16.04 - 20.04.6 to run this script."
msg_box "Please contact us to get support for upgrading your server:
https://www.hanssonit.se/#contact
https://shop.hanssonit.se/"
exit 1
fi


if ! version 18.04 "$DISTRO" 18.04.4; then
print_text_in_color "$IRed" "Ubuntu version $DISTRO must be between 18.04 - 18.04.4"
exit
fi

# Check if dir exists
if [ ! -d $SCRIPTS ]
then
mkdir -p $SCRIPTS
fi


# Check the current PHPVER
check_php

# Install Redis
install_if_not php"$PHPVER"-dev
pecl channel-update pecl.php.net
Expand All @@ -44,26 +43,17 @@ then
msg_box "PHP module installation failed"
exit 1
else
print_text_in_color "$IGreen" "PHP module installation OK!"
printf "${IGreen}\nPHP module installation OK!${Color_Off}\n"
fi
install_if_not redis-server

# Setting direct to PHP-FPM as it's installed with PECL (globally doesn't work)
print_text_in_color "$ICyan" "Adding extension=redis.so to $PHP_INI..."
# FPM is needed for frontend
echo 'extension=redis.so' >> /etc/php/"$PHPVER"/fpm/php.ini
# CLI is needed for backend
echo 'extension=redis.so' >> /etc/php/"$PHPVER"/cli/php.ini
service php"$PHPVER"-fpm restart
service nginx restart

# Install Redis
if ! apt -y install redis-server
then
print_text_in_color "$IRed" "Installation failed."
sleep 3
exit 1
else
print_text_in_color "$IGreen" "Redis installation OK!"
fi
restart_webserver

## Redis performance tweaks ##
if ! grep -Fxq "vm.overcommit_memory = 1" /etc/sysctl.conf
Expand All @@ -77,13 +67,19 @@ then
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
fi

# Raise TCP backlog
#if ! grep -Fxq "net.core.somaxconn" /proc/sys/net/core/somaxconn
#then
# sed -i "s|net.core.somaxconn.*||g" /etc/sysctl.conf
# sysctl -w net.core.somaxconn=512
# echo "net.core.somaxconn = 512" >> /etc/sysctl.conf
#fi
sed -i "s|# unixsocket .*|unixsocket $REDIS_SOCK|g" $REDIS_CONF
sed -i "s|# unixsocketperm .*|unixsocketperm 777|g" $REDIS_CONF
sed -i "s|^port.*|port 0|" $REDIS_CONF
sed -i "s|# requirepass .*|requirepass $(cat $REDISPTXT)|g" $REDIS_CONF
sed -i 's|# rename-command CONFIG ""|rename-command CONFIG ""|' $REDIS_CONF
redis-cli SHUTDOWN
rm -f $REDISPTXT

# Secure Redis
chown redis:root /etc/redis/redis.conf
Expand All @@ -92,5 +88,6 @@ chmod 600 /etc/redis/redis.conf
apt update -q4 & spinner_loading
apt autoremove -y
apt autoclean
rm -f "$REDISPTXT"

exit
Loading