Advertisement
Guest User

Untitled

a guest
Apr 5th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.67 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Install WordPress on a Debian/Ubuntu VPS
  4. #
  5.  
  6. # Create MySQL database
  7. read -p "Enter your MySQL root password: " rootpass
  8. read -p "Database name: " dbname
  9. read -p "Database username: " dbuser
  10. read -p "Enter a password for user $dbuser: " userpass
  11. echo "CREATE DATABASE $dbname;" | mysql -u root -p$rootpass
  12. echo "CREATE USER '$dbuser'@'localhost' IDENTIFIED BY '$userpass';" | mysql -u root -p$rootpass
  13. echo "GRANT ALL PRIVILEGES ON $dbname.* TO '$dbuser'@'localhost';" | mysql -u root -p$rootpass
  14. echo "FLUSH PRIVILEGES;" | mysql -u root -p$rootpass
  15. echo "New MySQL database is successfully created"
  16.  
  17. # Download, unpack and configure WordPress
  18. read -r -p "Enter your WordPress URL? [e.g. mywebsite.com]: " wpURL
  19. wget -q -O - "http://wordpress.org/latest.tar.gz" | tar -xzf - -C /var/www --transform s/wordpress/$wpURL/
  20. chown www-data: -R /var/www/$wpURL && cd /var/www/$wpURL
  21. cp wp-config-sample.php wp-config.php
  22. chmod 640 wp-config.php
  23. mkdir uploads
  24. sed -i "s/database_name_here/$dbname/;s/username_here/$dbuser/;s/password_here/$userpass/" wp-config.php
  25.  
  26. # Create Apache virtual host
  27. echo "
  28. ServerName $wpURL
  29. ServerAlias www.$wpURL
  30. DocumentRoot /var/www/$wpURL
  31. DirectoryIndex index.php
  32.  
  33. Options FollowSymLinks
  34. AllowOverride All
  35.  
  36. ErrorLog ${APACHE_LOG_DIR}/error.log
  37. CustomLog ${APACHE_LOG_DIR}/access.log combined
  38. " > /etc/apache2/sites-available/$wpURL
  39.  
  40. # Enable the site
  41. a2ensite $wpURL
  42. service apache2 restart
  43.  
  44. # Output
  45. WPVER=$(grep "wp_version = " /var/www/$wpURL/wp-includes/version.php |awk -F\' '{print $2}')
  46. echo -e "\nWordPress version $WPVER is successfully installed!"
  47. echo -en "\aPlease go to http://$wpURL and finish the installation\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement