Skip to content

Commit 5087711

Browse files
ryanneufeldscottgonzalez
authored andcommitted
Build: Add vagrantfile
Ref gh-42 Closes gh-293
1 parent 95061db commit 5087711

File tree

5 files changed

+214
-100
lines changed

5 files changed

+214
-100
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/gw-resources/*
2+
.vagrant

INSTALL.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# jquery-wp-content
2+
3+
`jquery-wp-content` is a **custom replacement** for the `wp-content` directory which contains the plugins, themes and site configuration to run the jQuery multi-site WordPress network.
4+
5+
## Warning
6+
7+
Configuring your own services can result in different configurations from the prodution environment. It is strongly encouraged to use the virtual machine environment as described in [README.md](README.md).
8+
9+
## Prerequisites
10+
11+
This install guide assumes you have certain prerequisites already configured within your environment.
12+
13+
* Apache
14+
* Mysql
15+
* PHP
16+
17+
## Installation
18+
19+
1. Configure your local webserver with a virtual host that covers the relevant jQuery domains, such as `*.jquery.com` and `*.jqueryui.com`, all pointing to the same root. For example, in Apache:
20+
21+
```
22+
<VirtualHost *:80>
23+
ServerName local.jquery.com
24+
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.qunitjs.com *.sizzlejs.com *.jquerymobile.com
25+
DocumentRoot "/srv/www/jquery"
26+
php_value memory_limit 256M
27+
<Directory /srv/www/jquery>
28+
Options All
29+
AllowOverride All
30+
Order allow,deny
31+
Allow from all
32+
</Directory>
33+
</VirtualHost>
34+
```
35+
36+
Make sure that virtual hosts are enabled as well:
37+
38+
```
39+
NameVirtualHost *:80
40+
```
41+
42+
Both blocks of code should be pasted into `extra/httpd-vhosts.conf`.
43+
Be sure to check `httpd.conf` to verify there is a line that includes
44+
`httpd-vhosts.conf`. It may already exist, but be commented out.
45+
46+
Check `httpd.conf` to ensure that the PHP module is enabled as well.
47+
48+
You do not need to configure your `/etc/hosts` file for `local.*` because `jquery.com`'s DNS handles this for you. However, if you plan to work offline, you can use the following rules:
49+
50+
```
51+
127.0.0.1 local.jquery.com local.api.jquery.com local.blog.jquery.com local.books.jquery.com local.codeorigin.jquery.com local.learn.jquery.com local.plugins.jquery.com
52+
127.0.0.1 local.jqueryui.com local.api.jqueryui.com local.blog.jqueryui.com
53+
127.0.0.1 local.jquerymobile.com local.api.jquerymobile.com local.blog.jquerymobile.com
54+
127.0.0.1 local.jquery.org local.brand.jquery.org local.contribute.jquery.org local.events.jquery.org local.irc.jquery.org local.meetings.jquery.org
55+
127.0.0.1 local.qunitjs.com local.api.qunitjs.com
56+
127.0.0.1 local.sizzlejs.com
57+
```
58+
59+
1. Place the WordPress core files **at** the document root you chose. For example, if you used `/srv/www/jquery`, you should unzip or clone WordPress directly into that directory, *not* a directory below it. **Do not install WordPress.** You can do this any number of ways:
60+
* Download the latest version from http://wordpress.org/latest.zip
61+
* Check out the latest tag from http://core.svn.wordpress.org/tags/
62+
* Clone the official WordPress Github mirror at https://github.com/WordPress/WordPress
63+
64+
1. Clone `jquery-wp-content` inside of the directory where you put WordPress, so you have a file tree that looks like this:
65+
66+
```
67+
├── jquery
68+
│   ├── gw-resources
69+
│   ├── index.php
70+
│   ├── jquery-wp-content
71+
│   ├── license.txt
72+
│   ├── readme.html
73+
│   ├── wp-activate.php
74+
│   ├── wp-admin
75+
│   ├── wp-blog-header.php
76+
│   ├── wp-comments-post.php
77+
│   ├── wp-config-sample.php
78+
│   ├── wp-content
79+
│   ├── ...
80+
│   └── xmlrpc.php
81+
```
82+
83+
1. Create a MySQL database and user. You can choose any name you want for both. Follow the [WordPress instructions](http://codex.wordpress.org/Installing_WordPress#Step_2:_Create_the_Database_and_a_User) for a step by step guide.
84+
85+
1. Copy `jquery-wp-content/wp-config-sample.php` and move it up one directory, to `wp-config.php`. Fill in your database credentials.
86+
87+
1. Create an .htaccess file with the following content into that same document root:
88+
89+
```
90+
RewriteEngine On
91+
RewriteBase /
92+
RewriteRule ^index\.php$ - [L]
93+
94+
RewriteRule ^resources/?$ index.php [L]
95+
RewriteRule ^resources/(.+) gw-resources/%{HTTP_HOST}/$1 [L]
96+
97+
# Add a trailing slash to the wp-admin of a subsite.
98+
RewriteRule ^([_0-9a-zA-Z\.-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
99+
100+
RewriteCond %{REQUEST_FILENAME} -f [OR]
101+
RewriteCond %{REQUEST_FILENAME} -d
102+
RewriteRule ^ - [L]
103+
104+
# Handle wp-admin, wp-includes, and root PHP files for subsites.
105+
RewriteRule ^[_0-9a-zA-Z\.-]+/((wp-admin|wp-includes).*) $1 [L]
106+
RewriteRule ^[_0-9a-zA-Z\.-]+/(.*\.php)$ $1 [L]
107+
108+
RewriteRule . index.php [L]
109+
```
110+
111+
1. Make sure that you have assigned your WordPress files and directories the correct permissions.
112+
For example, if your WordPress files are in the directory ```wordpress```, and you are running Apache under Mac OS X with the ```_www``` user:
113+
114+
```
115+
sudo chown -R _www wordpress
116+
sudo chmod -R g+w wordpress
117+
```
118+
119+
1. Restart your web server so the changes above are in use.
120+
121+
1. Go to `http://local.jquery.com` and walk through the standard WordPress installation. `jquery-wp-content` includes a special install script that will initialize the entire network.
122+
123+
1. Be sure to have node >= 0.8 installed on your system. Some sites, such as download.jqueryui.com, require that version or greater.

README.md

Lines changed: 58 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,84 @@
1-
# jQuery.com jquery-wp-content
1+
# jquery-wp-content
22

33
`jquery-wp-content` is a **custom replacement** for the `wp-content` directory which contains the plugins, themes and site configuration to run the jQuery multi-site WordPress network.
44

5+
Although we recommend using the pre-built VM, if you would like to manually install `jquery-wp-content` you will find instructions for installing in the [INSTALL.md](INSTALL.md) file in this directory. We strongly recommend using the VM as it will provide the same environment as our production servers.
56

67
## Prerequisites
78

8-
This install guide assumes you already have certain prerequisites already configured within your environment.
9-
10-
* Apache
11-
* Mysql
12-
* PHP
13-
14-
## Installation
15-
16-
1. Configure your local webserver with a virtual host that covers the relevant jQuery domains, such as `*.jquery.com` and `*.jqueryui.com`, all pointing to the same root. For example, in Apache:
9+
This setup guide assumes you have certain prerequisites installed.
1710

18-
```
19-
<VirtualHost *:80>
20-
ServerName local.jquery.com
21-
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.qunitjs.com *.sizzlejs.com *.jquerymobile.com
22-
DocumentRoot "/srv/www/jquery"
23-
php_value memory_limit 256M
24-
<Directory /srv/www/jquery>
25-
Options All
26-
AllowOverride All
27-
Order allow,deny
28-
Allow from all
29-
</Directory>
30-
</VirtualHost>
31-
```
11+
* [Virtualbox >=4.3+](https://www.virtualbox.org/)
12+
* [Vagrant >=1.4.0](http://www.vagrantup.com/)
3213

33-
Make sure that virtual hosts are enabled as well:
14+
## Vagrant and Virtualbox
3415

35-
```
36-
NameVirtualHost *:80
37-
```
16+
We recommend the combination of Virtualbox and [Vagrant](http://www.vagrantup.com/about.html) for a local development environment. Vagrant simplifies download, installation, and management of the local environment VM with a few commands.
3817

39-
Both blocks of code should be pasted into `extra/httpd-vhosts.conf`.
40-
Be sure to check `httpd.conf` to verify there is a line that includes
41-
`httpd-vhosts.conf`. It may already exist, but be commented out.
18+
### Setup
4219

43-
Check `httpd.conf` to ensure that the PHP module is enabled as well.
20+
From the root of your `jquery-wp-content` clone run the following command:
4421

45-
You do not need to configure your `/etc/hosts` file for `local.*` because `jquery.com`'s DNS handles this for you. However, if you plan to work offline, you can use the following rules:
22+
```
23+
vagrant up
24+
```
4625

47-
```
48-
127.0.0.1 local.jquery.com local.api.jquery.com local.blog.jquery.com local.books.jquery.com local.codeorigin.jquery.com local.learn.jquery.com local.plugins.jquery.com
49-
127.0.0.1 local.jqueryui.com local.api.jqueryui.com local.blog.jqueryui.com
50-
127.0.0.1 local.jquerymobile.com local.api.jquerymobile.com local.blog.jquerymobile.com
51-
127.0.0.1 local.jquery.org local.brand.jquery.org local.contribute.jquery.org local.events.jquery.org local.irc.jquery.org local.meetings.jquery.org
52-
127.0.0.1 local.qunitjs.com local.api.qunitjs.com
53-
127.0.0.1 local.sizzlejs.com
54-
```
26+
This will start the VM for you, the output should look similar to what you see below.
5527

56-
1. Place the WordPress core files **at** the document root you chose. For example, if you used `/srv/www/jquery`, you should unzip or clone WordPress directly into that directory, *not* a directory below it. **Do not install WordPress.** You can do this any number of ways:
57-
* Download the latest version from http://wordpress.org/latest.zip
58-
* Check out the latest tag from http://core.svn.wordpress.org/tags/
59-
* Clone the official WordPress Github mirror at https://github.com/WordPress/WordPress
28+
```
29+
Bringing machine 'default' up with 'virtualbox' provider...
30+
[default] Box 'jquery-wp-content' was not found. Fetching box from specified URL for
31+
the provider 'virtualbox'. Note that if the URL does not have
32+
a box for this provider, you should interrupt Vagrant now and add
33+
the box yourself. Otherwise Vagrant will attempt to download the
34+
full box prior to discovering this error.
35+
Downloading box from URL: http://boxes.jquery.com/jquery-wp-content.box
36+
Calculating and comparing box checksum...ime remaining: 0:00:01)
37+
Extracting box...
38+
Successfully added box 'jquery-wp-content' with provider 'virtualbox'!
39+
[default] Importing base box 'jquery-wp-content'...
40+
[default] Matching MAC address for NAT networking...
41+
[default] Setting the name of the VM...
42+
[default] Clearing any previously set forwarded ports...
43+
[default] Clearing any previously set network interfaces...
44+
[default] Preparing network interfaces based on configuration...
45+
[default] Forwarding ports...
46+
[default] -- 22 => 2222 (adapter 1)
47+
[default] Running 'pre-boot' VM customizations...
48+
[default] Booting VM...
49+
[default] Waiting for machine to boot. This may take a few minutes...
50+
[default] Machine booted and ready!
51+
[default] Setting hostname...
52+
[default] Configuring and enabling network interfaces...
53+
[default] Mounting shared folders...
54+
[default] -- /vagrant
55+
[default] -- /var/www/wordpress/jquery-wp-content
56+
```
6057

61-
1. Clone `jquery-wp-content` inside of the directory where you put WordPress, so you have a file tree that looks like this:
58+
Complete the installation process by pointing your browser at http://vagrant.jquery.com/. Feel free to use any username/password/email combination that you choose, though keep note of the username and password as you will need them to deploy to your local VM.
6259

63-
```
64-
├── jquery
65-
│   ├── gw-resources
66-
│   ├── index.php
67-
│   ├── jquery-wp-content
68-
│   ├── license.txt
69-
│   ├── readme.html
70-
│   ├── wp-activate.php
71-
│   ├── wp-admin
72-
│   ├── wp-blog-header.php
73-
│   ├── wp-comments-post.php
74-
│   ├── wp-config-sample.php
75-
│   ├── wp-content
76-
│   ├── ...
77-
│   └── xmlrpc.php
78-
```
60+
You do not need to configure your `/etc/hosts` file for `vagrant.*` because `jquery.com`'s DNS handles this for you. However, if you plan to work offline, you can use the following rules:
7961

80-
1. Create a MySQL database and user. You can choose any name you want for both. Follow the [WordPress instructions](http://codex.wordpress.org/Installing_WordPress#Step_2:_Create_the_Database_and_a_User) for a step by step guide.
62+
```
63+
172.27.72.27 vagrant.jquery.com vagrant.api.jquery.com vagrant.blog.jquery.com vagrant.books.jquery.com vagrant.codeorigin.jquery.com vagrant.learn.jquery.com vagrant.plugins.jquery.com
64+
172.27.72.27 vagrant.jqueryui.com vagrant.api.jqueryui.com vagrant.blog.jqueryui.com
65+
172.27.72.27 vagrant.jquerymobile.com vagrant.api.jquerymobile.com vagrant.blog.jquerymobile.com
66+
172.27.72.27 vagrant.jquery.org vagrant.brand.jquery.org vagrant.contribute.jquery.org vagrant.events.jquery.org vagrant.irc.jquery.org vagrant.meetings.jquery.org
67+
172.27.72.27 vagrant.qunitjs.com vagrant.api.qunitjs.com
68+
172.27.72.27 vagrant.sizzlejs.com
69+
```
8170

82-
1. Copy `jquery-wp-content/wp-config-sample.php` and move it up one directory, to `wp-config.php`. Fill in your database credentials.
71+
### Stopping and Restarting the Virtual Machine
8372

84-
1. Create an .htaccess file with the following content into that same document root:
73+
When you're not working on `jquery-wp-content` you'll probably want to run `vagrant halt` to turn off the VM to save yourself some system resources. Alternatively you can suspend the VM by using `vagrant suspend`. You can always start the VM by running `vagrant up`.
8574

86-
```
87-
RewriteEngine On
88-
RewriteBase /
89-
RewriteRule ^index\.php$ - [L]
75+
### Clean up
9076

91-
RewriteRule ^resources/?$ index.php [L]
92-
RewriteRule ^resources/(.+) gw-resources/%{HTTP_HOST}/$1 [L]
93-
94-
# Add a trailing slash to the wp-admin of a subsite.
95-
RewriteRule ^([_0-9a-zA-Z\.-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
96-
97-
RewriteCond %{REQUEST_FILENAME} -f [OR]
98-
RewriteCond %{REQUEST_FILENAME} -d
99-
RewriteRule ^ - [L]
100-
101-
# Handle wp-admin, wp-includes, and root PHP files for subsites.
102-
RewriteRule ^[_0-9a-zA-Z\.-]+/((wp-admin|wp-includes).*) $1 [L]
103-
RewriteRule ^[_0-9a-zA-Z\.-]+/(.*\.php)$ $1 [L]
104-
105-
RewriteRule . index.php [L]
106-
```
107-
108-
1. Make sure that you have assigned your WordPress files and directories the correct permissions.
109-
For example, if your WordPress files are in the directory ```wordpress```, and you are running Apache under Mac OS X with the ```_www``` user:
110-
111-
```
112-
sudo chown -R _www wordpress
113-
sudo chmod -R g+w wordpress
114-
```
115-
116-
1. Restart your web server so the changes above are in use.
117-
118-
1. Go to `http://local.jquery.com` and walk through the standard WordPress installation. `jquery-wp-content` includes a special install script that will initialize the entire network.
119-
120-
1. Be sure to have node >= 0.8 installed on your system. Some sites, such as download.jqueryui.com, require that version or greater.
77+
Should you need to recover some harddrive space you can safely run the `vagrant destroy` command from within your `jquery-wp-content` clone. This will delete the VM image from your hard drive. **You will not lose any work by doing this.**
12178

12279
## Auto-Updates
123-
Changes pushed to master will be pulled onto the stage domain.
80+
81+
Changes pushed to master are automatically pulled onto the stage domain.
12482

12583
## Copyright
12684

Vagrantfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
VAGRANTFILE_API_VERSION = "2"
4+
Vagrant.require_version ">= 1.4.0"
5+
6+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7+
8+
# use the config key as the vm identifier
9+
config.vm.box = "jquery-wp-content"
10+
config.vm.box_download_checksum_type = "sha256"
11+
config.vm.box_download_checksum = "3182bc50668e86022e7d50bc8c096774b49de40cfaffc77f4fad75ca6cf83d3d"
12+
13+
config.vm.box_url = "http://boxes.jquery.com/jquery-wp-content.box"
14+
15+
config.vm.synced_folder "./", "/var/www/wordpress/jquery-wp-content"
16+
17+
# assign an ip address in the hosts network
18+
config.vm.network "private_network", ip: "172.27.72.27"
19+
20+
# set the hostname of the vm so puppet site.pp will react
21+
# with the right node config
22+
# config.vm.provision :shell, :inline => "hostname vagrant.jquery.com"
23+
config.vm.hostname = "vagrant.jquery.com"
24+
25+
config.vm.provider "virtualbox" do |v|
26+
# make sure that the name makes sense when seen in the vbox GUI
27+
v.name = "jQuery Sites"
28+
29+
# Be nice to our users.
30+
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
31+
end
32+
end

uploads/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)