scotch-io / scotch-box-pro

Scotch Box Pro is a preconfigured Vagrant Box with a full array of LAMP Stack features to get you up and running with Vagrant in no time.
MIT License
77 stars 27 forks source link

vhost multiple domains old code not working #13

Open ivcreative opened 6 years ago

ivcreative commented 6 years ago

The code here to use multiple domains on vagrant pro is not working the one from here

https://scotch.io/bar-talk/announcing-scotch-box-2-0-our-dead-simple-vagrant-lamp-stack-improved#toc-multiple-domains-virtual-hosts

How can we get this on this version?

patrick-yi-82 commented 6 years ago

    config.vm.provision "shell", inline: <<-SHELL

        ## Only thing you probably really care about is right here
        DOMAINS=("site1.local" "site2.local")

        ## Loop through all sites
        for ((i=0; i < ${#DOMAINS[@]}; i++)); do

            ## Current Domain
            DOMAIN=${DOMAINS[$i]}

            echo "Creating directory for $DOMAIN..."
            mkdir -p /var/www/$DOMAIN/public

            echo "Creating vhost config for $DOMAIN..."

            cat >/etc/apache2/sites-available/$DOMAIN.conf <<EOL
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName ${DOMAIN}
    ServerAlias www.${DOMAIN}
    DocumentRoot /var/www/${DOMAIN}/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EOL

            echo "Enabling $DOMAIN. Will probably tell you to restart Apache..."
            sudo a2ensite $DOMAIN.conf

            echo "So let's restart apache..."
            sudo service apache2 restart

        done

    SHELL
clotted commented 6 years ago

Thanks Patrick, worked for me. Vhosts on Scotchbox is awesome 👍

ivcreative commented 6 years ago

Thanks