Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
1,052
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #!/bin/bash
  2. echo "A Wordpress website creation script"
  3. read -p "Website Name: " WEBNAME
  4. read -p "Website Url (excluding www prefix): " WEBURL
  5. read -p "PHP-FPM Port: " PORT
  6. read -p "Database Name: " DBNAME
  7. read -p "Database User: " DBUSER
  8. read -p "Database Password: " DBPWD
  9. echo "Creating database..."
  10. mysql -uroot -pYourRootPasswordHere <<EOF
  11. CREATE DATABASE $DBNAME;
  12. CREATE USER $DBUSER@localhost IDENTIFIED BY "$DBPWD";
  13. GRANT ALL PRIVILEGES ON $DBNAME.* TO $DBUSER@localhost IDENTIFIED BY "$DBPWD";
  14. FLUSH PRIVILEGES;
  15. exit
  16. EOF
  17. echo "Creating nginx config..."
  18. cat /home/user/wp >> /etc/nginx/sites-enabled/$WEBNAME
  19. echo "Replacing values..."
  20. sed -i 's/domain.ext/'$WEBURL'/g' /etc/nginx/sites-enabled/$WEBNAME
  21. sed -i 's/900x/'$PORT'/g' /etc/nginx/sites-enabled/$WEBNAME
  22. sed -i 's/site_files_here/'$WEBNAME'/g' /etc/nginx/sites-enabled/$WEBNAME
  23. echo "Creating wordpress files..."
  24. cp -a /home/user/downloads/wordpress /usr/share/nginx/$WEBNAME
  25. chown www-data:www-data /usr/share/nginx/$WEBNAME -R
  26. echo "Replacing wp-config.php values..."
  27. sed -i 's/database_name_here/'$DBNAME'/g' /usr/share/nginx/$WEBNAME/wp-config.php
  28. sed -i 's/username_here/'$DBUSER'/g' /usr/share/nginx/$WEBNAME/wp-config.php
  29. sed -i 's/password_here/'$DBPWD'/g' /usr/share/nginx/$WEBNAME/wp-config.php
  30. echo "Creating php-fpm pool config..."
  31. cat /home/user/default.conf >> /etc/php/7.0/fpm/pool.d/$WEBNAME.conf
  32. echo "Replacing values..."
  33. sed -i 's/pool_name_here/'$WEBNAME'/g' /etc/php/7.0/fpm/pool.d/$WEBNAME.conf
  34. sed -i 's/900x/'$PORT'/g' /etc/php/7.0/fpm/pool.d/$WEBNAME.conf
  35. echo "Restarting services..."
  36. service php7.0-fpm restart
  37. service nginx restart
  38. certbot --nginx -d www.$WEBURL
  39. echo "All done! =D"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement