geerlingguy / drupal-vm

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

Non-FPM configuration requires an additional package for Ubuntu #393

Closed achton closed 8 years ago

achton commented 8 years ago

Trying to run 2.2.0 without FPM, but with a few other tweaks to the example config. When I access any PHP application (including adminer etc) in my browser, I am just served the code as plain text. It seems there is no php module available to apache:

$ sudo apache2ctl -l
Compiled in modules:
  core.c
  mod_so.c
  mod_watchdog.c
  http_core.c
  mod_log_config.c
  mod_logio.c
  mod_version.c
  mod_unixd.c

Here is my config (as a diff from example.config.yml):

--- example.config.yml  2016-01-24 09:23:53.373535677 +0100
+++ config.yml  2016-01-25 15:37:44.059703413 +0100
@@ -22,13 +22,15 @@
 vagrant_synced_folders:
   # The first synced folder will be used for the default Drupal installation, if
   # build_makefile: is 'true'.
-  - local_path: ~/Sites/drupalvm
+  - local_path: ~/Code/drupal-sites
     destination: /var/www/drupalvm
+    id: drupal
     type: nfs
     create: true
+    mount_options: [ 'nolock', 'vers=3', 'udp', 'noatime', 'actimeo=1' ]

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

 # The web server software to use. Can be either 'apache' or 'nginx'.
@@ -36,12 +38,12 @@

 # 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: true
+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: true
+install_site: false

 # Settings for building a Drupal site from a makefile (if 'build_makefile:'
 # is 'true').
@@ -82,6 +84,9 @@
     extra_parameters: |
           ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}"

+  - servername: "mysite.drupalvm.dev"
+    documentroot: "/var/www/drupalvm/mysite"
+
   - servername: "adminer.drupalvm.dev"
     documentroot: "/opt/adminer"

@@ -182,11 +187,11 @@
 firewall_log_dropped_packets: false

 # PHP Configuration. Currently-supported versions: 5.5, 5.6, 7.0.
-php_version: "5.6"
-php_memory_limit: "192M"
+php_version: "5.5"
+php_memory_limit: "256M"
 php_display_errors: "On"
 php_display_startup_errors: "On"
-php_enable_php_fpm: true
+php_enable_php_fpm: false
 php_realpath_cache_size: "1024K"
 php_sendmail_path: "/usr/sbin/ssmtp -t"
 php_opcache_enabled_in_ini: true
oxyc commented 8 years ago

To fix it you need to add libapache2-mod-php5 in extra_packages. https://github.com/geerlingguy/drupal-vm/issues/387#issuecomment-173291158

@geerlingguy for DX purposes what about simply adding the package to the example config? I've had two developers from our team ask me about it already :) It would be nice to support both fpm and mod_php out of the box. I understand that you don't want to add it to the apache role, but it would be a nice high level feature for Drupal VM.

achton commented 8 years ago

@oxyc Thanks for the feedback. I thought that might have been an intermediate step when upgrading from 2.1.x to 2.2.0. In my case, this is a freshly built box. In any case, without the mod-php5 package, I cannot see how the box can run with FPM disabled?

geerlingguy commented 8 years ago

@achton - My goal with 2.2.0 (and beyond) is to support primarily the FPM-only use case, as it's:

If a compelling argument can be made to preserve (and default to) mod_php support, I may consider semi-reverting my stance and adding libapache2-mod-php5 to example.config.yml extra packages, but as it is, I want to keep pushing people towards best practices with the defaults for Drupal VM.

You have to install libapache2-mod-php5 if you use a Debian/Ubuntu base box to get mod_php support. Note that on CentOS, you don't need to do so, as mod_php is already included with the base Apache packages.

achton commented 8 years ago

@geerlingguy Thanks for the quick response. In our case, we are indeed transitioning to FPM on our hosting platform. But until that change has been completed by our Ops department, I want to keep using mod_php as that is the current method. So on the long term, I also think that a FPM-only setup is the way to go.

I just needed a bit of guidance on how to continue here, which I have now, thanks. Also, I think this is a duplicate of #387.

Another thing: it seems that switching between FPM and non-FPM is not supported by the provisioning scripts? At least I find that I have to destroy/rebuild while testing these changes to get back to a working box.

geerlingguy commented 8 years ago

If you have mod_php installed, I think you can just leave PHP-FPM running and choose to switch between it and mod_php using the ProxyPass extra param as shown in example.config.yml, right?

oxyc commented 8 years ago

When running apt-get install manually it prompts about what to do with the current configuration files. Might be why a re-provision doesn't work after adding libapache2-mod-php5.

I'd still vote for using FPM by default but having mod_php installed so developers can swap them more easily. I'm guessing everyone does exactly what @achton did, and then comes here to try and figure out why it doesnt work. Having to install an extra package isn't immediately obvious.

geerlingguy commented 8 years ago

[Edit: whoops, hit the wrong button].

geerlingguy commented 8 years ago

One issue I have with adding the package the the default extra_packages is that this will be yet another thing that has to be edited for the box to provision correctly if someone switches to the centos6 or centos7 base box.

It seems it's mostly just a communication issue... though I don't have anything more than the release notes (e.g. https://github.com/geerlingguy/drupal-vm/releases/tag/2.2.0) to communicate the need to change an existing config.

oxyc commented 8 years ago

Hmm yeah that's not ideal either.

Maybe for the next few releases keep a comment about adding the package here (like a deprecation notice): https://github.com/geerlingguy/drupal-vm/blob/master/example.config.yml#L189

I'm guessing everyone who wants to swap look at that particular line.

geerlingguy commented 8 years ago

@oxyc - Good idea. We'll leave it in until we take it out :)