Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # Usage : wp-create.sh my_site
- #
- # Will create a mysql user and database,
- # then download and install latest wordpress
- #
- PLUGINS="contact-form-7 contact-form-cfdb7"
- LOCALE="fr_FR"
- HOST="127.0.0.1" # localhost
- USER=root
- PASS= # empty to ask
- MAIL="contact@$PRJ.com"
- PRJ=$1
- URL=$2
- MYSQL="mysql -u$USER -p$PASS -e "
- #export PATH=/usr/local/mysql/bin:$PATH # fix macos mysql path
- if [[ $# -eq 0 ]] ; then
- echo "Usage: '$0 example.com' will create 'example.com' database, user and wordpress website"
- exit 1
- fi
- #
- # MySQL
- #
- # Create mysql user and database
- echo "Create '$PRJ' database and user (password:'$PRJ') as mysql $USER user"
- SQL="CREATE USER '$PRJ'@'localhost' IDENTIFIED WITH mysql_native_password AS '***';"
- #SQL="$SQL GRANT USAGE ON *.* TO '$PRJ'@'localhost';"
- SQL="$SQL CREATE DATABASE IF NOT EXISTS \`$PRJ\`;"
- SQL="$SQL GRANT ALL PRIVILEGES ON \`$PRJ\`.* TO '$PRJ'@'localhost';"
- echo "> $SQL"
- if $MYSQL "$SQL"; then
- echo "> Success !"
- else
- echo "> Query failed :("
- exit
- fi
- #
- # Wordpress
- #
- if mkdir $PRJ; then
- cd $PRJ
- echo "Installing wordpress"
- else
- echo "Install failed : folder '$PRJ' already exists"
- exit
- fi
- # Download and setup wordpress
- wp core download --locale=$LOCALE
- wp core config --dbname=$PRJ --dbuser=$PRJ --dbpass=$PRJ --dbhost=$HOST --dbprefix=wp_
- wp core install --url=$URL --title="$PRJ" --admin_user=admin --admin_password=admin --admin_email="$MAIL"
- # Install plugins
- wp plugin delete hello
- wp plugin install $PLUGINS --activate
- # Fix uploads permissions
- # sudo chown -R _www:_www $PRJ
- chmod -R og+w $PRJ/wp-content
- #
- # Result
- #
- echo "Project : $PRJ"
- echo " "
- echo "MySQL dbname: $PRJ"
- echo "MySQL user: $PRJ"
- echo "MySQL passord: $PRJ"
- echo "MySQL host: $HOST"
- echo ""
- echo "WP user: $PRJ"
- echo "WP password: $PRJ"
- echo "WP email: $MAIL"
- echo "WP path: $PWD"
- echo "WP url: $URL"
- echo ""
Add Comment
Please, Sign In to add comment