Skip to content

Add a Vagrantfile for easy remote development. #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/gw-resources/*
.vagrant
123 changes: 123 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# jquery-wp-content

`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.

## Warning

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).

## Prerequisites

This install guide assumes you have certain prerequisites already configured within your environment.

* Apache
* Mysql
* PHP

## Installation

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:

```
<VirtualHost *:80>
ServerName local.jquery.com
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.qunitjs.com *.sizzlejs.com *.jquerymobile.com
DocumentRoot "/srv/www/jquery"
php_value memory_limit 256M
<Directory /srv/www/jquery>
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
```

Make sure that virtual hosts are enabled as well:

```
NameVirtualHost *:80
```

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

Check `httpd.conf` to ensure that the PHP module is enabled as well.

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:

```
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
127.0.0.1 local.jqueryui.com local.api.jqueryui.com local.blog.jqueryui.com
127.0.0.1 local.jquerymobile.com local.api.jquerymobile.com local.blog.jquerymobile.com
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
127.0.0.1 local.qunitjs.com local.api.qunitjs.com
127.0.0.1 local.sizzlejs.com
```

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:
* Download the latest version from http://wordpress.org/latest.zip
* Check out the latest tag from http://core.svn.wordpress.org/tags/
* Clone the official WordPress Github mirror at https://github.com/WordPress/WordPress

1. Clone `jquery-wp-content` inside of the directory where you put WordPress, so you have a file tree that looks like this:

```
├── jquery
│   ├── gw-resources
│   ├── index.php
│   ├── jquery-wp-content
│   ├── license.txt
│   ├── readme.html
│   ├── wp-activate.php
│   ├── wp-admin
│   ├── wp-blog-header.php
│   ├── wp-comments-post.php
│   ├── wp-config-sample.php
│   ├── wp-content
│   ├── ...
│   └── xmlrpc.php
```

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.

1. Copy `jquery-wp-content/wp-config-sample.php` and move it up one directory, to `wp-config.php`. Fill in your database credentials.

1. Create an .htaccess file with the following content into that same document root:

```
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteRule ^resources/?$ index.php [L]
RewriteRule ^resources/(.+) gw-resources/%{HTTP_HOST}/$1 [L]

# Add a trailing slash to the wp-admin of a subsite.
RewriteRule ^([_0-9a-zA-Z\.-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Handle wp-admin, wp-includes, and root PHP files for subsites.
RewriteRule ^[_0-9a-zA-Z\.-]+/((wp-admin|wp-includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z\.-]+/(.*\.php)$ $1 [L]

RewriteRule . index.php [L]
```

1. Make sure that you have assigned your WordPress files and directories the correct permissions.
For example, if your WordPress files are in the directory ```wordpress```, and you are running Apache under Mac OS X with the ```_www``` user:

```
sudo chown -R _www wordpress
sudo chmod -R g+w wordpress
```

1. Restart your web server so the changes above are in use.

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.

1. Be sure to have node >= 0.8 installed on your system. Some sites, such as download.jqueryui.com, require that version or greater.
158 changes: 58 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,84 @@
# jQuery.com jquery-wp-content
# jquery-wp-content

`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.

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.

## Prerequisites

This install guide assumes you already have certain prerequisites already configured within your environment.

* Apache
* Mysql
* PHP

## Installation

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:
This setup guide assumes you have certain prerequisites installed.

```
<VirtualHost *:80>
ServerName local.jquery.com
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.qunitjs.com *.sizzlejs.com *.jquerymobile.com
DocumentRoot "/srv/www/jquery"
php_value memory_limit 256M
<Directory /srv/www/jquery>
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
```
* [Virtualbox >=4.3+](https://www.virtualbox.org/)
* [Vagrant >=1.4.0](http://www.vagrantup.com/)

Make sure that virtual hosts are enabled as well:
## Vagrant and Virtualbox

```
NameVirtualHost *:80
```
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.

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

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

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:
```
vagrant up
```

```
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
127.0.0.1 local.jqueryui.com local.api.jqueryui.com local.blog.jqueryui.com
127.0.0.1 local.jquerymobile.com local.api.jquerymobile.com local.blog.jquerymobile.com
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
127.0.0.1 local.qunitjs.com local.api.qunitjs.com
127.0.0.1 local.sizzlejs.com
```
This will start the VM for you, the output should look similar to what you see below.

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:
* Download the latest version from http://wordpress.org/latest.zip
* Check out the latest tag from http://core.svn.wordpress.org/tags/
* Clone the official WordPress Github mirror at https://github.com/WordPress/WordPress
```
Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'jquery-wp-content' was not found. Fetching box from specified URL for
the provider 'virtualbox'. Note that if the URL does not have
a box for this provider, you should interrupt Vagrant now and add
the box yourself. Otherwise Vagrant will attempt to download the
full box prior to discovering this error.
Downloading box from URL: http://boxes.jquery.com/jquery-wp-content.box
Calculating and comparing box checksum...ime remaining: 0:00:01)
Extracting box...
Successfully added box 'jquery-wp-content' with provider 'virtualbox'!
[default] Importing base box 'jquery-wp-content'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Running 'pre-boot' VM customizations...
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Setting hostname...
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /var/www/wordpress/jquery-wp-content
```

1. Clone `jquery-wp-content` inside of the directory where you put WordPress, so you have a file tree that looks like this:
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.

```
├── jquery
│   ├── gw-resources
│   ├── index.php
│   ├── jquery-wp-content
│   ├── license.txt
│   ├── readme.html
│   ├── wp-activate.php
│   ├── wp-admin
│   ├── wp-blog-header.php
│   ├── wp-comments-post.php
│   ├── wp-config-sample.php
│   ├── wp-content
│   ├── ...
│   └── xmlrpc.php
```
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:

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.
```
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
172.27.72.27 vagrant.jqueryui.com vagrant.api.jqueryui.com vagrant.blog.jqueryui.com
172.27.72.27 vagrant.jquerymobile.com vagrant.api.jquerymobile.com vagrant.blog.jquerymobile.com
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
172.27.72.27 vagrant.qunitjs.com vagrant.api.qunitjs.com
172.27.72.27 vagrant.sizzlejs.com
```

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

1. Create an .htaccess file with the following content into that same document root:
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`.

```
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
### Clean up

RewriteRule ^resources/?$ index.php [L]
RewriteRule ^resources/(.+) gw-resources/%{HTTP_HOST}/$1 [L]

# Add a trailing slash to the wp-admin of a subsite.
RewriteRule ^([_0-9a-zA-Z\.-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Handle wp-admin, wp-includes, and root PHP files for subsites.
RewriteRule ^[_0-9a-zA-Z\.-]+/((wp-admin|wp-includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z\.-]+/(.*\.php)$ $1 [L]

RewriteRule . index.php [L]
```

1. Make sure that you have assigned your WordPress files and directories the correct permissions.
For example, if your WordPress files are in the directory ```wordpress```, and you are running Apache under Mac OS X with the ```_www``` user:

```
sudo chown -R _www wordpress
sudo chmod -R g+w wordpress
```

1. Restart your web server so the changes above are in use.

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.

1. Be sure to have node >= 0.8 installed on your system. Some sites, such as download.jqueryui.com, require that version or greater.
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.**

## Auto-Updates
Changes pushed to master will be pulled onto the stage domain.

Changes pushed to master are automatically pulled onto the stage domain.

## Copyright

Expand Down
32 changes: 32 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.4.0"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# use the config key as the vm identifier
config.vm.box = "jquery-wp-content"
config.vm.box_download_checksum_type = "sha256"
config.vm.box_download_checksum = "3182bc50668e86022e7d50bc8c096774b49de40cfaffc77f4fad75ca6cf83d3d"

config.vm.box_url = "http://boxes.jquery.com/jquery-wp-content.box"

config.vm.synced_folder "./", "/var/www/wordpress/jquery-wp-content"

# assign an ip address in the hosts network
config.vm.network "private_network", ip: "172.27.72.27"

# set the hostname of the vm so puppet site.pp will react
# with the right node config
# config.vm.provision :shell, :inline => "hostname vagrant.jquery.com"
config.vm.hostname = "vagrant.jquery.com"

config.vm.provider "virtualbox" do |v|
# make sure that the name makes sense when seen in the vbox GUI
v.name = "jQuery Sites"

# Be nice to our users.
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
end
end
Empty file added uploads/.gitkeep
Empty file.