Guest User

Untitled

a guest
Dec 15th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Usage : wp-create.sh my_site
  4. #
  5. # Will create a mysql user and database,
  6. # then download and install latest wordpress
  7. #
  8.  
  9. PLUGINS="contact-form-7 contact-form-cfdb7"
  10. LOCALE="fr_FR"
  11.  
  12. HOST="127.0.0.1" # localhost
  13. USER=root
  14. PASS= # empty to ask
  15. MAIL="contact@$PRJ.com"
  16. PRJ=$1
  17. URL=$2
  18. MYSQL="mysql -u$USER -p$PASS -e "
  19.  
  20. #export PATH=/usr/local/mysql/bin:$PATH # fix macos mysql path
  21.  
  22. if [[ $# -eq 0 ]] ; then
  23. echo "Usage: '$0 example.com' will create 'example.com' database, user and wordpress website"
  24. exit 1
  25. fi
  26.  
  27. #
  28. # MySQL
  29. #
  30.  
  31. # Create mysql user and database
  32. echo "Create '$PRJ' database and user (password:'$PRJ') as mysql $USER user"
  33. SQL="CREATE USER '$PRJ'@'localhost' IDENTIFIED WITH mysql_native_password AS '***';"
  34. #SQL="$SQL GRANT USAGE ON *.* TO '$PRJ'@'localhost';"
  35. SQL="$SQL CREATE DATABASE IF NOT EXISTS \`$PRJ\`;"
  36. SQL="$SQL GRANT ALL PRIVILEGES ON \`$PRJ\`.* TO '$PRJ'@'localhost';"
  37. echo "> $SQL"
  38.  
  39. if $MYSQL "$SQL"; then
  40. echo "> Success !"
  41. else
  42. echo "> Query failed :("
  43. exit
  44. fi
  45.  
  46. #
  47. # Wordpress
  48. #
  49.  
  50. if mkdir $PRJ; then
  51. cd $PRJ
  52. echo "Installing wordpress"
  53. else
  54. echo "Install failed : folder '$PRJ' already exists"
  55. exit
  56. fi
  57.  
  58. # Download and setup wordpress
  59. wp core download --locale=$LOCALE
  60. wp core config --dbname=$PRJ --dbuser=$PRJ --dbpass=$PRJ --dbhost=$HOST --dbprefix=wp_
  61. wp core install --url=$URL --title="$PRJ" --admin_user=admin --admin_password=admin --admin_email="$MAIL"
  62.  
  63. # Install plugins
  64. wp plugin delete hello
  65. wp plugin install $PLUGINS --activate
  66.  
  67. # Fix uploads permissions
  68. # sudo chown -R _www:_www $PRJ
  69. chmod -R og+w $PRJ/wp-content
  70.  
  71. #
  72. # Result
  73. #
  74.  
  75. echo "Project : $PRJ"
  76. echo " "
  77. echo "MySQL dbname: $PRJ"
  78. echo "MySQL user: $PRJ"
  79. echo "MySQL passord: $PRJ"
  80. echo "MySQL host: $HOST"
  81. echo ""
  82. echo "WP user: $PRJ"
  83. echo "WP password: $PRJ"
  84. echo "WP email: $MAIL"
  85. echo "WP path: $PWD"
  86. echo "WP url: $URL"
  87. echo ""
Add Comment
Please, Sign In to add comment