vagrant + ContOS7 + php7.2 + nginx + phalcon4 environment construction and problem recording

2 minute read

vagrant + ContOS7 + php7.2 + nginx + phalcon4 environment construction and problem recording


Tool installation:

1. Launching a virtual environment

$ mkdir phalcon
$ cd phalcon
$ mkdir sync
$ vagrant init CentOS7

Edit phalcon / Vagrantfile

Vagrant.configure("2") do |config| = "centos/7"
  #IP address for local access. "private_network", ip: ""
  #Specify the synchronization destination. "Current directory (.)/"Synchronize under vagrant" and "sync directory"/var/www/Synchronize below.
  config.vm.synced_folder ".", "/vagrant"
  config.vm.synced_folder "sync", "/var/www/" "forwarded_port", guest: 80, host: 8080
  #Now let's use epel and remi.
  config.vm.provision "shell", inline: <<-SHELL
    sudo yum update -y
    sudo yum -y install epel-release
    sudo rpm -Uvh

Launch vagrant

$ cd phalcon
$ vagrant up --provision

If an error occurs, handle it with an error message.

Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

The solution is:

$ vagrant plugin install vagrant-vbguest

2. Install the required applications in the virtual environment

$ vagrant ssh
$ sudo yum install --enablerepo=remi-php72 php php-mbstring php-mcrypt php-mysqlnd php-pdo php-fpm nginx -y

Edit php-fpm settings

$ sudo vi /etc/php-fpm.d/www.conf

Note: Search vim with “/”


; user = apache 
; group = apache
; listen =
;listen.owner = nobody
; = nobody

user = nginx    
group = nginx    
listen = /run/php-fpm/php-fpm.sock  
listen.owner = nginx = nginx   

Edit nginx settings

sudo vi /etc/nginx/nginx.conf

For root, specify the root directory specified in the Vagrantfile mentioned above.
I set “allow all;”, but when I control access by IP address with Nginx, I set it separately.


 server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /var/www;
        index index.php index.html index.htm;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        location / {
            try_files $uri $uri/ /index.php;

        error_page 404 /404.html;
            location = /40x.html {

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {

        location ~ .php$ {
            fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
            include fastcgi_params;

At this stage, test the server once

$ exit
$ cd sync
$ touch index.php


<?php phpinfo();

After completing the settings, check if the file is reflected in the virtual environment.

[vagrant@localhost /]$ cd var/www
[vagrant@localhost www]$ ls
cgi-bin  html  index.php

Start the server. Note: A reboot is required when new additions such as php extensions occur.

$ vagrant ssh
$ sudo systemctl restart php-fpm
$ sudo systemctl restart nginx

##Status check, successful if active
$ sudo systemctl status php-fpm
$ sudo sudo systemctl status nginx

If you access and the phpinfo page appears, you are successful.

Occasionally, in the case of “403 Forbidden with Nginx”, there is a workaround either to change the permissions of the files under “/ var / www” or to disable SELinux.

3. Install phalcon4

$ sudo yum install --enablerepo=remi-php72 php-phalcon4 -y

Find the installed

$ find / -name

Found in the following places.

php --info | grep phalcon

If you output below, you’re done:

phalcon => enabled

Access again, and if “phalcon” appears on the phpinfo page, it is successful.
スクリーンショット 2020-09-09 15.20.36.png