Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning PHP 7 High Performance

You're reading from   Learning PHP 7 High Performance Improve the performance of your PHP application to ensure the application users aren't left waiting

Arrow left icon
Product type Paperback
Published in Apr 2016
Publisher Packt
ISBN-13 9781785882265
Length 202 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Iltaf (Altaf) Hussain Gul Iltaf (Altaf) Hussain Gul
Author Profile Icon Iltaf (Altaf) Hussain Gul
Iltaf (Altaf) Hussain Gul
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Setting Up the Environment FREE CHAPTER 2. New Features in PHP 7 3. Improving PHP 7 Application Performance 4. Improving Database Performance 5. Debugging and Profiling 6. Stress/Load Testing PHP Applications 7. Best Practices in PHP Programming A. Tools to Make Life Easy B. MVC and Frameworks Index

Setting up Vagrant

Vagrant is a tool used by developers for development environments. Vagrant provides an easy command-line interface to set up virtual machines with all the tools required. Vagrant uses boxes called Vagrant Boxes that can have a Linux operating system and other tools according to this box. Vagrant supports both Oracle VM VirtualBox and VMware. For the purpose of this book, we will use VirtualBox, which we assume is installed on your machine as well.

Vagrant has several boxes for PHP 7, including Laravel Homestead and Rasmus PHP7dev. So, let's get started by configuring the Rasmus PHP7dev box on Windows and Mac OS X.

Note

We assume that both VirutalBox and Vagrant are installed on our machine. VirtualBox can be downloaded from https://www.virtualbox.org/wiki/Downloads, and Vagrant can be downloaded from https://www.vagrantup.com/downloads.html for different platforms. Details about Rasmus PHP7dev VagrantBox can be found at https://github.com/rlerdorf/php7dev.

Perform the following steps:

  1. Make a directory in one of the drives. For example, we made a php7 directory in our D drive. Then, open the command line in this specific folder directly by holding the Shift key, right-clicking, and then selecting Open command window here.
  2. Now, issue the following command in the command window:
    vagrant box add rasmus/php7dev
    

    It will start downloading the Vagrant box, as shown in the following screenshot:

    Setting up Vagrant
  3. Now, when the download is completed, we need to initialize it so that the box is configured and added to VirtualBox for us. Issue the following command in the command window:
    vagrant init rasmus/php7dev
    

    This will start adding the box to VirtualBox and configuring it. When the process is completed, it will display a message, as in the following screenshot:

    Setting up Vagrant
  4. Now, issue the following command, which will completely set up the Vagrant box and start it up and running:
    vagrant up
    

    This process will take a little bit of time. When it is completed, your box is ready and running and can be used.

  5. Now, the first thing to do after it is up is to update everything. This box uses Ubuntu, so open the command window in the same php7dev directory and issue the following command:
    vagrant ssh
    

    It will connect us with the virtual machines through SSH.

    Note

    In Windows, if SSH in not installed or not configured in the PATH variable, PuTTY can be used. It can be downloaded from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. For PuTTY, the host will be 127.0.0.1, and the port will be 2222. Vagrant is both the username and password for SSH.

  6. When we are logged in to the box OS, issue the following commands to update the system:
    sudo apt-get update
    sudo apt-get upgrade
    

    This will update the core system, NGINX, MySQL, PHP 7, and other installed tools if new versions are available.

  7. The box is now ready to use for development purposes. The box can be accessed in the browser by typing its IP address in the browser window. To find the IP address of the box, issue the following command in the SSH-connected command window:
    sudo ifconfig
    

    This will display some details. Find out the IPv4 details there and take the IP of the box.

You have been reading a chapter from
Learning PHP 7 High Performance
Published in: Apr 2016
Publisher: Packt
ISBN-13: 9781785882265
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image