geerlingguy / drupal-vm

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

Ensure Apache is installed task failed #247

Closed ravbaba closed 8 years ago

ravbaba commented 9 years ago

I get the error for the ansible task "Ensure Apache is installed":

failed: [drupalvm] => (item=apache2,apache2-utils) => {"failed": true, "item": "apache2,apache2-utils"} stderr: dpkg: error processing archive /var/cache/apt/archives/apache2_2.4.16-4+deb.sury.org~trusty+4_amd64.deb (--unpack): error setting ownership of/var/www/html.dpkg-new': Operation not permitted Errors were encountered while processing: /var/cache/apt/archives/apache2_2.4.16-4+deb.sury.org~trusty+4_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)`

I am using:

geerlingguy commented 9 years ago

@ravbaba - It's likely your shared directory is not configured correctly; can you post the shared folders section, and the apache vhosts section, of your config.yml?

ravbaba commented 9 years ago
vagrant_synced_folders:
  - local_path: ~/Projects/drupalvm
    destination: /var/www
    id: drupal
    type: nfs
    create: true
apache_vhosts:
  - servername: "{{ drupal_domain }}"
    documentroot: "{{ drupal_core_path }}"

  - servername: "xhprof.drupalvm.dev"
    documentroot: "/usr/share/php/xhprof_html"

  - servername: "pimpmylog.drupalvm.dev"
    documentroot: "/usr/share/php/pimpmylog"
geerlingguy commented 9 years ago

Ah, sorry, one more thing too - what's the drupal_core_path set to?

And I guess one more thing—are you using the geerlingguy.ubuntu1404 base box or something else?

ravbaba commented 9 years ago

drupal_core_path: "/var/www/drupal"

geerlingguy commented 9 years ago

@ravbaba - Just for a quick test, can you remove the type: nfs line from the synced folder configuration, then do a vagrant reload --provision, and see if it works?

ravbaba commented 9 years ago

@geerlingguy - it works when I remove the line. It looks like nfs configuration on my ubuntu machine is not correct because it works on my mac with nfs.

devekko commented 9 years ago

me too on trusty

devekko commented 9 years ago

I think it might be something related to nfs etc/exports not being handled properly i.e. removed after a failed attempt, such as the ansible playbooks force requirements gotcha

alb404 commented 8 years ago

Hi. I had the same problem as ravbaba and fixed it by installing Guest Additions to Virtualbox. See: http://askubuntu.com/questions/22743/how-do-i-install-guest-additions-in-a-virtualbox-vm (Installing Guest Additions from a Terminal)

geerlingguy commented 8 years ago

Can everyone who's having this issue also look at @nateswart's blog post on the topic and see if it helps? https://nateofnine.com/2015/10/25/drupalvm-nfs-on-ubuntu/

lilswif commented 8 years ago

@geerlingguy followed the steps in the link you mentioned, and still having this problem. Running the same setup as the opener of this issue.

Part of my error message:

msg: '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"   install 'apache2' 'apache2-utils'' failed: perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US:",
    LC_ALL = (unset),
    LC_TIME = "de_BE.UTF-8",
    LC_MONETARY = "de_BE.UTF-8",
    LC_CTYPE = "C",
    LC_ADDRESS = "de_BE.UTF-8",
    LC_TELEPHONE = "de_BE.UTF-8",
    LC_NAME = "de_BE.UTF-8",
    LC_MEASUREMENT = "de_BE.UTF-8",
    LC_IDENTIFICATION = "de_BE.UTF-8",
    LC_NUMERIC = "de_BE.UTF-8",
    LC_PAPER = "de_BE.UTF-8",
    LANG = "C"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
dpkg: error processing archive /var/cache/apt/archives/apache2_2.4.16-4+deb.sury.org~trusty+4_amd64.deb (--unpack):
 error setting ownership of `/var/www/html.dpkg-new': Operation not permitted
Errors were encountered while processing:
 /var/cache/apt/archives/apache2_2.4.16-4+deb.sury.org~trusty+4_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
ennenine commented 8 years ago

One thing I (finally) figured out is that if you have encryption turned on for your home folder NFS to the VM won't work. I realized I didn't call very much attention to it in that blog post so it's easy to miss.

oxyc commented 8 years ago

@lilswif is there a line that begins with AcceptEnv LANG in /etc/ssh/sshd_config? Looks like you're passing your locale to the VM while this should have been prevented in https://github.com/geerlingguy/drupal-vm/issues/186

Edit: Just realised that task runs too late to be effective on the initial provisioning. @geerlingguy any ideas how to prevent it on the initial provisioning already? pre_tasks won't work as the variable is already present. Guess we could reset it... If we moved it here it would work if the user just re-ran vagrant provision at least.

@lilswif to get it working ASAP you can follow the suggestions @geerlingguy linked to in the other issue.

lilswif commented 8 years ago

still getting a error (see below) after trying:

ailed: [drupalvm] => (item=apache2,apache2-utils) => {"failed": true, "item": "apache2,apache2-utils"}
stderr: dpkg: error processing archive /var/cache/apt/archives/apache2_2.4.16-4+deb.sury.org~trusty+4_amd64.deb (--unpack):
 error setting ownership of `/var/www/html.dpkg-new': Operation not permitted
Errors were encountered while processing:
 /var/cache/apt/archives/apache2_2.4.16-4+deb.sury.org~trusty+4_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

stdout: Reading package lists...
Building dependency tree...
Reading state information...
apache2-utils is already the newest version.
The following packages were automatically installed and are no longer required:
  libyaml-0-2 python-crypto python-httplib2 python-jinja2 python-markupsafe
  python-paramiko python-pkg-resources python-support python-yaml sshpass
Use 'apt-get autoremove' to remove them.
Suggested packages:
  www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom
The following NEW packages will be installed:
  apache2
0 upgraded, 1 newly installed, 0 to remove and 35 not upgraded.
6 not fully installed or removed.
Need to get 0 B/144 kB of archives.
After this operation, 451 kB of additional disk space will be used.
(Reading database ... 63480 files and directories currently installed.)
Preparing to unpack .../apache2_2.4.16-4+deb.sury.org~trusty+4_amd64.deb ...
Unpacking apache2 (2.4.16-4+deb.sury.org~trusty+4) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...

msg: '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"   install 'apache2' 'apache2-utils'' failed: dpkg: error processing archive /var/cache/apt/archives/apache2_2.4.16-4+deb.sury.org~trusty+4_amd64.deb (--unpack):
 error setting ownership of `/var/www/html.dpkg-new': Operation not permitted
Errors were encountered while processing:
 /var/cache/apt/archives/apache2_2.4.16-4+deb.sury.org~trusty+4_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
geerlingguy commented 8 years ago

Does the fix suggested in https://github.com/geerlingguy/drupal-vm/issues/85#issuecomment-134315326 fix the issue for anyone in this thread?

kporras07 commented 8 years ago

provisioning without nfs:true line works for me. Then, I add back that line and everything works ok.

geerlingguy commented 8 years ago

In that case, it looks like the problem is basically that the html folder needs to be created for Apache to work correctly, but it is not. I'm testing things on some Linux flavors this week, and ran into this problem myself. It looks like the same fix for #85 worked here:

  1. (On your host) Create the folder html inside the synced folder directory (by default ~/Sites/drupalvm).
  2. Run vagrant provision again.

I'm going to look into a better way to make sure this issue doesn't occur on a fresh install, though. One other solution is to set your synced folder directory to something like ~/Sites/drupalvm/example or something like that (I think, haven't tested personally).

jygastaud commented 8 years ago

@geerlingguy You're right, html folder is needed and automaticaly created by Apache.

Using a subfolder inside /var/www solved that issue and no need to create /var/www/html.

Default should recommand something like that

vagrant_synced_folders:
  # The first synced folder will be used for the default Drupal installation, if
  # build_makefile: is 'true'.
  - local_path: ~/Sites/drupalvm
    destination: /var/www/drupalvm
    type: nfs
    create: true
geerlingguy commented 8 years ago

Fixed via the above commit, which updates the included example.config.yml and makes it so the default site is generated inside a subdir of the /var/www directory instead of having the synced folder take over that directory completely.