Skip to content

Commit cf59de9

Browse files
committed
Fix a typo in bootstrap.sh; make bootstrap work if ssl keys aren't in place, or if script is re-run
1 parent 9e4943e commit cf59de9

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

README.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,22 @@ manually configure a few things:
1515

1616
1. Edit <code>docroot/wp-config-local.php</code> and fill in values as
1717
needed by WordPress.
18-
2. Set up SSL keys in /etc/ssl/*
19-
3. Edit /etc/apache2/sites-available/(hostname) if needed (e.g. to
20-
change SSL key locations)
21-
4. Load DB data from another WordPress install (see below)
18+
2. Set up SSL keys in /etc/ssl/private. If there isn't a key for the
19+
hostname being set-up, then the Apache config will not include an
20+
SSL virtual host. Simply re-run the setup script if you add a key.
21+
3. If desired, load DB data from another WordPress install (see below)
22+
23+
### Editing the Apache config
24+
25+
If you need to edit the Apache config, the files are:
26+
27+
* <code>apache.conf</code>: CC Apache config in macro form.
28+
* <code>/etc/apache2/httpd.conf</code>: Includes the
29+
<code>apache.conf</code> file in this checkout.
30+
* <code>/etc/apache2/sites-available/<hostname></code>: Virtual host
31+
definition which uses a macro defined in <code>apache.conf</code> to
32+
pull in a lot of rules and settings. This file gets overwritten by
33+
the setup script, so if you edit it, do not run it again.
2234

2335
### Loading DB data
2436

scripts/bootstrap.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
44

55
function usage {
6-
echo "Usage: $0 <hostname>
6+
echo "Usage: $0 <hostname>"
77
exit 1
88
}
99
[ -z "$1" ] && usage;

scripts/bootstrap_server_ubuntu.sh

+10-6
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,27 @@ else
3636
fi
3737

3838
cat <<EOF > /etc/apache2/sites-available/${HOSTNAME}
39-
<VirtualHost *:8080>
39+
<VirtualHost ${HOSTNAME}:8080>
4040
Use CCVHost ${HOSTNAME} http ${TOPDIR} /var/log/apache2/${HOSTNAME}
4141
</VirtualHost>
42+
EOF
4243

43-
<VirtualHost *:443>
44+
if [ -f /etc/ssl/private/${HOSTNAME}.key ]
45+
then
46+
cat <<EOF >> /etc/apache2/sites-available/${HOSTNAME}
47+
<VirtualHost ${HOSTNAME}:443>
4448
Use CCVHost ${HOSTNAME} https ${TOPDIR} /var/log/apache2/${HOSTNAME}
4549
SSLEngine on
4650
SSLCertificateFile /etc/ssl/private/${HOSTNAME}.crt
4751
SSLCertificateKeyFile /etc/ssl/private/${HOSTNAME}.key
4852
SSLCACertificateFile /etc/ssl/certs/RapidSSL_CA_bundle.pem
4953
</VirtualHost>
5054
EOF
55+
fi
5156

5257
# 2. Create logging directory
5358

54-
mkdir /var/log/apache2/${HOSTNAME}
59+
mkdir -p /var/log/apache2/${HOSTNAME}
5560
chown root.adm /var/log/apache2/${HOSTNAME}
5661
chmod 750 /var/log/apache2/${HOSTNAME}
5762

@@ -74,7 +79,6 @@ service apache2 restart
7479

7580
echo "Enter the MySQL root password:"
7681
mysql -u root -p mysql <<EOF
77-
CREATE DATABASE ${DBNAME};
78-
CREATE USER '${DBUSER}'@'localhost' IDENTIFIED BY '${DBPASS}';
79-
GRANT ALL PRIVILEGES ON *.* TO '${DBUSER}'@'localhost' WITH GRANT OPTION;
82+
CREATE DATABASE IF NOT EXISTS ${DBNAME};
83+
GRANT ALL ON ${DBNAME} TO '${DBUSER}'@'localhost' IDENTIFIED BY '${DBPASS}';
8084
EOF

0 commit comments

Comments
 (0)