geerlingguy / drupal-vm

A VM for Drupal development
https://www.drupalvm.com/
MIT License
1.37k stars 645 forks source link

config.yml PHP settings not being applied to php.ini as expected #507

Closed justinlevi closed 8 years ago

justinlevi commented 8 years ago

We recently discovered that the config.yml PHP settings don't seem to be getting applied to the php.ini file loaded by apache at /etc/php5/fpm/php.ini but instead are getting applied to /etc/php5/apache2/php.ini.

Here are the values I expect to show up in my php.ini

# PHP Configuration. Currently-supported versions: 5.5, 5.6, 7.0.
php_version: "5.6"
php_memory_limit: "256M"
php_display_errors: "On"
php_display_startup_errors: "On"
php_realpath_cache_size: "2048K"
php_sendmail_path: "/usr/sbin/ssmtp -t"
php_opcache_enabled_in_ini: true
php_opcache_memory_consumption: "256"
php_opcache_max_accelerated_files: 4096
php_max_input_vars: "4000"

Here's what I'm seeing at phpinfo()

Configuration File (php.ini) Path = /etc/php5/fpm/php.ini memory_limit = 128M

capture

Here's my complete config.yml


---
# `vagrant_box` can also be set to geerlingguy/centos6, geerlingguy/centos7,
# geerlingguy/ubuntu1204, parallels/ubuntu-14.04, etc.
vagrant_box: geerlingguy/ubuntu1404
vagrant_user: vagrant
vagrant_synced_folder_default_type: nfs

# If you need to run multiple instances of Drupal VM, set a unique hostname,
# machine name, and IP address for each instance.
vagrant_hostname: vm
vagrant_machine_name: vm
vagrant_ip: 192.168.88.88

# Allow Drupal VM to be accessed via a public network interface on your host.
# Vagrant boxes are insecure by default, so be careful. You've been warned!
# See: https://docs.vagrantup.com/v2/networking/public_network.html
vagrant_public_ip: ""

# A list of synced folders, with the keys 'local_path', 'destination', and
# a 'type' of [nfs|rsync|smb] (leave empty for slow native shares). See
# http://docs.drupalvm.com/en/latest/extras/syncing-folders/ for more info.
vagrant_synced_folders:
  - local_path: C:\drupal\sites\d8
    destination: /var/www/d8
    type: nfs
    create: true

  - local_path: C:\drupal\sites\nysptracs-dev
    destination: /var/www/nysptracs
    type: nfs
    create: true

  - local_path: C:\drupal\sites\nysafeschools-dev
    destination: /var/www/nysafeschools
    type: nfs
    create: true

# Memory and CPU to use for this VM.
vagrant_memory: 2048
vagrant_cpus: 2

# The web server software to use. Can be either 'apache' or 'nginx'.
drupalvm_webserver: apache

# Set this to false if you are using a different site deployment strategy and
# would like to configure 'vagrant_synced_folders' and 'apache_vhosts' manually.
build_makefile: false
drush_makefile_path: /vagrant/drupal.make.yml

# Set this to false if you don't need to install drupal (using the drupal_*
# settings below), but instead copy down a database (e.g. using drush sql-sync).
install_site: false

# Settings for building a Drupal site from a makefile (if 'build_makefile:'
# is 'true').
drupal_major_version: 8
drupal_core_path: "/var/www"
drupal_domain: "local.vm"
drupal_site_name: "Drupal"
drupal_install_profile: standard
drupal_enable_modules: [ 'devel' ]
drupal_account_name: admin
drupal_account_pass: admin
drupal_mysql_user: drupal
drupal_mysql_password: drupal
drupal_mysql_database: drupal

# Additional arguments or options to pass to `drush site-install`.
drupal_site_install_extra_args: []

# Cron jobs are added to the root user's crontab. Keys include name (required),
# minute, hour, day, weekday, month, job (required), and state.
drupalvm_cron_jobs: []
  # - {
  #   name: "Drupal Cron",
  #   minute: "*/30",
  #   job: "drush -r {{ drupal_core_path }} core-cron"
  # }

# Drupal VM automatically creates a drush alias file in your ~/.drush folder if
# this variable is 'true'.
configure_local_drush_aliases: true

# Apache VirtualHosts. Add one for each site you are running inside the VM. For
# multisite deployments, you can point multiple servernames at one documentroot.
# View the geerlingguy.apache Ansible Role README for more options.
apache_vhosts:
  # - servername: "{{ drupal_domain }}"
  #   documentroot: "{{ drupal_core_path }}"
  #   extra_parameters: |
  #         ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}"

  - servername: "d8.vm"
    documentroot: "/var/www/d8/docroot"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000/var/www/d8/docroot"

  - servername: "nysptracs.vm"
    documentroot: "/var/www/nysptracs/docroot"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000/var/www/nysptracs/docroot"

  - servername: "nysafeschools.vm"
    documentroot: "/var/www/nysafeschools/docroot"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000/var/www/nysafeschools/docroot"

  - servername: "adminer.{{ vagrant_hostname }}"
    documentroot: "{{ adminer_install_dir }}"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ adminer_install_dir }}"

  - servername: "xhprof.{{ vagrant_hostname }}"
    documentroot: "{{ php_xhprof_html_dir }}"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ php_xhprof_html_dir }}"

  - servername: "pimpmylog.{{ vagrant_hostname }}"
    documentroot: "{{ pimpmylog_install_dir }}"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ pimpmylog_install_dir }}"

  - servername: "{{ vagrant_ip }}"
    serveralias: "dashboard.{{ vagrant_hostname }}"
    documentroot: "{{ dashboard_install_dir }}"

apache_remove_default_vhost: true
apache_mods_enabled:
  - expires.load
  - ssl.load
  - rewrite.load
  - proxy.load
  - proxy_fcgi.load

# Nginx hosts. Each site will get a server entry using the configuration defined
# here. Set the 'is_php' property for document roots that contain PHP apps like
# Drupal.
nginx_hosts:
  - server_name: "{{ drupal_domain }}"
    root: "{{ drupal_core_path }}"
    is_php: true

  - server_name: "adminer.{{ vagrant_hostname }}"
    root: "{{ adminer_install_dir }}"
    is_php: true

  - server_name: "xhprof.{{ vagrant_hostname }}"
    root: "{{ php_xhprof_html_dir }}"
    is_php: true

  - server_name: "pimpmylog.{{ vagrant_hostname }}"
    root: "{{ pimpmylog_install_dir }}"
    is_php: true

  - server_name: "{{ vagrant_ip }} dashboard.{{ vagrant_hostname }}"
    root: "{{ dashboard_install_dir }}"

nginx_remove_default_vhost: true

# MySQL Databases and users. If build_makefile: is true, first database will
# be used for the makefile-built site.
mysql_databases:
  - name: "{{ drupal_mysql_database }}"
    encoding: utf8
    collation: utf8_general_ci

  - name: "d8"
    encoding: utf8
    collation: utf8_general_ci

  - name: "nysptracs"
    encoding: utf8
    collation: utf8_general_ci

  - name: "nysafeschools"
    encoding: utf8
    collation: utf8_general_ci

mysql_users:
  - name: "{{ drupal_mysql_user }}"
    host: "%"
    password: "{{ drupal_mysql_password }}"
    priv: "{{ drupal_mysql_database }}.*:ALL"

# Comment out any extra utilities you don't want to install. If you don't want
# to install *any* extras, make set this value to an empty set, e.g. `[]`.
installed_extras:
  - adminer
  - drupalconsole
  # - mailhog
  - memcached
  - nodejs
  - pimpmylog
  # - redis
  - ruby
  - selenium
  # - solr
  # - varnish
  - xdebug
  - xhprof

# Add any extra apt or yum packages you would like installed.
extra_packages:
  - unzip
  - graphicsmagick
  - graphicsmagick-imagemagick-compat

# `nodejs` must be in installed_extras for this to work.
# "0.12", "4.x", "5.x".
nodejs_version: "0.12"
nodejs_npm_global_packages: []
  # This does not work as expected. Installs under sudo and not under the vagrant user.
  # Means that you need to install each of these manually
  # - { name: phantomjs, version: 1.9.8 }
  # - { name: webdriverio, version: 2.4.5 }
  # - { name: phantomcss }
  # - { name: jquery }

# `ruby` must be in installed_extras for this to work.
ruby_install_gems_user: "{{ vagrant_user }}"
ruby_install_gems: []

# You can configure almost anything else on the server in the rest of this file.
extra_security_enabled: false

drush_version: "master"
drush_keep_updated: true
drush_composer_cli_options: "--prefer-dist --no-interaction"

firewall_allowed_tcp_ports:
  - "22"
  - "25"
  - "80"
  - "81"
  - "443"
  - "4444"
  - "8025"
  - "8080"
  - "8443"
  - "8983"
  - "7055"
firewall_log_dropped_packets: false

# PHP Configuration. Currently-supported versions: 5.5, 5.6, 7.0.
php_version: "5.6"
php_memory_limit: "256M"
php_display_errors: "On"
php_display_startup_errors: "On"
php_realpath_cache_size: "2048K"
php_sendmail_path: "/usr/sbin/ssmtp -t"
php_opcache_enabled_in_ini: true
php_opcache_memory_consumption: "256"
php_opcache_max_accelerated_files: 4096
php_max_input_vars: "4000"

# Drupal VM defaults to using PHP-FPM with either Apache or Nginx. If you wish
# to instead use Apache + mod_php with an Ubuntu base box, make sure you add
# libapache2-mod-php5 to `extra_packages` elsewhere in this config file.
php_enable_php_fpm: true
php_fpm_listen: "127.0.0.1:9000"

composer_path: /usr/bin/composer
composer_home_path: '/home/vagrant/.composer'
composer_global_packages: []
# - { name: drupal/drupal-extension, release: '*' }
# - { name: phpunit/phpunit, release: '@stable' }
# - { name: behatch/contexts, release: '*' }
# - { name: behat/mink, release: '1.5.*@stable' }
# - { name: behat/mink-goutte-driver, release: '*' }
# - { name: behat/mink-selenium2-driver, release: '*' }
# - { name: phpunit/phpunit, release: '@stable' }

# Run specified scripts after VM is provisioned. Path is relative to the
# `provisioning/playbook.yml` file.
post_provision_scripts: []
  # - "../examples/scripts/configure-solr.sh"

# MySQL Configuration.
mysql_root_password: root
mysql_slow_query_log_enabled: true
mysql_slow_query_time: 2
mysql_wait_timeout: 300
adminer_install_filename: index.php

# Varnish Configuration.
varnish_listen_port: "81"
varnish_default_vcl_template_path: templates/drupalvm.vcl.j2
varnish_default_backend_host: "127.0.0.1"
varnish_default_backend_port: "80"

# Pimp my Log settings.
pimpmylog_install_dir: /usr/share/php/pimpmylog
pimpmylog_grant_all_privs: true

# XDebug configuration. XDebug is disabled by default for better performance.
php_xdebug_default_enable: 1
php_xdebug_coverage_enable: 1
php_xdebug_cli_enable: 1
php_xdebug_remote_enable: 1
php_xdebug_remote_connect_back: 1
# Use PHPSTORM for PHPStorm, sublime.xdebug for Sublime Text.
php_xdebug_idekey: PHPSTORM
php_xdebug_max_nesting_level: 256

# Solr Configuration (if enabled above).
solr_version: "4.10.4"
solr_xms: "64M"
solr_xmx: "128M"

# Selenium configuration.
selenium_version: 2.46.0

# Other configuration.
dashboard_install_dir: /var/www/dashboard
known_hosts_path: ~/.ssh/known_hosts

selenium_install_firefox: "true"

I tried to dig in a bit further and maybe it has something to do with this file??? drupal-vm\provisioning\roles\geerlingguy.php\vars\Debian.yml:

# Vendor-specific configuration paths on Debian/Ubuntu make my brain asplode.
__php_conf_path: "{{ '/etc/php5' if php_webserver_daemon and php_webserver_daemon != 'apache2' else '/etc/php5/apache2' }}"
__php_extension_conf_path: "{{ __php_conf_path }}/conf.d"

I could be totally off though as I don't have any experience with the magic that's going on here :)

justinlevi commented 8 years ago

Oh, I'm also working off the latest master commit as of this morning. https://github.com/geerlingguy/drupal-vm/commit/9ada7ab8c5e6731c7c8362a9e09ad65fc5142308

oxyc commented 8 years ago

You are correct, that is the line causing trouble :) The fix should already be in upstream though. Try updating the role.

sudo ansible-galaxy install -r provisioning/requirements.yml --force

This was first fixed in https://github.com/geerlingguy/ansible-role-php/commit/29826297df63d5cce4673d71ab7084af96b38a62 and then more recently revamped to apply to all config files regardless of the daemon/webserver settings https://github.com/geerlingguy/ansible-role-php/commit/a1dd9901ec5e0a456849a2808ee63d8a5f5180f1.

justinlevi commented 8 years ago

@oxyc good deal. glad to see I was at least looking in the right place. Could you explain to me what is meant by The fix should already be in upstream though

I have the latest version of drupal-vm as of this morning. If the upstream has the fix, wouldn't doing a $vagrant up and/or $vagrant reload --provision use the fixed ansible role? Again, forgive my ignorance with this Ansible stuff. I'm still trying to wrap my head around how it all works.

also, where should I run that command? From a terminal ssh connection within the VM? Today I'm working on a Windows 7 box and running that command gives me:

λ vagrant ssh
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 4.2.0-27-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
vagrant@vm:~$ sudo ansible-galaxy install -r provisioning/requirements.yml --force
 [ERROR]: Unable to open provisioning/requirements.yml: [Errno 2] No such file or directory:
'provisioning/requirements.yml'

I realize I'm probably missing something obvious here but I'm not clear when this upstream fix would show up for me if it's not there with the latest git pull of the drupal-vm repo.

Thanks for your help understanding how this all works!

oxyc commented 8 years ago

The roles do not get updated by any vagrant commands unfortunately, you need to update them manually :/ If you're on windows I think you need to do it from the /vagrant directory on the guest VM (basically from the root of the Drupal VM checkout where that requirements.yml file is accessable).

cd /vagrant
sudo ansible-galaxy install -r provisioning/requirements.yml --force
justinlevi commented 8 years ago

Unfortunately, I'm getting a missing command error when I try to run that on windows. Likely because ansible and ruby are not setup on my PATH variable.

I figured out thought that if I just delete my provisioning/roles folder then a $vagrant destroy && vagrant up that did the trick.

I noticed that the roles folder doesn't seem to be created anymore. Is there a way to add a check in the VagrantFile to delete that if it exists so other people don't run into this issue?

oxyc commented 8 years ago

:+1: great! Yes it seems that ansible-galaxy doesn't have an update command. If the role directory already exists it fails to download a new version, which is why we use the --force flag. The provisioning script for windows doesn't use --force however and that's why it worked for you after you deleted the directories and not before.

Hopefully ansible-galaxy will one day support a lockfile like composer. I'm guessing Drupal VM would start using --force when that happens.

ghost commented 8 years ago

My solution to that was SSH into the VM and do the ansible-galaxy update from inside the VM on my Windows machine.

geerlingguy commented 8 years ago

Yeah, if you don't have Ansible installed locally (if you're on Windows, this is most likely the case), then you have to vagrant ssh in, then cd to the /vagrant directory and run the galaxy install command inside there. Fingers are still crossed for Galaxy to someday use an idempotent command for ensuring the latest versions of all the roles are present...

esteinborn commented 8 years ago

I couldn't get it to re-provision using my config.yml values using the ssh and galaxy setup. I had to manually delete the roles folder, and then vagrant reload --provision and it worked.