Skip to content

zikezhang/vagrant

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vagrant Phalcon

Phalcon strives to get closer to developers, providing flexible, powerful and simple tools. We would like a Phalcon development process to be effortless and pleasant from deployment of the development environment to the programming in Zephir language.

Vagrant provides a simple, elegant way to manage and provision Virtual Machines and this is a recommended Vagrant setup to get loaded with core development tools to build a powerful PHP application focused on Phalcon Framework.

Index

Landing Page

This is the default page for the Phalcon Vagrant Setup. This page will be empty at the beginning until you start adding VirtualHosts and content to the /www/ folder. Phalcon Vagrant

Overview

We use the default Ubuntu trusty64 ISO from Vagrant for compatibility. If you choose to use a 64-bit ISO you may need to update your BIOS to enable virtualization with AMD-V, Intel VT-x or VIA VT.

When you provision Vagrant for the first time it's always the longest procedure ($ vagrant up). Vagrant will download the entire Linux OS if you've never used Vagrant or the ubuntu/trusty64 Box. Afterwards, booting time is fast.

By default this setup uses 2 GB. You can change this in Vagrantfile and simply run $ vagrant reload. You can also use more than one core if you like, simply uncomment these two lines in the same file:

v.customize ["modifyvm", :id, "--cpus", "2"]
v.customize ["modifyvm", :id, "--ioapic", "on"]

Packages Included

Requirements

If you have issues with Windows and vbguest additions, use the following versions:

  • Virtualbox version 4.2.*
  • Vagrant 1.4.1

Installation

First you need a Git enabled terminal. Then you should clone this repository locally.

$ git clone https://github.com/phalcon/vagrant.git

For newer versions of Vagrant and VirtualBox you may need guest additions, so install the plugin:

# For Linux/OSX
$ vagrant plugin install vagrant-vbguest

# For Windows
$ vagrant plugin install vagrant-windows

Now you are ready to provision your Virtual Machine, run:

$ vagrant up

The init.sh script will provision the system with everything needed. Take a look inside if you want to change any default settings. Once provisioned, to access the box, simply type:

$ vagrant ssh

# To exit type:
$ exit

If you want to change your bound address (192.168.50.4), edit Vagrantfile, change the ip and run:

$ vagrant reload

If you want to point your Guest Machine (The Virtual Machine OS) to a friendly URL, you could modify your etc/hosts file and add the following:

192.168.50.4  your-server-name

Vagrant Credentials

These are credentials setup by default:

  • Host Address: 192.168.50.4 (Change in Vagrantfile if you like)
  • SSH: vagrant / vagrant (If root password fails, run $ sudo passwd and set one)
  • MySQL: root / (none)
  • PostgreSQL: postgres / postgres (We have disabled the password prompt for psql -U postgres command)
  • Redis: (none)

Create a Phalcon Project

To create your Phalcon project, head over to the default working directory:

$ cd /vagrant/www

Then run the following command using the Phalcon Dev Tools to see your options:

$ phalcon

To create a project type the following, I'll create one called superstar for this example:

$ phalcon project superstar

This will create a folder called superstar with all your Phalcon files. At this point you have a folder at /vagrant/www/superstar and your VirtualHost will need to point to /vagrant/www/superstar/public

Create a VHost Record

You can have multiple Phalcon projects in subfolders. Make sure to keep your base VirtualHost enabled, in our case it's the vagrant.conf enabled by default. Then follow the instructions below and take note, you must include the ServerPath /project/ in your VirtualHost's.

Do not include a ServerPath for the base vagrant.conf VirtualHost.

$ touch superstar.conf

Then include the following data. Notice the two directory paths with superstar:

<VirtualHost *:80>
    DocumentRoot /vagrant/www/superstar/public
    ServerPath /superstar
</VirtualHost>

<Directory "/vagrant/www/superstar/public">
    Options Indexes Followsymlinks
    AllowOverride All
    Require all granted
</Directory>

Next move your VirtualHost configuration file to sites-available in Apache:

$ sudo mv superstar.conf /etc/apache2/sites-available

Lastly, you must enable your configuration file and restart apache

$ sudo a2ensite superstar
$ sudo service apache2 reload

If you wanted to disable a site:

$ sudo a2dissite superstar
$ sudo service apache2 reload

You should be able to access the following URL's:

http://192.168.50.4/
http://192.168.50.4/superstar

Local Editing

On your Host computer open any file explorer or IDE and navigate to /www/. This folder is mounted to the Virtual Machine. Any changes to files within here will reflect realtime changes in the Virtual Machine.

If you are using .git you should initialize your repository locally rather than on the server. This way you will not have to import keys into your Virtual Machine.

Using SSH

Files in the shared directory of www are by default given ownership of vagrant:vagrant so that you will have no problems with saving cached files.

Troubleshooting Vagrant Ubuntu

If you are using Linux such as Ubuntu, you may have to set a different IP that doesn't interfere with DHCP in linux, here is a safe bet:

  • 192.168.50.4

If you are using the latest VirtualBox with Ubuntu 14, after installing guest additions (below), to fix the error message you will get due to a bug in the guest additions do the following after you run $ vagrant up.

$ vagrant ssh
$ sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
$ vagrant reload

Troubleshooting Phalcon

If you are having trouble with Phalcon in this Vagrant Project (Or on your live server), try compiling in safe mode.

If you are having problems with guest-additions on linux with mounting folders run this command in the guest machine:

$ sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions

Software Suggestions

If you are using Linux you can use the built in Terminal to do everything. The same goes with OSX.

For Windows, you can use Git SCM and Bash.

License

Phalcon MVC Examples is open source software licensed under the New BSD License. See the LICENSE.txt file for more.
Copyright (c) 2011-2016, Phalcon Framework Team

About

Vagrant box for PHP7.0, Phalcon......

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%