-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.sh
70 lines (57 loc) · 1.59 KB
/
provision.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Arguments
SERVER_NAME=${1}
PRODUCTION_SERVER_ALIAS=${2}
SERVER_ADMIN=${3}
# Basics
apt-get -y -q update
apt-get -y -q upgrade
## Nice colors
echo '[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls="ls -GFh"' > ~/.bash_profile
# Install packages
apt-get -y -q install git apache2 php5 php5-cli
# Setup webserver
echo '<VirtualHost *:80>
# General
ServerName '$SERVER_NAME'
ServerAlias www.'$SERVER_NAME'
ServerAdmin '$SERVER_ADMIN'
# Site
DocumentRoot /var/www/local
<Directory "/var/www/local">
Require all granted
</Directory>
# Logs
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
' > /etc/apache2/sites-available/000-local.conf
echo '<VirtualHost *:80>
# General
ServerName '$SERVER_NAME'
ServerAlias '$PRODUCTION_SERVER_ALIAS'
ServerAlias www.'$PRODUCTION_SERVER_ALIAS'
ServerAdmin '$SERVER_ADMIN'
# Site
DocumentRoot /var/www/production
<Directory "/var/www/production">
Require all granted
</Directory>
# Logs
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
' > /etc/apache2/sites-available/100-production.conf
a2enmod rewrite
a2dissite 000-default
a2dissite default-ssl
a2ensite 000-local
a2ensite 100-production
## Clean up virtual hosts
rm /etc/apache2/sites-available/000-default.conf
rm /etc/apache2/sites-available/default-ssl.conf
service apache2 restart