1

I am trying to build virtual machine using vagrant, virtualbox and CentOS 7 64bit. Host OS is Ubuntu 14.04 64bit. Vagrant is 1.9.2, VirtualBox 5.1.6.

Here is the Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.box_check_update = false

  # Enable cache if plugin is installed
  # To install it execute: vagrant plugin install vagrant-cachier
  # cache will be located in [thisvagrantdir]/.vagrant/machines/default/cache
  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.auto_detect = true
    config.cache.scope       = :machine
  end

  config.vm.network "private_network", ip: "192.168.33.101"

  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
  config.hostmanager.aliases = %w(centos7.dev)

  config.ssh.forward_agent = true
  config.vm.synced_folder ".", "/vagrant", type: "nfs"

  config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--memory", "2048"   ]
    vb.customize ["modifyvm", :id, "--name"  , "centos7"]
  end

  config.vm.provision "shell" do |s|
     s.privileged = true
     s.path       = "provisioner.sh"
  end

end

Now in the provisioner.sh I install PHP, some extensions and add one config file for apache located in /etc/httpd/conf.d/site.conf . Here is the site.conf:

<VirtualHost _default_:80>
     ServerAdmin webmaster@example.com
     DocumentRoot /vagrant/www/moodle
     ServerName centos7.dev
     ErrorLog /vagrant/log/error.log
     CustomLog /vagrant/log/requests.log combined

  <IfModule dir_module>
    DirectoryIndex index.php index.html
  </IfModule>

  <Directory /vagrant/www/moodle>
    Options All
    AllowOverride All
    Require all granted
  </Directory>

  <Location />
     LogLevel warn
  </Location>

</VirtualHost>

/vagrant/www/moodle is NFS attached dir from host system.

After all this is done apache just refuses to start. I can run sudo systemctl start httpd.service 100 times and nothing happens. However if I run it with sudo httpd it works???!!!

This is what I get as status

[vagrant@default ~]$ sudo systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since mar 2017-05-09 11:29:09 UTC; 8s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 7149 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 7148 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 7148 (code=exited, status=1/FAILURE)

may 09 11:29:09 default systemd[1]: Starting The Apache HTTP Server...
may 09 11:29:09 default systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
may 09 11:29:09 default kill[7149]: kill: cannot find process ""
may 09 11:29:09 default systemd[1]: httpd.service: control process exited, code=exited status=1
may 09 11:29:09 default systemd[1]: Failed to start The Apache HTTP Server.
may 09 11:29:09 default systemd[1]: Unit httpd.service entered failed state.
may 09 11:29:09 default systemd[1]: httpd.service failed.

Any ideas as to what I'm doing wrong here? Thanks

Added content of error_log

  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  [Tue May 09 02:00:13.473097 2017] [core:notice] [pid 24635] SELinux policy enabled; httpd running as context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
  [Tue May 09 02:00:13.475731 2017] [suexec:notice] [pid 24635] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
  [Tue May 09 02:00:13.504866 2017] [auth_digest:notice] [pid 24636] AH01757: generating secret for digest authentication ...
  [Tue May 09 02:00:13.507336 2017] [lbmethod_heartbeat:notice] [pid 24636] AH02282: No slotmem from mod_heartmonitor
  [Tue May 09 02:00:13.536814 2017] [mpm_prefork:notice] [pid 24636] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
  [Tue May 09 02:00:13.536867 2017] [core:notice] [pid 24636] AH00094: Command line: 'httpd'
  [Tue May 09 02:05:20.671219 2017] [mpm_prefork:notice] [pid 24636] AH00169: caught SIGTERM, shutting down
  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  [Tue May 09 02:07:52.571217 2017] [core:notice] [pid 6154] SELinux policy enabled; httpd running as context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
  [Tue May 09 02:07:52.573223 2017] [suexec:notice] [pid 6154] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
  [Tue May 09 02:07:52.599432 2017] [auth_digest:notice] [pid 6155] AH01757: generating secret for digest authentication ...
  [Tue May 09 02:07:52.601028 2017] [lbmethod_heartbeat:notice] [pid 6155] AH02282: No slotmem from mod_heartmonitor
  [Tue May 09 02:07:52.671389 2017] [mpm_prefork:notice] [pid 6155] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
  [Tue May 09 02:07:52.671423 2017] [core:notice] [pid 6155] AH00094: Command line: 'httpd'
  [Tue May 09 02:20:28.697078 2017] [mpm_prefork:notice] [pid 6155] AH00169: caught SIGTERM, shutting down
  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  [Tue May 09 11:14:29.277789 2017] [core:notice] [pid 7361] SELinux policy enabled; httpd running as context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
  [Tue May 09 11:14:29.285279 2017] [suexec:notice] [pid 7361] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
  [Tue May 09 11:14:29.307699 2017] [auth_digest:notice] [pid 7362] AH01757: generating secret for digest authentication ...
  [Tue May 09 11:14:29.309339 2017] [lbmethod_heartbeat:notice] [pid 7362] AH02282: No slotmem from mod_heartmonitor
  [Tue May 09 11:14:29.448865 2017] [mpm_prefork:notice] [pid 7362] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
  [Tue May 09 11:14:29.448913 2017] [core:notice] [pid 7362] AH00094: Command line: 'httpd'
  [Tue May 09 11:19:24.274215 2017] [mpm_prefork:notice] [pid 7362] AH00169: caught SIGTERM, shutting down
  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  (13)Permission denied: AH00091: httpd: could not open error log file /vagrant/log/error.log.
  AH00015: Unable to open logs
  [Tue May 09 11:32:03.917301 2017] [core:notice] [pid 7210] SELinux policy enabled; httpd running as context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
  [Tue May 09 11:32:03.919728 2017] [suexec:notice] [pid 7210] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
  [Tue May 09 11:32:03.944005 2017] [auth_digest:notice] [pid 7211] AH01757: generating secret for digest authentication ...
  [Tue May 09 11:32:03.945572 2017] [lbmethod_heartbeat:notice] [pid 7211] AH02282: No slotmem from mod_heartmonitor
  [Tue May 09 11:32:04.013106 2017] [mpm_prefork:notice] [pid 7211] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
  [Tue May 09 11:32:04.013158 2017] [core:notice] [pid 7211] AH00094: Command line: 'httpd'
  • What does the apache error log say? – Jenny D May 9 '17 at 13:39
  • Added. It seems to be permissions and selinux issue? – Darko Miletic May 9 '17 at 14:18
  • 1
    well, check if /vagrant/log/ exists and it is writable by httpd. Supposedly httpd runs as root for this but if the directory is present chances are SELinux is not allowing it. – ezra-s May 9 '17 at 16:10
  • /vagrant/log exists and it has 777 mask. I will try disabling selinux – Darko Miletic May 9 '17 at 16:24
1

As user ezra-s already mentioned SELinux was the culprit. As soon as I executed

sudo setenforce 0
sudo systemctl start httpd.service

Everything started working. I will disable SELinux permanently since this is pure test VM.

Thanks everybody.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.