Prevent Apache from starting after apt-get install

Solution 1:

Try this:

  1. Create a file /usr/sbin/policy-rc.d with following content:
#!/bin/sh  
exit 101
  1. Make it executable:
chmod +x /usr/sbin/policy-rc.d

After this, all packages will be installed but the services will not start.

Once you are done, you can remove the file:

rm -f /usr/sbin/policy-rc.d

Solution 2:

Lots of options:

  1. Move the closed source content out of /var/www
  2. Change the permissions on that content such that the apache user cannot read it
  3. Iptables to stop port 80/443 traffic
  4. Pass a runlevel environment variable to apt-get:
sudo RUNLEVEL=1 apt-get install apache2