Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
create new wordpress project, ready to use | FOR DEV ONLY !! DO NOT USE IN PRODUCTION !! :D :D
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "You must run this script as SUDO"
exit 0
fi
if [ -d ./$1 ]
then
echo ">>> Folder Already exists"
# exit 1
else
echo ">>> [DOWNLOADING LAST WORDPRESS VERSION]"
git clone https://github.com/WordPress/WordPress.git $1
echo "[CREATE HOST FOR $1]"
echo "127.0.0.1 $1.local" >> /etc/hosts
sleep 1
fi
echo ">>> [MOVING INTO $1]"
cd $1
echo ">>> PLEASE ENTER ROOT PASSWORD FOR DATABASE CREATION <<<"
read rootpwd
DBNAME="$1"
echo ">>> [CREATE DATABASE AND USER]"
mariadb -uroot -p${rootpwd} -e "CREATE DATABASE ${DBNAME} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mariadb -uroot -p${rootpwd} -e "CREATE USER ${DBNAME}@localhost IDENTIFIED BY '${DBNAME}';"
mariadb -uroot -p${rootpwd} -e "GRANT ALL PRIVILEGES ON ${DBNAME}.* TO '${DBNAME}'@'localhost';"
mariadb -uroot -p${rootpwd} -e "FLUSH PRIVILEGES;"
sleep 1
echo ">>> [UPDATE FOLDERS RIGHTS]"
chown www-data ./* -Rf
chmod 775 -R ./*
sleep 1
echo ">>> [REMOVE GIT HIDDEN FOLDER]"
rm -rf .git
sleep 1
echo ">>> [PREPARE wp-config.php]"
cp wp-config-sample.php wp-config.php
sed -i -e "s/database_name_here/$1/g" ./wp-config.php
sed -i -e "s/username_here/$1/g" ./wp-config.php
sed -i -e "s/password_here/$1/g" ./wp-config.php
echo "define('FS_METHOD', 'direct');" >> ./wp-config.php
echo ">>> [CREATE APACHE CONFIG]"
cp /etc/apache2/sites-available/base.conf /etc/apache2/sites-available/$1.conf
sed -i -e "s/PROJECT_NAME/$1/g" /etc/apache2/sites-available/$1.conf
a2ensite $1.conf
service apache2 reload
echo "Done ! Happy Hacking !"
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.