Advertisement
scrizo

LAMP/ WORDPRESS Install

Aug 1st, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.39 KB | None | 0 0
  1. # Install the LAMP stack
  2. #!/bin/bash
  3.  
  4. if [ "$EUID" -ne 0 ]
  5. then
  6.         echo 'Please run with sudo or as root.'
  7.         exit 1
  8. fi
  9.  
  10.  
  11.  
  12. # Install Apache, PHP, and PHP Modules
  13. echo "Installing LAMP"
  14. yum -q install -y httpd php php-mysql
  15.  
  16. # Start and enable the web server
  17. echo "Starting Services"
  18. systemctl start httpd
  19. systemctl enable httpd
  20.  
  21. # Install MariaDB
  22. echo "Installing MariaDB"
  23. yum -q install -y mariadb-server
  24.  
  25. # Start and enable MariaDB
  26. echo "Starting MariaDB"
  27. systemctl start mariadb
  28. systemctl enable mariadb
  29.  
  30. # Create a wordpress database
  31. echo "Creating a wordpress database"
  32. mysqladmin create wordpress
  33.  
  34. # Create a user for the wordpress database
  35. echo "Creating a user for wordpress DB"
  36. mysql -e "GRANT ALL on wordpress.* to wordpress@localhost identified by 'wordpress123';"
  37. mysql -e "FLUSH PRIVILEGES;"
  38.  
  39. # Remove the test DB privileges.
  40. echo "Removing test DB privs"
  41. mysql -e "DELETE FROM mysql.db where db='test' or db='test\\_%'"
  42.  
  43. # Drop the test DB
  44. echo "Dropping test DB"
  45. mysqladmin drop -f test
  46.  
  47. # Remove anonymous DB users.
  48. echo "Remove anonymous DB users"
  49. mysql -e "delete from mysql.user where user='';"
  50.  
  51. # Remove remote root DB account access.
  52. echo "Remove remote root db account access"
  53. mysql -e "delete from mysql.user where user='root' and host not in ('localhost', '127.0.0.1', '::1');"
  54.  
  55. # Set a root DB password
  56. echo "Set a root db password"
  57. mysql -e "update mysql.user set password=password('root123') where user='root';"
  58.  
  59. # Flush the privileges
  60. echo "Flush privs"
  61. mysql -e "flush privileges;"
  62.  
  63. # Download and extract WordPress
  64. echo "Download and extract Wordpress"
  65. TMP_DIR=$(mktemp -d)
  66. cd $TMP_DIR
  67. curl -sOL https://wordpress.org/latest.tar.gz
  68. tar zxf latest.tar.gz
  69. mv wordpress/* /var/www/html
  70.  
  71. # Clean up
  72. echo "Clean up"
  73. cd /
  74. rm -rf $TMP_DIR
  75.  
  76. # Install the wp-cli tool
  77. echo "Install wp-cli tool"
  78. curl -sOL https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  79. chmod +x wp-cli.phar
  80. mv wp-cli.phar /usr/local/bin/wp
  81. chmod 755 /usr/local/bin/wp
  82.  
  83. # Configure Wordpress
  84. echo "Configure Wordpress"
  85. cd /var/www/html
  86. /usr/local/bin/wp core config --dbname=wordpress --dbuser=wordpress --dbpass=wordpress123
  87.  
  88. # Install wordpress
  89. echo "Install wordpress"
  90. /usr/local/bin/wp core install --url=http://localhost \
  91. --title="Blog" --admin_user="admin" --admin_password="admin" \
  92. --admin_email="root@localhost.localdomain"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement