Skip to content

Commit 6196e4a

Browse files
committed
[ticket/14547] Add Vagrant to phpBB
PHPBB3-14547
1 parent ead261e commit 6196e4a

9 files changed

Lines changed: 318 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@
2222
/tests/test_config*.php
2323
/tests/tmp/*
2424
/tests/vendor
25+
/vagrant/phpbb-install-config.yml
26+
.vagrant

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ To be able to run an installation from the repo (and not from a pre-built packag
2323
3. Read our [Coding guidelines](https://wiki.phpbb.com/Coding_guidelines) and [Git Contribution Guidelines](http://wiki.phpbb.com/Git)
2424
4. Send us a pull request
2525

26+
## VAGRANT
27+
28+
Read our [Vagrant documentation](phpBB/docs/vagrant.md) to find out how to use Vagrant to develop and contribute to phpBB.
29+
2630
## AUTOMATED TESTING
2731

2832
We have unit and functional tests in order to prevent regressions. You can view the bamboo continuous integration [here](http://bamboo.phpbb.com) or check our travis builds below:

Vagrantfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'json'
2+
require 'yaml'
3+
4+
VAGRANTFILE_API_VERSION ||= "2"
5+
confDir = $confDir ||= File.expand_path("phpBB/vendor/laravel/homestead", File.dirname(__FILE__))
6+
7+
homesteadYamlPath = "vagrant/bootstrap.yaml"
8+
homesteadJsonPath = "vagrant/bootstrap.json"
9+
afterScriptPath = "vagrant/after.sh"
10+
aliasesPath = "vagrant/aliases"
11+
12+
require File.expand_path(confDir + '/scripts/homestead.rb')
13+
14+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
15+
if File.exists? aliasesPath then
16+
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
17+
end
18+
19+
if File.exists? homesteadYamlPath then
20+
Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
21+
elsif File.exists? homesteadJsonPath then
22+
Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
23+
end
24+
25+
if File.exists? afterScriptPath then
26+
config.vm.provision "shell", path: afterScriptPath
27+
end
28+
end

phpBB/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"require-dev": {
5353
"fabpot/goutte": "~2.0",
5454
"facebook/webdriver": "~1.1",
55+
"laravel/homestead": "~3.0",
5556
"phing/phing": "2.4.*",
5657
"phpunit/dbunit": "1.3.*",
5758
"phpunit/phpunit": "4.1.*",

phpBB/composer.lock

Lines changed: 48 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpBB/docs/vagrant.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
## Using Vagrant with phpBB
2+
3+
phpBB includes support for Vagrant. This allows developers and contributors to run phpBB without the need to set up their own local web server with traditional WAMP/MAMP stacks. It also provides a consistent environment between developers for writing and debugging code changes more productively.
4+
5+
phpBB uses the [Laravel/Homestead](https://laravel.com/docs/5.2/homestead) Vagrant box. It runs a Linux server with Ubuntu 14.04, PHP 7, Nginx, SQLite3, MySQL, and a whole lot more (complete specs below).
6+
7+
## Get Started
8+
9+
* Download and Install [Vagrant](https://www.vagrantup.com/downloads.html)
10+
* Download and Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
11+
* Run `vagrant up` from the root of your cloned fork of the phpBB Git repository
12+
13+
```sh
14+
$ vagrant up
15+
```
16+
17+
* Access phpBB at `http://192.168.33.10/phpBB/`
18+
* Username: **admin**
19+
* Password: **adminadmin**
20+
21+
## Additional commands:
22+
* Access your Linux server from the command line:
23+
24+
```sh
25+
$ vagrant ssh
26+
```
27+
28+
* Pause your server:
29+
30+
```sh
31+
$ vagrant suspend
32+
```
33+
34+
* Shut down your server:
35+
36+
```sh
37+
$ vagrant halt
38+
```
39+
40+
* Delete and remove your server:
41+
42+
```sh
43+
$ vagrant destroy
44+
```
45+
46+
> Note: destroying the vagrant server will remove all traces of the VM from your computer, reclaiming any disk space used by it. However, it also means the next time you vagrant up, you will be creating a brand new VM with a fresh install of phpBB and a new database.
47+
48+
## Customising the phpBB configuration
49+
50+
By default, phpBB is pre-configured to install with a MySQL database. You can, however, switch to PostegreSQL or SQLite3 by editing the `phpbb-install-config.yml` file in the vagrant directory. The next time you run `vagrant up` (or `vagrant provision`) it will be installed under the new configuration.
51+
52+
If you prefer to access phpBB from the more friendly URL `http://phpbb.app/phpBB` then you must update your computer's hosts file. This file is typically located at `/etc/hosts` for Mac/Linux or `C:\Windows\System32\drivers\etc\hosts` for Windows. Open this file and add the following line to it, at the very bottom, and save.
53+
54+
```
55+
192.168.10.10 phpbb.app
56+
```
57+
58+
## How it all works
59+
60+
When you vagrant up, the Laravel/Homestead box is transparently loaded as a Virtual Machine on your computer. Your local phpBB repository clone is mirrored/shared with the VM, so you can work on the phpBB code on your computer, and see the changes immediately when you browse to phpBB at the URL provided by the VM.
61+
62+
This is very similar to traditional methods of working with a local WAMP/MAMP stack, except the webserver is now being provided by a VM of a Linux server. The advantages here are the exact same Linux server environment is being used by everybody who uses Vagrant with phpBB, so there will be consist behaviour unlike when everybody is developing on different versions of PHP, server configurations, etc.
63+
64+
The environment is also "sandboxed" from your system. This means you don't need to worry about adjusting your own computer's internal PHP settings, setting up databases, or doing damage to your system or to phpBB. Other than the phpBB codebase, which lives on your computer, all execution is taking place within the VM and you can at any time, halt or destroy the VM and start a brand new one.
65+
66+
There are some caveats, however. You can only run one vagrant VM for the phpBB repository. And of course, the database will be destroyed when you vagrant destroy. If the database is important, you should SSH into your vagrant VM and export/import the DB as needed using SSH commands.
67+
68+
For example, to export/import a MySQL database (using phpBB's store directory):
69+
70+
SSH into the VM
71+
```
72+
$ vagrant ssh
73+
```
74+
Export MySQL:
75+
```
76+
$ mysqldump phpbb > /home/vagrant/phpbb/phpBB/store/phpbb.sql
77+
```
78+
Import MySQL:
79+
```
80+
$ mysql phpbb < /home/vagrant/phpbb/phpBB/store/phpbb.sql
81+
```
82+
83+
---
84+
85+
## About the Laravel/Homestead box
86+
87+
### Included Software
88+
89+
* Ubuntu 14.04
90+
* Git
91+
* PHP 7.0
92+
* HHVM
93+
* Nginx
94+
* MySQL
95+
* MariaDB
96+
* Sqlite3
97+
* Postgres
98+
* Composer
99+
* Node (With PM2, Bower, Grunt, and Gulp)
100+
* Redis
101+
* Memcached
102+
* Beanstalkd
103+
104+
### MySQL Access
105+
106+
- Hostname: 127.0.0.1
107+
- Username: homestead
108+
- Password: secret
109+
- Database: phpbb
110+
- Port: 3306
111+
112+
### PostgreSQL Access
113+
114+
- Hostname: 127.0.0.1
115+
- Username: homestead
116+
- Password: secret
117+
- Database: phpbb
118+
- Port: 5432

vagrant/after.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
PHPBB_PATH="/home/vagrant/phpbb"
4+
PHPBB_CONFIG="${PHPBB_PATH}/phpBB/config.php"
5+
PHPBB_INSTALL="${PHPBB_PATH}/vagrant/phpbb-install-config.yml"
6+
7+
# Ensure composer deps are installed
8+
cd ${PHPBB_PATH}/phpBB
9+
php ../composer.phar install
10+
11+
# Backup current config.php file
12+
if [ -e ${PHPBB_CONFIG} ]
13+
then
14+
cp --backup=numbered ${PHPBB_CONFIG} ${PHPBB_CONFIG}.bak
15+
fi
16+
17+
# Delete any sqlite db and config file
18+
rm -rf /tmp/phpbb.sqlite3
19+
rm -rf ${PHPBB_CONFIG}
20+
21+
# Install phpBB
22+
php ${PHPBB_PATH}/phpBB/install/phpbbcli.php install ${PHPBB_INSTALL}
23+
24+
# Update sqlite db file permissions
25+
sudo chown -R vagrant /tmp/phpbb.sqlite3
26+
27+
# Add DEBUG mode to phpBB to remove annoying installer warnings
28+
sed -i "$ a @define('DEBUG', true);" ${PHPBB_CONFIG}
29+
30+
echo "Your board is ready at http://192.168.10.10/"

vagrant/bootstrap.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
ip: "192.168.10.10"
3+
memory: 2048
4+
cpus: 1
5+
hostname: phpbb
6+
name: phpbb
7+
provider: virtualbox
8+
9+
authorize: ~/.ssh/id_rsa.pub
10+
11+
keys:
12+
- ~/.ssh/id_rsa
13+
14+
folders:
15+
- map: "."
16+
to: "/home/vagrant/phpbb"
17+
18+
sites:
19+
- map: phpbb.app
20+
to: "/home/vagrant/phpbb/phpBB"
21+
22+
databases:
23+
- phpbb
24+
25+
# blackfire:
26+
# - id: foo
27+
# token: bar
28+
# client-id: foo
29+
# client-token: bar
30+
31+
# ports:
32+
# - send: 50000
33+
# to: 5000
34+
# - send: 7777
35+
# to: 777
36+
# protocol: udp

vagrant/phpbb-install-config.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
installer:
2+
admin:
3+
name: admin
4+
password: adminadmin
5+
email: admin@example.org
6+
7+
board:
8+
lang: en
9+
name: phpBB Dev Board
10+
description: My phpBB development board
11+
12+
database:
13+
dbms: mysqli
14+
dbhost: 127.0.0.1
15+
dbport: ~
16+
dbuser: homestead
17+
dbpasswd: secret
18+
dbname: phpbb
19+
table_prefix: phpbb_
20+
# database:
21+
# dbms: postgres
22+
# dbhost: 127.0.0.1
23+
# dbport: 5432
24+
# dbuser: homestead
25+
# dbpasswd: secret
26+
# dbname: phpbb
27+
# table_prefix: phpbb_
28+
# database:
29+
# dbms: sqlite3
30+
# dbhost: /tmp/phpbb.sqlite3
31+
# dbport: ~
32+
# dbuser: ~
33+
# dbpasswd: ~
34+
# dbname: phpbb
35+
# table_prefix: phpbb_
36+
37+
email:
38+
enabled: false
39+
smtp_delivery : ~
40+
smtp_host: ~
41+
smtp_auth: ~
42+
smtp_user: ~
43+
smtp_pass: ~
44+
45+
server:
46+
cookie_secure: false
47+
server_protocol: http://
48+
force_server_vars: false
49+
server_name: 192.168.10.10
50+
server_port: 80
51+
script_path: /

0 commit comments

Comments
 (0)