1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-16 21:58:17 +01:00

[ticket/14547] Add Vagrant to phpBB

PHPBB3-14547
This commit is contained in:
Matt Friedman 2016-03-12 11:26:26 -08:00
parent ead261e6db
commit 6196e4ae4d
9 changed files with 318 additions and 2 deletions

2
.gitignore vendored
View File

@ -22,3 +22,5 @@
/tests/test_config*.php
/tests/tmp/*
/tests/vendor
/vagrant/phpbb-install-config.yml
.vagrant

View File

@ -23,6 +23,10 @@ To be able to run an installation from the repo (and not from a pre-built packag
3. Read our [Coding guidelines](https://wiki.phpbb.com/Coding_guidelines) and [Git Contribution Guidelines](http://wiki.phpbb.com/Git)
4. Send us a pull request
## VAGRANT
Read our [Vagrant documentation](phpBB/docs/vagrant.md) to find out how to use Vagrant to develop and contribute to phpBB.
## AUTOMATED TESTING
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:

28
Vagrantfile vendored Normal file
View File

@ -0,0 +1,28 @@
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path("phpBB/vendor/laravel/homestead", File.dirname(__FILE__))
homesteadYamlPath = "vagrant/bootstrap.yaml"
homesteadJsonPath = "vagrant/bootstrap.json"
afterScriptPath = "vagrant/after.sh"
aliasesPath = "vagrant/aliases"
require File.expand_path(confDir + '/scripts/homestead.rb')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exists? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end
if File.exists? homesteadYamlPath then
Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
elsif File.exists? homesteadJsonPath then
Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
end
if File.exists? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath
end
end

View File

@ -52,6 +52,7 @@
"require-dev": {
"fabpot/goutte": "~2.0",
"facebook/webdriver": "~1.1",
"laravel/homestead": "~3.0",
"phing/phing": "2.4.*",
"phpunit/dbunit": "1.3.*",
"phpunit/phpunit": "4.1.*",

50
phpBB/composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "b82925c74b2b12ce589973243a9fab68",
"content-hash": "fee6d87604f3053b51c0947ded841cfe",
"hash": "d17edf84ae8880e813086b6d819b673e",
"content-hash": "6f5504e5ebda4ca805181bbf6c829f1f",
"packages": [
{
"name": "bantu/ini-get-wrapper",
@ -1972,6 +1972,52 @@
],
"time": "2015-12-31 15:58:49"
},
{
"name": "laravel/homestead",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/homestead.git",
"reference": "705449c3dbedbded4bd4f3ed725303c69253cad4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/homestead/zipball/705449c3dbedbded4bd4f3ed725303c69253cad4",
"reference": "705449c3dbedbded4bd4f3ed725303c69253cad4",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/console": "~2.3|~3.0",
"symfony/process": "~2.3|~3.0"
},
"bin": [
"homestead"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"psr-4": {
"Laravel\\Homestead\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylorotwell@gmail.com"
}
],
"description": "A virtual machine for web artisans.",
"time": "2016-02-16 22:31:00"
},
{
"name": "michelf/php-markdown",
"version": "1.6.0",

118
phpBB/docs/vagrant.md Normal file
View File

@ -0,0 +1,118 @@
## Using Vagrant with phpBB
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.
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).
## Get Started
* Download and Install [Vagrant](https://www.vagrantup.com/downloads.html)
* Download and Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
* Run `vagrant up` from the root of your cloned fork of the phpBB Git repository
```sh
$ vagrant up
```
* Access phpBB at `http://192.168.33.10/phpBB/`
* Username: **admin**
* Password: **adminadmin**
## Additional commands:
* Access your Linux server from the command line:
```sh
$ vagrant ssh
```
* Pause your server:
```sh
$ vagrant suspend
```
* Shut down your server:
```sh
$ vagrant halt
```
* Delete and remove your server:
```sh
$ vagrant destroy
```
> 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.
## Customising the phpBB configuration
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.
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.
```
192.168.10.10 phpbb.app
```
## How it all works
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.
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.
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.
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.
For example, to export/import a MySQL database (using phpBB's store directory):
SSH into the VM
```
$ vagrant ssh
```
Export MySQL:
```
$ mysqldump phpbb > /home/vagrant/phpbb/phpBB/store/phpbb.sql
```
Import MySQL:
```
$ mysql phpbb < /home/vagrant/phpbb/phpBB/store/phpbb.sql
```
---
## About the Laravel/Homestead box
### Included Software
* Ubuntu 14.04
* Git
* PHP 7.0
* HHVM
* Nginx
* MySQL
* MariaDB
* Sqlite3
* Postgres
* Composer
* Node (With PM2, Bower, Grunt, and Gulp)
* Redis
* Memcached
* Beanstalkd
### MySQL Access
- Hostname: 127.0.0.1
- Username: homestead
- Password: secret
- Database: phpbb
- Port: 3306
### PostgreSQL Access
- Hostname: 127.0.0.1
- Username: homestead
- Password: secret
- Database: phpbb
- Port: 5432

30
vagrant/after.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
PHPBB_PATH="/home/vagrant/phpbb"
PHPBB_CONFIG="${PHPBB_PATH}/phpBB/config.php"
PHPBB_INSTALL="${PHPBB_PATH}/vagrant/phpbb-install-config.yml"
# Ensure composer deps are installed
cd ${PHPBB_PATH}/phpBB
php ../composer.phar install
# Backup current config.php file
if [ -e ${PHPBB_CONFIG} ]
then
cp --backup=numbered ${PHPBB_CONFIG} ${PHPBB_CONFIG}.bak
fi
# Delete any sqlite db and config file
rm -rf /tmp/phpbb.sqlite3
rm -rf ${PHPBB_CONFIG}
# Install phpBB
php ${PHPBB_PATH}/phpBB/install/phpbbcli.php install ${PHPBB_INSTALL}
# Update sqlite db file permissions
sudo chown -R vagrant /tmp/phpbb.sqlite3
# Add DEBUG mode to phpBB to remove annoying installer warnings
sed -i "$ a @define('DEBUG', true);" ${PHPBB_CONFIG}
echo "Your board is ready at http://192.168.10.10/"

36
vagrant/bootstrap.yaml Normal file
View File

@ -0,0 +1,36 @@
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
hostname: phpbb
name: phpbb
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: "."
to: "/home/vagrant/phpbb"
sites:
- map: phpbb.app
to: "/home/vagrant/phpbb/phpBB"
databases:
- phpbb
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp

View File

@ -0,0 +1,51 @@
installer:
admin:
name: admin
password: adminadmin
email: admin@example.org
board:
lang: en
name: phpBB Dev Board
description: My phpBB development board
database:
dbms: mysqli
dbhost: 127.0.0.1
dbport: ~
dbuser: homestead
dbpasswd: secret
dbname: phpbb
table_prefix: phpbb_
# database:
# dbms: postgres
# dbhost: 127.0.0.1
# dbport: 5432
# dbuser: homestead
# dbpasswd: secret
# dbname: phpbb
# table_prefix: phpbb_
# database:
# dbms: sqlite3
# dbhost: /tmp/phpbb.sqlite3
# dbport: ~
# dbuser: ~
# dbpasswd: ~
# dbname: phpbb
# table_prefix: phpbb_
email:
enabled: false
smtp_delivery : ~
smtp_host: ~
smtp_auth: ~
smtp_user: ~
smtp_pass: ~
server:
cookie_secure: false
server_protocol: http://
force_server_vars: false
server_name: 192.168.10.10
server_port: 80
script_path: /