Last active
January 15, 2018 09:21
-
-
Save m0veax/d70333deecd43afa6c6f55b203cb073d to your computer and use it in GitHub Desktop.
Vagrant Setup for setting up suitecrm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Creating empty database..." | |
sudo mysqladmin -u root --password=yourrootpassword create suitecrm | |
sudo mysql -u root -pyourrootpassword -- <<MYSQL | |
CREATE USER 'suitecrm'@'localhost' IDENTIFIED BY 'suitecrm'; | |
GRANT ALL ON suitecrm.* TO 'suitecrm'@'localhost'; | |
FLUSH PRIVILEGES; | |
MYSQL | |
cat /vagrant/suitecrm.sql | mysql -u root -pyourrootpassword suitecrm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "apt-get update..." | |
sudo apt-get update > /dev/null | |
echo "install php 5.6 repo" | |
sudo apt-get install -y software-properties-common > /dev/null | |
sudo add-apt-repository ppa:ondrej/php > /dev/null | |
echo "apt-get update..." | |
sudo apt-get update > /dev/null | |
echo "apt-get install..." | |
sudo apt-get install -y build-essential apache2 php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-zip php5.6-imap php5.6-gd php5.6-curl libapache2-mod-php5.6 php5.6-cli | |
echo "finished" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Credit: https://serverfault.com/questions/783527/non-interactive-silent-install-of-mysql-5-7-on-ubuntu-16-04-lts | |
export DEBIAN_FRONTEND=noninteractive | |
sudo apt-get update > /dev/null | |
MYSQL_ROOT_PASSWORD='yourrootpassword' # SET THIS! Avoid quotes/apostrophes in the password, but do use lowercase + uppercase + numbers + special chars | |
# Install MySQL | |
# Suggestion from @dcarrith (http://serverfault.com/a/830352/344471): | |
echo debconf mysql-server/root_password password $MYSQL_ROOT_PASSWORD | sudo debconf-set-selections | |
echo debconf mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD | sudo debconf-set-selections | |
#sudo debconf-set-selections <<< "mysql-server-5.7 mysql-server/root_password password $MYSQL_ROOT_PASSWORD" | |
#sudo debconf-set-selections <<< "mysql-server-5.7 mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD" | |
sudo apt-get -qq install mysql-server expect # > /dev/null # Install MySQL quietly | |
echo "MySQL Root Password: $MYSQL_ROOT_PASSWORD\r" | |
# Build Expect script | |
tee ~/secure_our_mysql.sh > /dev/null << EOF | |
spawn $(which mysql_secure_installation) | |
expect "Enter password for user root:" | |
send "$MYSQL_ROOT_PASSWORD\r" | |
expect "Press y|Y for Yes, any other key for No:" | |
send "n\r" | |
expect "Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:" | |
send "0\r" | |
expect "Change the password for root ? ((Press y|Y for Yes, any other key for No) :" | |
send "y\r" | |
expect "New password:" | |
send "$MYSQL_ROOT_PASSWORD\r" | |
expect "Re-enter new password:" | |
send "$MYSQL_ROOT_PASSWORD\r" | |
expect "Remove anonymous users? (Press y|Y for Yes, any other key for No) :" | |
send "y\r" | |
expect "Disallow root login remotely? (Press y|Y for Yes, any other key for No) :" | |
send "y\r" | |
expect "Remove test database and access to it? (Press y|Y for Yes, any other key for No) :" | |
send "y\r" | |
expect "Reload privilege tables now? (Press y|Y for Yes, any other key for No) :" | |
send "y\r" | |
EOF | |
# Run Expect script. | |
# This runs the "mysql_secure_installation" script which removes insecure defaults. | |
sudo expect ~/secure_our_mysql.sh | |
# SuiteCRM needed MySQL Configs | |
echo "[mysqld] | |
max_allowed_packet=20M | |
innodb_log_file_size=512M" >> /etc/mysql/my.cnf | |
/etc/init.d/mysql restart | |
# Cleanup | |
rm -v ~/secure_our_mysql.sh # Remove the generated Expect script | |
#sudo apt-get -qq purge expect > /dev/null # Uninstall Expect, commented out in case you need Expect | |
echo "MySQL setup completed. Insecure defaults are gone. Please remove this script manually when you are done with it (or at least remove the MySQL root password that you put inside it." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "box-cutter/ubuntu1604" | |
config.vm.network "public_network", ip: "192.168.2.253" | |
config.vm.network "forwarded_port", guest: 80, host: 3001, host_ip: "127.0.0.1", protocol: 'tcp' | |
config.vm.synced_folder "source/suitecrm/", "/var/www/html/suitecrm", owner: "www-data", group: "www-data" | |
config.vm.provision "shell", | |
path: "mysql.sh" | |
config.vm.provision "shell", | |
path: "init.sh" | |
config.vm.provision "shell", | |
path: "db.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Important is to run the setup one time by hand and include the dump in the same folder as Vagrantfile with name suitecrm.sql