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,47 +41,45 @@ install_site() {
|
||||
setup_directories
|
||||
|
||||
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
|
||||
read -p "Enter admin email: " ADMIN_EMAIL
|
||||
if validate_email "$ADMIN_EMAIL"; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
read -p "Enter admin username: " ADMIN_USER
|
||||
read -p "Enter admin username: " ADMIN_USER
|
||||
|
||||
read -s -p "Enter password (press Enter for random password): " ADMIN_PASSWORD
|
||||
echo
|
||||
read -s -p "Enter password (press Enter for random password): " ADMIN_PASSWORD
|
||||
echo
|
||||
|
||||
if [ -z "$ADMIN_PASSWORD" ]; then
|
||||
if [ -z "$ADMIN_PASSWORD" ]; then
|
||||
ADMIN_PASSWORD=$(generate_password)
|
||||
echo "Generated password: $ADMIN_PASSWORD"
|
||||
fi
|
||||
fi
|
||||
|
||||
read -p "Enter site title: " SITE_TITLE
|
||||
read -p "Enter site title: " SITE_TITLE
|
||||
|
||||
MYSQL_ROOT_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"
|
||||
cd "$WP_PROJECT_DIR"
|
||||
|
||||
create_docker_compose "$DOMAIN" "$MYSQL_ROOT_PASSWORD" "$MYSQL_PASSWORD"
|
||||
create_caddy_config "$DOMAIN"
|
||||
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"
|
||||
MYSQL_ROOT_PASSWORD=$(openssl rand -base64 32)
|
||||
MYSQL_PASSWORD=$(openssl rand -base64 32)
|
||||
|
||||
mkdir -p "$WP_PROJECT_DIR"
|
||||
cd "$WP_PROJECT_DIR"
|
||||
|
||||
|
||||
create_docker_compose "$DOMAIN" "$MYSQL_ROOT_PASSWORD" "$MYSQL_PASSWORD"
|
||||
create_caddy_config "$DOMAIN"
|
||||
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"
|
||||
|
||||
|
||||
while true; do
|
||||
|
||||
@@ -33,6 +33,38 @@ create_caddy_docker_compose() {
|
||||
admin 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
|
||||
import sites/*.caddy
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
${DOMAIN} {
|
||||
#reverse_proxy wordpress_${DOMAIN}:80
|
||||
|
||||
tls internal
|
||||
#tls internal
|
||||
root * /var/www/${DOMAIN}/html
|
||||
encode zstd gzip
|
||||
|
||||
@@ -18,5 +17,6 @@ ${DOMAIN} {
|
||||
X-Frame-Options "SAMEORIGIN"
|
||||
X-Content-Type-Options "nosniff"
|
||||
}
|
||||
import wordpress
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ while [ "$(docker inspect --format='{{.State.Health.Status}}' db_${DOMAIN})" !=
|
||||
sleep 5
|
||||
done
|
||||
|
||||
|
||||
echo "Installing WordPress..."
|
||||
wpcli core install \
|
||||
if ! wpcli core is-installed ; then
|
||||
echo "Installing WordPress..."
|
||||
wpcli core install \
|
||||
--url="https://${DOMAIN}" \
|
||||
--title="${SITE_TITLE}" \
|
||||
--admin_user="${ADMIN_USER}" \
|
||||
@@ -21,10 +21,50 @@ wpcli core install \
|
||||
--admin_email="${ADMIN_EMAIL}" \
|
||||
--skip-email
|
||||
|
||||
echo "Installing and activating plugins..."
|
||||
wpcli plugin install wordfence --activate
|
||||
wpcli theme install twentytwentyfour --activate
|
||||
wpcli plugin update --all
|
||||
wpcli theme update --all
|
||||
echo "Installing and activating plugins..."
|
||||
wpcli plugin install wordfence cache-enabler --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
|
||||
|
||||
echo "WordPress setup completed!"
|
||||
wpcli theme install kadence --activate
|
||||
wpcli plugin 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!"
|
||||
else
|
||||
echo "WordPress is already installed. Exiting now..."
|
||||
fi
|
||||
Reference in New Issue
Block a user