geerlingguy / drupal-vm

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

Box provisions and installs d7 but times out when trying to access vm #592

Closed richierampage closed 8 years ago

richierampage commented 8 years ago

Hi,

tl;dr

Box provisions and install d7 but times out when trying to access vm, other installed apps such as adminer and dashboard work fine.

Detail

I've just started playing with drupal-vm although pretty familiar with vagrant/drupal/ansible. First impressions great!

What I am trying to do is automatically build a vm and then install Drupal from a project repo on bitbucket (I appreciate the benefits of make driven development but this is how we roll for smaller projects!).

I can not see an automated way out of the box to do this so I am trying cloning code repo on my host machine (mac running vmware fusion) into a dir called docroot that is at root of drupalvm project (as opposed to say ~/Sites/). Need to restructure things for version control but ok for now.

When I vagrant up, vm is built & site installed using my existing, pre-cloned codebase ( install_site: true ). I can ssh onto vm and successfully run drush status command which shows site installed. I can also get to dashboard, adminer and pimpmylog apps.

What I can't do is access site, it times out. :-(

Apache vhost configs look fine but there are no requests or errors in log files for my vm (other_vhosts log file). I do see entries for adminer etc. though so requests to vm don't seem to be getting to apache.

I can ping examplevm.dev and it resolves correctly. (using hostupdater for local/etc./hosts file updates).

Although it seems to be apache related to rule out my codebase I have cloned Drupal core and still the same.

My config.yml file is below. Pretty standard except I have changed boxname, ip and removed /drupal from synced directory.

Any ideas on what to try next would be much appreciated. :-)

Thanks

Rich

config.yml


---
# `vagrant_box` can also be set to geerlingguy/centos6, geerlingguy/centos7,
# geerlingguy/ubuntu1604, 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: examplevm.dev
vagrant_machine_name: example
vagrant_ip: 192.168.88.100

# 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:
  # The first synced folder will be used for the default Drupal installation, if
  # build_makefile: is 'true'.
  - local_path: docroot
    destination: /var/www/drupalvm
    type: nfs
    create: true

# Memory and CPU to use for this VM.
vagrant_memory: 1024
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: ../../drupal.make

# 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: true

# Settings for building a Drupal site from a makefile (if 'build_makefile:'
# is 'true').
drupal_major_version: 7
drupal_core_path: "/var/www/drupalvm"
drupal_domain: "{{ vagrant_hostname }}"
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`.
[]

# 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: "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
nginx_ppa_use: 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

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: []

# `nodejs` must be in installed_extras for this to work. Valid examples: "0.10",
# "0.12", "4.x", "5.x".
nodejs_version: "0.12"
nodejs_npm_global_packages: []
nodejs_install_npm_user: "{{ drupalvm_user }}"

# `ruby` must be in installed_extras for this to work.
ruby_install_gems_user: "{{ drupalvm_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"
firewall_log_dropped_packets: false

# PHP Configuration. Currently-supported versions: 5.5, 5.6, 7.0.
# PHP 7.0 requires a few additional changes. See the documentation at
# http://docs.drupalvm.com/en/latest/other/php-7/
php_version: "5.6"
php_memory_limit: "192M"
php_display_errors: "On"
php_display_startup_errors: "On"
php_realpath_cache_size: "1024K"
php_sendmail_path: "/usr/sbin/ssmtp -t"
php_opcache_enabled_in_ini: true
php_opcache_memory_consumption: "192"
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/{{ drupalvm_user }}/.composer"
composer_home_owner: "{{ drupalvm_user }}"
composer_home_group: "{{ drupalvm_user }}"
# composer_global_packages:
#   - { 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: 0
php_xdebug_coverage_enable: 0
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
oxyc commented 8 years ago

Everything does look correct. Can you access the site from within the VM?

vagrant ssh
...
curl http://examplevm.dev

One thing that comes to mind as you're using an existing codebase. Do you use any redirects within Drupal/htaccess, eg to https or www.?

richierampage commented 8 years ago

Good call about trying within the vm with curl will try that and post results. To rule out code issues I tried a vanilla d7 clone from d.o. with same results. Thanks for replying :-) On 5 May 2016 6:12 p.m., "Oskar Schöldström" notifications@github.com wrote:

Everything does look correct. Can you access the site from within the VM?

vagrant ssh ... curl http://examplevm.dev

One thing that comes to mind as you're using an existing codebase. Do you use any redirects within Drupal/htaccess, eg to https or www.?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/geerlingguy/drupal-vm/issues/592#issuecomment-217213612

oxyc commented 8 years ago

Some other things you could do to help debugging (unless someone else chimes in):

No idea what the problem could be but the more info the better. More eyes looking at things and maybe we can spot what's wrong.

richierampage commented 8 years ago

I can successfully request urls via curl from within the vm. Can't see it being a vhost issue but here it is anyway. :-)

<VirtualHost *:80> ServerName examplevm.dev DocumentRoot /var/www/drupalvm <Directory "/var/www/drupalvm"> AllowOverride All Options -Indexes +FollowSymLinks Require all granted </Directory> ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000/var/www/drupalvm" </VirtualHost>

All other vhosts are working fine externally to vm (adminer etc.), it's just drupal that's timing out. Here's adminer's vhost settings that is working fine.

<VirtualHost *:80> ServerName adminer.examplevm.dev DocumentRoot /opt/adminer <Directory "/opt/adminer"> AllowOverride All Options -Indexes +FollowSymLinks Require all granted </Directory> ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000/opt/adminer" </VirtualHost>

geerlingguy commented 8 years ago

@richierampage - Can you try setting the host to www.examplevm.dev instead? Maybe the bare domain is doing something funny... Since Google bought .dev, I've noticed strange things sometimes when using certain bare .dev domains.

Also, if you ping examplevm.dev on your host, what do you get?

richierampage commented 8 years ago

@geerlingguy I can confirm that the issue is with bate .dev domains.

www.examplevm.dev works fine, as does examplevm.local

Thanks for the pointer, I would never have considered that a specific tld defined in /etc/hosts could be treated differently than others!

geerlingguy commented 8 years ago

@richierampage - Thanks for the confirmation! Yeah, .dev worked splendid for a long time, until Google Alphabet had the gumption to go buy the TLD and break domains in weird ways.

oxyc commented 8 years ago

How rude! Should we consider switching the example host to something else? I see others are having that discussion as well https://github.com/Varying-Vagrant-Vagrants/VVV/issues/583

geerlingguy commented 8 years ago

Yeah... the problem is, what? I don't like .local because it has weird issues on both Mac OS X and Windows because of zeroconf... and something like .com would be problematic just like .dev :/

geerlingguy commented 8 years ago

I could maybe purchase the .drupalvm TLD if someone wants to front the money :)

oxyc commented 8 years ago

As per the discussion in the issue I referenced, it seems the only options are:

drupalvm.localhost, people wouldn't even understand that's a hostname... So maybe not :/

richierampage commented 8 years ago

How about prepending the drupal site url with www. the same as adminer etc? That worked ok for me with .dev but not sure if there are other issues with .dev due to the Alphabet ownership you mentioned?

geerlingguy commented 8 years ago

We could do a www., but that's still not too obvious. I'm leaning slightly towards .test... but that implies that the site is a 'test' site, not dev, prod, etc., and that could also throw people off. Though .dev has similar semantic issues.

The main thing is to find something that won't blow up someday. Naming things--

richierampage commented 8 years ago

All the other sites within drupalvm have a prefix (dashboard, adminer, pimpmylog) so how about we set a default for the drupal site that can be overridden in config?

The default value might be 'www' or whatever. This could then be overridden, in this way there would always is always a prefix and we could still use .dev. as when used with a subdomain e.g. drupal.examplevm.dev it seems to work fine.

site_​prefix​: drupal

Not considered multisite, haven't tried that yet within Drupalvm but should work I guess.