Skip to content

Instantly share code, notes, and snippets.

@JamesTheHacker
Created December 3, 2019 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesTheHacker/de4bbc2b69c4ea29a65d7f250545acad to your computer and use it in GitHub Desktop.
Save JamesTheHacker/de4bbc2b69c4ea29a65d7f250545acad to your computer and use it in GitHub Desktop.
# Change permissions for webroot directory
chown "${user}":www-data "${webroot}"
# Create auth.json required for magento installation
sudo -u "${user}" bash -c "mkdir ${home}/.composer"
sudo -u "${user}" bash -c "tee ${home}/.composer/auth.json" > /dev/null <<ILOVEBASH
{
"github-oauth": {
"github.com": "${github_pa_token}"
},
"http-basic": {
"repo.magento.com": {
"username": "${magento_public_key}",
"password": "${magento_private_key}"
}
}
}
ILOVEBASH
cd "${webroot}"
# Setup magento
sudo -H -u "${user}" bash -c "composer create-project --repository=https://repo.magento.com/ magento/project-community-edition ."
# Magento permissions
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data .
chmod u+x bin/magento
# Install Magento
sudo -u "${user}" bash -s <<ILOVEBASH
bin/magento setup:install \
--base-url=http://"${domain}" \
--db-host="${db_host}" \
--db-name="${db_name}" \
--db-user="${db_username}" \
--db-password="${db_password}" \
--admin-firstname=admin \
--admin-lastname=admin \
--admin-email="${webmaster_email}" \
--admin-user="${webmaster_username}" \
--admin-password="${webmaster_email}" \
--language="${magento_language}" \
--currency="${magento_currency}" \
--timezone="${magento_timezone}" \
--use-rewrites=1 \
--cleanup-database
ILOVEBASH
# Set mode
sudo -u ${user} bash -c "bin/magento deploy:mode:set ${mode}"
# Install sample data
sudo -H -u ${user} bash -c "bin/magento sampledata:deploy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment