Preventing other applications from binding to port 80 and 443
You can't prevent a port from being bound by the wrong service. In your case, just remove apache from autostart and you should be good.
For 16.04 and newer:
sudo systemctl disable apache2
For older Ubuntu versions:
sudo update-rc.d apache2 disable
If you really aren't using apache2
, and it's PHP 7.0 that's requiring it, then it looks like you have libapache2-mod-php7.0
installed. That package is useless without Apache. Since you're using nginx, you likely also have php7.0-fpm
or php7.0-cgi
installed, either of which is sufficient for satisfying php7.0
's dependency requirements:
$ apt-cache depends php7.0
php7.0
|Depends: php7.0-fpm
|Depends: libapache2-mod-php7.0
Depends: php7.0-cgi
Depends: php7.0-common
Conflicts: <php5>
If you do have either of php7.0-{fpm,cgi}
installed, you can go ahead and uninstall Apache.