How to use this box with Vagrant:

Vagrant.configure("2") do |config|
  config.vm.box = "rasmus/php7dev"
end
vagrant init rasmus/php7dev
vagrant up

This version was created 11 months ago.

See https://github.com/rlerdorf/php7dev/

1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (2.36 GB)

This version was created almost 2 years ago.

See https://github.com/rlerdorf/php7dev

1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (2.29 GB)

This version was created about 2 years ago.

See https://github.com/rlerdorf/php7dev

1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (1.66 GB)

This version was created over 2 years ago.

  • Fix double-entry in /etc/network/interfaces
1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (1.49 GB)

This version was created over 2 years ago.

  • Try to fix vagrant ssh issue by adding new insecure vagrant key
1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (1.67 GB)

This version was created over 2 years ago.

  • Default PHP version is 7 again
  • Use -j2 in makephp since the vm is configured for 2 CPUs
  • Updated composer
1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (1.67 GB)

This version was created over 2 years ago.

  • dist-upgraded all Debian packages
  • Updated newphp script - no longer need to sudo
  • Added makephp script
  • Added src/mysql checkout from pecl
  • Rebuilt all PHP versions
  • Added phpdbg to PHP 7.0 builds
  • Updated Valgrind .suppressions file
  • Re-installed headers as per https://github.com/rlerdorf/php7dev/issues/4
1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (1.71 GB)

This version was created over 2 years ago.

Documentation

See https://github.com/rlerdorf/php7dev/blob/master/README.md

Changelog

  • Reduced the size of the image by almost 1G - It is 1.5G now
  • Built latest php7 and php7-debug
1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (1.4 GB)

This version was created over 2 years ago.

Changelog:

1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (2.38 GB)

This version was created over 2 years ago.

Changelog

0.0.2:

  • Upgraded VirtualBox Guest Additions to version 4.3
  • Added curl
  • pulled and built latest php7 from master

0.0.1 Initial release

Installation

Download and install Virtualbox

Download and install Vagrant

Make sure you are at least at Vagrant version 1.5 or the steps below may not work for you.

Then from a terminal, do:

$ vagrant box add rasmus/php7dev
...
$ vagrant init rasmus/php7dev
...
$ vagrant up
...
(You can ignore the warning about the guest additions version)
...
$ vagrant ssh

If everything went well you should now be ssh'ed into your php7dev environment.

However, if you check /sbin/ifconfig you will see that your network interface is a private NAT'ed ip. You can get out from it, but you can't get in. Log back out and edit your ~/Vagrantfile. Most of it is commented out. Find the section that says config.vm.network and add:

config.vm.hostname = "php7dev"
config.vm.network "public_network", type: "dhcp"

There are also various vagrant plugins that can help you update your dns. See local-domain-resolution.

The landrush one looks interesting since it could be used to create a local php7dev domain and you could then just make all your vhosts myvhost.php7dev and you wouldn't need to edit your /etc/hosts file every time you added a new vhost.

$ vagrant reload

It will ask you which interface to bridge to. Select your current active network interface and it should just work. If you have configured one of the domain resolution plugins you should be set to go now, otherwise, vagrant ssh in and check the ip manually and add it to your /etc/hosts file. Then try it from your browser:

http://php7dev/

It should show the PHP7 phpinfo() page.

This also means you don't need to use vagrant ssh anymore. You can just ssh directly into the machine like any other machine on your network at this point.

Installing phpBB

Now you can install something. The sites live in /var/www.

For example, to install phpBB:

$ cd /var/www
$ wget https://www.phpbb.com/files/release/phpBB-3.1.2.zip
...
$ unzip phpBB-3.1.2.zip
...
$ sudo chown -R www-data phpBB3

Now create /etc/nginx/conf.d/phpbb.conf with this config:

server {
    listen 80;
    server_name  phpbb;
    root   /var/www/phpBB3;
    index  index.php index.html index.htm;
    access_log /var/log/nginx/phpbb-access.log;
    error_log /var/log/nginx/phpbb-error.log;

    location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|store) {
        deny all;
        return 403;
    }

    location ~* \.(gif|jpe?g|png|css)$ {
        expires   30d;
    }

    include php.conf;
}

You will need to sudo to do it. It shouldn't ask you for a password, but every password, sudo, root, mysql is set to: vagrant in case you need it.

Then do:

$ sudo service nginx reload

On the machine you are running your web browser, add an entry to your /etc/hosts file with:

192.168.x.x phpbb

Substitute your ip there, of course.

Now you can go to http://phpbb/ and you should be redirected to the phpBB installer.

Before you start, you need to create the database:

$ mysqladmin create phpbb

Now go through the steps. Your Database host is localhost and the user is vagrant, password vagrant. Database name is phpbb. You can leave the port empty. Click through the rest and you should be done. Then remove the install directory to get rid of the annoying warning:

$ sudo rm -rf /var/www/phpBB3/install/

Installing other apps

For the most part installing almost anything follows the same pattern. Download the tarball or zip file to /var/www. Extract, make it owned by www-data and find the nginx server config. Usually a quick Google search will turn it up. If it doesn't, something like:

    server {
       listen 80;
       server_name mysite;
       root /var/www/mysite;
       access_log /var/log/nginx/mysite-access.log;
       error_log /var/log/nginx/mysite-error.log;

       index index.php index.html;

       location / {
           try_files $uri $uri/ @rewrite;
        }
        location @rewrite {
            rewrite ^(.*)$ /index.php;
        }

        include php.conf;
    }

Usually does the trick.

Composer and switching PHP versions

Composer is installed (in /usr/local/bin) for the packages that need it. You also have PHP versions 5.3 (with both APC and opcache), PHP 5.4, PHP 5.5, PHP 5.6 and PHP 7 all installed. By default the box comes up with PHP 7 running, but to switch to 5.6 temporarily:

$ sudo service php-fpm stop
$ sudo service php56-fpm start

Similarly, from the command line you can run php56.

Debugging Tools

For debugging, you have many options. Valgrind is installed and the suppressions file is up to date. I have included a helper script I use called memcheck. Try it:

$ memcheck php -v
==3788== Memcheck, a memory error detector
==3788== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==3788== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==3788== Command: php -v
==3788==
PHP 7.0.0-dev (cli) (built: Jan 28 2015 15:53:12) (DEBUG)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
==3788==
==3788== HEAP SUMMARY:
==3788==     in use at exit: 19,112 bytes in 17 blocks
==3788==   total heap usage: 29,459 allocs, 29,442 frees, 3,033,303 bytes allocated
==3788==
==3788== LEAK SUMMARY:
==3788==    definitely lost: 0 bytes in 0 blocks
==3788==    indirectly lost: 0 bytes in 0 blocks
==3788==      possibly lost: 0 bytes in 0 blocks
==3788==    still reachable: 0 bytes in 0 blocks
==3788==         suppressed: 19,112 bytes in 17 blocks
==3788==
==3788== For counts of detected and suppressed errors, rerun with: -v
==3788== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 28 from 6)

Also, sometimes it is easier to track down issues with a single standalone process instead of using php-fpm. You can do this like this:

$ sudo service php-fpm stop
$ sudo php-cgi -b /var/run/php-fpm.sock

The debug build will report memory leaks and you can of course run it under gdb or valgrind as well. See the /usr/local/bin/memcheck script for how to run Valgrind.

To update php7 to the latest, do this:

$ cd php-src
$ git pull -r
$ make distclean
$ ./buildconf -f
$ ./cn
$ make
$ sudo make install
$ sudo service php-fpm restart

It should be quite fast because ccache is installed and the cache should be relatively recent.

You will also find a .gdbinit symlink in ~vagrant which provides a number of useful gdb macros. The symlink into php-src should ensure you have the right set for the current checked out version of the code.

APT

And a tiny apt primer:

  • update pkg list: sudo apt-get update
  • search for stuff: apt-cache search stuff
  • install stuff: sudo apt-get install stuff
  • list installed: dpkg -l
  • upgrade installed: apt-get upgrade

If something isn't working or you have suggestions, please let me know.

1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (1.73 GB)

Next