Skip to content

Commit c5f4e38

Browse files
committed
better setup script; easier setup instructions
1 parent dbaa837 commit c5f4e38

File tree

6 files changed

+119
-35
lines changed

6 files changed

+119
-35
lines changed

README.md

+37-32
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,49 @@
11
# CC WordPress 2013
22

3-
Sample Apache config file, place in /etc/apache* and tweak the paths
4-
as needed:
3+
## Set-up
54

6-
Include /var/www/creativecommons.org/apache.conf
7-
8-
<VirtualHost *:8080>
9-
Use CCVHost creativecommons.org http /var/www/creativecommons.org /var/log/apache2/creativecommons.org
10-
UseCanonicalName On
11-
</VirtualHost>
12-
13-
<VirtualHost *:443>
14-
Use CCVHost creativecommons.org https /var/www/creativecommons.org /var/log/apache2/creativecommons.org
15-
UseCanonicalName On
16-
SSLEngine on
17-
SSLCertificateFile /etc/ssl/private/creativecommons.org.crt
18-
SSLCertificateKeyFile /etc/ssl/private/creativecommons.org.key
19-
SSLCACertificateFile /etc/ssl/certs/RapidSSL_CA_bundle.pem
20-
</VirtualHost>
5+
There are some handy setup scripts in the <code>scripts</code>
6+
directory. On a fresh Ubuntu 12 server, you should only need to run
7+
<code>scripts/bootstrap.sh</code>, which calls other scripts to set
8+
most things up. See below for some details on the other scripts.
9+
10+
You'll still need to manually configure a few things:
11+
12+
1. Edit <code>docroot/wp-config-local.php</code> and fill in values as
13+
needed by WordPress.
14+
2. Set up SSL keys in /etc/ssl/*
15+
3. Edit /etc/apache2/sites-available/<hostname> if needed (e.g. to
16+
change SSL key locations)
17+
4. Load DB data from another WordPress install (see below)
2118

22-
The <code>UseCanonicalName</code> option forces URLs to redirect to
23-
the canonical host name, you can remove it if you want to use other
24-
names to access the site (e.g., an Amazon EC2 hostname before you get
25-
DNS set-up).
19+
### Loading DB data
2620

21+
If you want to import DB data from another WordPress install, use the
22+
<code>mysqldump</code> / <code>mysql</code> utilities to create a
23+
backup and restore it here:
24+
25+
# on the source machine:
26+
mysqldump -u root dbname | gzip > backup.sql.gz
27+
28+
# ... copy (eg. with scp) ...
29+
30+
# then on this machine:
31+
zcat backup.sql.gz | mysql -u root -p dbname
2732

33+
### Bootstrap scripts (details)
2834

29-
You'll need the <code>macro</code> Apache module. On Debian-like systems you can try:
35+
Note that the <code>scripts/bootstrap.sh</code> script calls these for
36+
you. But if something goes wrong / you want to know more:
3037

31-
apt-get install libapache2-mod-macro
32-
a2enmod macro
38+
* <code>scripts/bootstrap_server_ubuntu.sh</code>: Will configure an
39+
Ubuntu 12 server (install packages and enable apache modules, etc).
3340

34-
There is a setup script, <code>server_bootstrap.sh</code>, in this
35-
checkout, it primarily sets up the python environment. It should "just
36-
work", but if it doesn't then give it a read. It requires some basic
37-
Python utilities like <code>virtualenv</code> and <code>pip</code>.
41+
* <code>scripts/bootstrap_mysql.sh</code>: Creates a database and user
42+
with specified password. Use these values in your
43+
<code>wp-config-local.php</code> file (see below).
3844

39-
To configure WordPress, there is a sample config file at
40-
<code>docroot/wp-config-local.php.sample</code>, copy it to
41-
<code>docroot/wp-config-local.php</code> and fill in the information
42-
as needed by the WP install.
45+
* <code>scripts/bootstrap_checkout.sh</code>: Sets up this checkout by
46+
downloading git submodules, creating a virtual Python environment,
47+
etc.
4348

4449
Happy hacking!

apache.conf

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
Options +ExecCGI
1919

20+
# Redirect users to ${host} if they used something else
21+
# (e.g. www.${host}, etc).
22+
UseCanonicalName On
23+
2024
<Location /licenses>
2125
DirectoryIndex deed
2226
DefaultType text/html

scripts/bootstrap.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
function usage() {
4+
echo "Usage: $0 <hostname> <db> <dbuser>"
5+
exit 1
6+
}
7+
8+
[ -z "$3" ] && usage;
9+
10+
HOSTNAME=${1}
11+
DB=${2}
12+
DBUSER=${3}
13+
14+
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}/.." )" && pwd )"
15+
16+
${TOPDIR}/scripts/bootstrap_server_ubuntu.sh
17+
${TOPDIR}/scripts/bootstrap_mysql.sh "${DB}" "${DBUSER}"
18+
${TOPDIR}/scripts/bootstrap_checkout.sh

server_bootstrap.sh renamed to scripts/bootstrap_checkout.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/bash
22

33
CUR=`pwd`
4-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}/.." )" && pwd )"
55

6-
cd ${DIR}
6+
cd ${TOPDIR}
77

88
git submodule init
99
git submodule update
1010

1111
cd python_env
1212

13-
sed -e "s|@env_dir@|${DIR}/python_env|" < bin/ccengine.fcgi.in > bin/ccengine.fcgi
13+
sed -e "s|@env_dir@|${TOPDIR}/python_env|" < bin/ccengine.fcgi.in > bin/ccengine.fcgi
1414
chmod 755 bin/ccengine.fcgi
1515

1616
virtualenv .

scripts/bootstrap_mysql.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
function usage() {
4+
echo "Usage: $0 <new-database> <new-user>"
5+
exit 1
6+
}
7+
8+
[ -z "$1" ] && usage;
9+
[ -z "$2" ] && usage;
10+
11+
mysql -u root -p mysql <<EOF
12+
create database $1
13+
create user '$2'@'localhost' identified by 'password';
14+
grant all privileges on *.* to '$2'@'localhost' with grant option;
15+
EOF

scripts/bootstrap_server_ubuntu.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
HOSTNAME=${1:-creativecommons.org}
4+
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}/.." )" && pwd )"
5+
6+
apt-get -y install apache2 python-virtualenv python-pip gcc python-dev libxml2 libxml2-dev libxslt1.1 libxslt-dev php5 php5-mysql python-librdf libapache2-mod-fcgid libapache-mod-macro mysql-server mysql-client
7+
8+
for i in macro php5 rewrite ssl fcgid
9+
do
10+
a2enmod $i
11+
done
12+
13+
if grep -q "apache.conf" /etc/apache2/httpd.conf
14+
then
15+
echo "Note: /etc/apache2/httpd.conf seems to be loading an apache.conf file,"
16+
echo "leaving it alone. If that's not the CC apache.conf file, then you'll"
17+
echo "need to add the Include line manually."
18+
else
19+
echo "Include ${TOPDIR}/apache.conf" >> /etc/apache2/httpd.conf
20+
fi
21+
22+
cat <<EOF > /etc/apache2/sites-available/${HOSTNAME}
23+
<VirtualHost *:8080>
24+
Use CCVHost ${HOSTNAME} http ${TOPDIR} /var/log/apache2/${HOSTNAME}
25+
</VirtualHost>
26+
27+
<VirtualHost *:443>
28+
Use CCVHost ${HOSTNAME} https ${TOPDIR} /var/log/apache2/${HOSTNAME}
29+
SSLEngine on
30+
SSLCertificateFile /etc/ssl/private/${HOSTNAME}.crt
31+
SSLCertificateKeyFile /etc/ssl/private/${HOSTNAME}.key
32+
SSLCACertificateFile /etc/ssl/certs/RapidSSL_CA_bundle.pem
33+
</VirtualHost>
34+
EOF
35+
36+
mkdir /var/log/apache2/${HOSTNAME}
37+
chown root.adm /var/log/apache2/${HOSTNAME}
38+
chmod 750 /var/log/apache2/${HOSTNAME}
39+
40+
a2ensite ${HOSTNAME}
41+
42+
service apache2 restart

0 commit comments

Comments
 (0)