Giter VIP home page Giter VIP logo

box_apache_config_files's Introduction

box_apache_config_files

Use this with scotch box

Install

  • Install virtualbox and vagrant
  • Clone scotch box with this:
git clone https://github.com/scotch-io/scotch-box.git new-project

Up

Run cd new-project and vagrant up

Update php/mysql

  • Update mysql
  • Update php along with this:
sudo apt-get install -y php7.0 php7.0-fpm php7.0-mysql php7.0-pgsql php-redis php-curl libapache2-mod-php7.0 php7.0-mbstring php7.0-mcrypt php7.0-xml php7.0-zip php7.0-soap htop

Domains + SSL

    config.hostsupdater.aliases = ["local.website.com"]

    config.vm.provider :virtualbox do |p|
      # p.gui = true
      p.customize ["modifyvm", :id, "--memory", "2048"]
      p.customize ["modifyvm", :id, "--cpuexecutioncap", "80"]
      p.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
    end

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

      ## ------------------------------------------------------------------------------------ ##
      ## FIRST PART (run once and comment)                                                    ##
      ## ------------------------------------------------------------------------------------ ##

      echo "Adding composer to PATH"
      export PATH="~/.composer/vendor/bin:$PATH"

      echo "Activate SSL"
      sudo a2enmod ssl
      sudo service apache2 restart
      sudo mkdir /etc/apache2/ssl

      echo "Copy SSL files"
      sudo cp /var/www/box_apache_config_files/apache.crt /etc/apache2/ssl/apache.crt
      sudo cp /var/www/box_apache_config_files/apache.key /etc/apache2/ssl/apache.key
      sudo cp /var/www/box_apache_config_files/vhost-custom-ssl.conf /etc/apache2/sites-available/vhost-custom-ssl.conf

      ## ------------------------------------------------------------------------------------ ##
      ## SECOND PART (run each time a new domain is added)                                    ##
      ## ------------------------------------------------------------------------------------ ##

      ## SET DOMAINS (separated by blank spaces)
      DOMAINS=("local.website.com")

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

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

        ## Comment if directory is already created
        echo "Creating directory for $DOMAIN..."
        sudo mkdir -p /var/www/public/$DOMAIN

        echo "Disabling $DOMAIN. Will probably tell you to restart Apache..."
        sudo a2dissite $DOMAIN.conf

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

        echo "Removing vhost config for $DOMAIN..."
        sudo rm /etc/apache2/sites-available/$DOMAIN.conf

        echo "Creating vhost config for $DOMAIN..."
        sudo cp /etc/apache2/sites-available/vhost-custom-ssl.conf /etc/apache2/sites-available/$DOMAIN.conf

        echo "Updating vhost config for $DOMAIN..."
        sudo sed -i s,scotchbox.local,$DOMAIN,g /etc/apache2/sites-available/$DOMAIN.conf
        sudo sed -i s,/var/www/public,/var/www/public/$DOMAIN,g /etc/apache2/sites-available/$DOMAIN.conf

        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
  • Change / add domain(s) - default local.website.com
  • vagrant provision

DB Import

  • Create DB
  • Run inside box:
mysql -u root [database] < /var/www/box_apache_config_files/database_dump.sql

Enjoy

Sources

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.