mirror of
https://github.com/10h30/kazewp.git
synced 2026-05-12 15:21:20 +09:00
Update Caddy config and wp-setup.sh template
This commit is contained in:
@@ -41,7 +41,13 @@ install_site() {
|
|||||||
setup_directories
|
setup_directories
|
||||||
|
|
||||||
DOMAIN="$1"
|
DOMAIN="$1"
|
||||||
#db_prefix="$(openssl rand -base64 6)"_
|
|
||||||
|
WP_PROJECT_DIR="${WORDPRESS_DIR}/${DOMAIN}"
|
||||||
|
if [ -d "$WP_PROJECT_DIR" ]; then
|
||||||
|
echo -e "${RED}Directory ${WP_PROJECT_DIR} already exists!${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
@@ -66,24 +72,16 @@ read -p "Enter site title: " SITE_TITLE
|
|||||||
MYSQL_ROOT_PASSWORD=$(openssl rand -base64 32)
|
MYSQL_ROOT_PASSWORD=$(openssl rand -base64 32)
|
||||||
MYSQL_PASSWORD=$(openssl rand -base64 32)
|
MYSQL_PASSWORD=$(openssl rand -base64 32)
|
||||||
|
|
||||||
WP_PROJECT_DIR="${WORDPRESS_DIR}/${DOMAIN}"
|
|
||||||
if [ -d "$WP_PROJECT_DIR" ]; then
|
|
||||||
echo -e "${RED}Directory ${WP_PROJECT_DIR} already exists!${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$WP_PROJECT_DIR"
|
mkdir -p "$WP_PROJECT_DIR"
|
||||||
cd "$WP_PROJECT_DIR"
|
cd "$WP_PROJECT_DIR"
|
||||||
|
|
||||||
|
|
||||||
create_docker_compose "$DOMAIN" "$MYSQL_ROOT_PASSWORD" "$MYSQL_PASSWORD"
|
create_docker_compose "$DOMAIN" "$MYSQL_ROOT_PASSWORD" "$MYSQL_PASSWORD"
|
||||||
create_caddy_config "$DOMAIN"
|
create_caddy_config "$DOMAIN"
|
||||||
create_wp_setup "$DOMAIN" "$ADMIN_USER" "$ADMIN_PASSWORD" "$ADMIN_EMAIL" "$SITE_TITLE"
|
create_wp_setup "$DOMAIN" "$ADMIN_USER" "$ADMIN_PASSWORD" "$ADMIN_EMAIL" "$SITE_TITLE"
|
||||||
create_env_file "$DOMAIN" "$ADMIN_USER" "$ADMIN_PASSWORD" "$ADMIN_EMAIL" "$MYSQL_ROOT_PASSWORD" "$MYSQL_PASSWORD"
|
create_env_file "$DOMAIN" "$ADMIN_USER" "$ADMIN_PASSWORD" "$ADMIN_EMAIL" "$MYSQL_ROOT_PASSWORD" "$MYSQL_PASSWORD"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Do you want to (1) start services and set up WordPress automatically or (2) do it manually later? [1/2]: " SETUP_CHOICE
|
read -p "Do you want to (1) start services and set up WordPress automatically or (2) do it manually later? [1/2]: " SETUP_CHOICE
|
||||||
case $SETUP_CHOICE in
|
case $SETUP_CHOICE in
|
||||||
|
|||||||
@@ -33,6 +33,38 @@ create_caddy_docker_compose() {
|
|||||||
admin off
|
admin off
|
||||||
persist_config off
|
persist_config off
|
||||||
}
|
}
|
||||||
|
(wordpress) {
|
||||||
|
|
||||||
|
# Some static files Cache-Control.
|
||||||
|
@static {
|
||||||
|
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.json
|
||||||
|
}
|
||||||
|
header @static Cache-Control max-age=2592000
|
||||||
|
|
||||||
|
# Security
|
||||||
|
@forbidden {
|
||||||
|
not path /wp-includes/ms-files.php
|
||||||
|
path /wp-admin/includes/*.php
|
||||||
|
path /wp-includes/*.php
|
||||||
|
path /wp-config.php
|
||||||
|
path /wp-content/uploads/*.php
|
||||||
|
path /.user.ini
|
||||||
|
path /wp-content/debug.log
|
||||||
|
}
|
||||||
|
respond @forbidden "Access denied" 403
|
||||||
|
|
||||||
|
# Cache Enabler
|
||||||
|
@cache_enabler {
|
||||||
|
not header_regexp Cookie "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in"
|
||||||
|
not path_regexp "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]+-sitemap([0-9]+)?.xml)"
|
||||||
|
not method POST
|
||||||
|
not expression {query} != ''
|
||||||
|
}
|
||||||
|
|
||||||
|
route @cache_enabler {
|
||||||
|
try_files /wp-content/cache/cache-enabler/{host}{uri}/https-index.html /wp-content/cache/cache-enabler/{host}{uri}/index.html {path} {path}/index.php?{query}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Site configurations will be imported below
|
# Site configurations will be imported below
|
||||||
import sites/*.caddy
|
import sites/*.caddy
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
${DOMAIN} {
|
${DOMAIN} {
|
||||||
#reverse_proxy wordpress_${DOMAIN}:80
|
|
||||||
|
|
||||||
tls internal
|
#tls internal
|
||||||
root * /var/www/${DOMAIN}/html
|
root * /var/www/${DOMAIN}/html
|
||||||
encode zstd gzip
|
encode zstd gzip
|
||||||
|
|
||||||
@@ -18,5 +17,6 @@ ${DOMAIN} {
|
|||||||
X-Frame-Options "SAMEORIGIN"
|
X-Frame-Options "SAMEORIGIN"
|
||||||
X-Content-Type-Options "nosniff"
|
X-Content-Type-Options "nosniff"
|
||||||
}
|
}
|
||||||
|
import wordpress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ while [ "$(docker inspect --format='{{.State.Health.Status}}' db_${DOMAIN})" !=
|
|||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if ! wpcli core is-installed ; then
|
||||||
echo "Installing WordPress..."
|
echo "Installing WordPress..."
|
||||||
wpcli core install \
|
wpcli core install \
|
||||||
--url="https://${DOMAIN}" \
|
--url="https://${DOMAIN}" \
|
||||||
@@ -22,9 +22,49 @@ wpcli core install \
|
|||||||
--skip-email
|
--skip-email
|
||||||
|
|
||||||
echo "Installing and activating plugins..."
|
echo "Installing and activating plugins..."
|
||||||
wpcli plugin install wordfence --activate
|
wpcli plugin install wordfence cache-enabler --activate
|
||||||
wpcli theme install twentytwentyfour --activate
|
wpcli option update cache_enabler '{
|
||||||
|
"version": "1.8.15",
|
||||||
|
"use_trailing_slashes": 1,
|
||||||
|
"permalink_structure": "has_trailing_slash",
|
||||||
|
"cache_expires": 1,
|
||||||
|
"cache_expiry_time": 8,
|
||||||
|
"clear_site_cache_on_saved_post": 0,
|
||||||
|
"clear_site_cache_on_saved_comment": 0,
|
||||||
|
"clear_site_cache_on_saved_term": 0,
|
||||||
|
"clear_site_cache_on_saved_user": 0,
|
||||||
|
"clear_site_cache_on_changed_plugin": 0,
|
||||||
|
"convert_image_urls_to_webp": 0,
|
||||||
|
"mobile_cache": 0,
|
||||||
|
"compress_cache": 1,
|
||||||
|
"minify_html": 1,
|
||||||
|
"minify_inline_css_js": 1,
|
||||||
|
"excluded_post_ids": "",
|
||||||
|
"excluded_page_paths": "",
|
||||||
|
"excluded_query_strings": "",
|
||||||
|
"excluded_cookies": ""
|
||||||
|
}' --format=json
|
||||||
|
|
||||||
|
wpcli theme install kadence --activate
|
||||||
wpcli plugin update --all
|
wpcli plugin update --all
|
||||||
wpcli theme update --all
|
wpcli theme update --all
|
||||||
|
|
||||||
|
# List users
|
||||||
|
echo "== User List =="
|
||||||
|
wpcli user list
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Show installed plugin
|
||||||
|
echo "== Theme List =="
|
||||||
|
wpcli theme list
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Show installed plugin
|
||||||
|
echo "== Plugin List =="
|
||||||
|
wpcli plugin list
|
||||||
|
echo ""
|
||||||
|
|
||||||
echo "WordPress setup completed!"
|
echo "WordPress setup completed!"
|
||||||
|
else
|
||||||
|
echo "WordPress is already installed. Exiting now..."
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user