Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vagrant provision crashes in the middle of many Sites (vhosts) because Apache can't bind to port 80 #1948

Open
mikeziri opened this issue Jan 31, 2024 · 4 comments

Comments

@mikeziri
Copy link

mikeziri commented Jan 31, 2024

Versions

  • Vagrant: Vagrant 2.4.1
  • Provider: Parallels Desktop 19 for Mac
  • Homestead: Branch release commit 6c474ca51c6c8662c71c10cec11a6f1dd7a7fb3c (v15.0.2)

Host operating system

MacOS 14.3 (23D56) on Apple M2 Pro

Expected behavior

I have more than 100 vhosts on my Homestead.yaml.
After upgrading to the new box homestead (not -arm), did a full provision and expected the provision to end.

Actual behavior

The vagrant provision fails in different places after consecutive runs.
After provisioning the last "Site" before crashing, the vagrant provision outputs:

    homestead: Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
    homestead: Executing: /lib/systemd/systemd-sysv-install disable nginx
    homestead: Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
    homestead: Executing: /lib/systemd/systemd-sysv-install enable apache2
    homestead: Job for apache2.service failed.
    homestead: See "systemctl status apache2.service" and "journalctl -xeu apache2.service" for details.

I then login via ssh with vagrant ssh and run journalctl -xeu apache2.service outputing (in the end):

░░ A reload job for unit apache2.service has begun execution.
░░
░░ The job identifier is 32278.
Jan 31 15:39:06 homestead apachectl[96200]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.2.1. Set the 'ServerName' directi>
Jan 31 15:39:06 homestead apachectl[96200]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Jan 31 15:39:06 homestead apachectl[96200]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Jan 31 15:39:06 homestead apachectl[96200]: no listening sockets available, shutting down
Jan 31 15:39:06 homestead apachectl[96200]: AH00015: Unable to open logs
Jan 31 15:39:06 homestead apachectl[96200]: httpd not running, trying to start
Jan 31 15:39:06 homestead apachectl[96197]: Action 'graceful' failed.
Jan 31 15:39:06 homestead apachectl[96197]: The Apache error log may have more information.
Jan 31 15:39:06 homestead systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE

It seems the problem lies in the ipv4 (or ipv6) version:

(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80

Where Apache tries to bind to port 80 but fails.

My suspicion is the fact that on each Site provisioning, Nginx is disabled and then Apache is enabled. But sometimes, Nginx didn't yet release it's port 80 (socket) and Apache fails to bind.

There's not a clear pattern on which Site (vhost) it fails when provisioning. Almost always a different one.

Would it be possible to add an X seconds sleep in between Nginx disable and Apache enable commands while provisioning?
Better yet, is it possible to completely disable Nginx as an installed service as we only use Apache?

Although this is on Mac M2 (Arm), I have colleagues on Intel machines with the same problem.

Our workaround is to place the vhost we need to work on, on top of the Sites list on Homestead.yaml and provision again, hoping it goes past the first one.

@lachmart
Copy link

I'm encountering the same issue on an Intel Mac using the VirtualBox provider.

@svpernova09
Copy link
Contributor

svpernova09#2

@jakub-vozenilek
Copy link

I'm also having the same issue on an Intel Windows using the VirtualBox provider.

@lachmart
Copy link

lachmart commented Jul 2, 2024

I am only using Apache for all my websites. Here's a workaround that seems to be working, in case anyone else needs it:

  1. edit file scripts\site-types\apache.sh - remove lines with nginx and apache (lines 24-27 and 148-154)
sudo service nginx stop
sudo systemctl disable nginx
sudo systemctl enable apache2
service apache2 restart
service php"$5"-fpm restart

if [ $? == 0 ]
then
    service apache2 reload
fi
  1. add this to /after.sh
sudo service nginx stop
sudo systemctl disable nginx
sudo systemctl enable apache2
sudo service apache2 restart
sudo service php5.6-fpm restart
sudo service php7.0-fpm restart
sudo service php7.1-fpm restart
sudo service php7.2-fpm restart
sudo service php8.0-fpm restart
sudo service php8.1-fpm restart
sudo service php8.2-fpm restart
sudo service php8.3-fpm restart
sudo service apache2 reload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants