Skip to content

Instantly share code, notes, and snippets.

@mt8 mt8/bash.sh
Created Jul 30, 2019

Embed
What would you like to do?
Local by Flywheel でインストールしたWordPresssをサブディレクトリに移動する
#!/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
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
You can’t perform that action at this time.