- Learning PHP 7 High Performance
- Altaf Hussain
- 519字
- 2021-07-16 11:23:22
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:
- Make a directory in one of the drives. For example, we made a
php7
directory in ourD
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. - 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:
- 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:
- 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.
- 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 be127.0.0.1
, and the port will be2222
.Vagrant
is both the username and password for SSH. - 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.
- 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.
- Kibana Essentials
- Mastering RabbitMQ
- Python入門很簡單
- SQL Server 2012數據庫技術及應用(微課版·第5版)
- 動手玩轉Scratch3.0編程:人工智能科創教育指南
- Flask Web開發入門、進階與實戰
- UML+OOPC嵌入式C語言開發精講
- 假如C語言是我發明的:講給孩子聽的大師編程課
- Go并發編程實戰
- SQL經典實例(第2版)
- 蘋果的產品設計之道:創建優秀產品、服務和用戶體驗的七個原則
- Android項目實戰:手機安全衛士開發案例解析
- Python 3.7從入門到精通(視頻教學版)
- 深入實踐Kotlin元編程
- Android Development Tools for Eclipse