Last active
February 1, 2022 02:39
-
-
Save mt8/7ca7797d7cb266195a476c094056b497 to your computer and use it in GitHub Desktop.
Local by Flywheel でインストールしたWordPresssをサブディレクトリに移動する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" = "" ] | |
then | |
echo "please set sub dir name" | |
exit 1 | |
fi | |
echo "move your wp to $1!" | |
OLD_WP_URL=`wp option get home --allow-root` | |
NEW_WP_URL="$OLD_WP_URL/$1" | |
NEW_WP_DIR="/app/public/$1" | |
echo "old wp url is...$OLD_WP_URL" | |
echo "new wp url is...$NEW_WP_URL" | |
echo "new wp dir is...$NEW_WP_DIR" | |
echo "[wp search-replace] start" | |
wp search-replace $OLD_WP_URL $NEW_WP_URL --allow-root --path=/app/public | |
echo "[wp search-replace] end" | |
echo "[move wp files to new dir] start" | |
mkdir -p $NEW_WP_DIR | |
mv /app/public/* $NEW_WP_DIR | |
echo "[move wp files to new dir] end" | |
echo "[change confs] start" | |
cp -f /etc/nginx/includes/wordpress.conf /etc/nginx/includes/wordpress.conf.bk | |
cp -f ~/.bashrc ~/.bashrc.bk | |
source ~/.bashrc | |
sed -i -e "s#index.php#$1/index.php#g" /etc/nginx/includes/wordpress.conf | |
sed -i -e "s#wp --allow-root#wp --allow-root --path=$NEW_WP_DIR#g" ~/.bashrc | |
echo "[change confs] end" | |
echo "done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment