Working With Apache on EC2's Ubuntu Image

Restarting Apache

To restart apache you can run sudo service apache2 reload, apachectl, apache2ctl

Config Files

  • Config files for apache are located in /etc/apache2.
  • Do not modify apache2.conf, instead add your own custom configuration files to the conf-available folder. It looks like the naming convention is to prefix custom conf files with local, e.g. local-my-custom-config.conf.

To enable config files use the a2enconf command, e.g. a2enconf local-my-custom-config. This command will create a symbol link to your config file in the mods-enabled folder. Similarly, you can use a2disconf to disabled configuration files, e.g. a2disconf local-my-custom config.

Enabling and Disabled Modules

To enabled and disable modules, use a2enmod and ha2dismod like you did with the config commands, e.g. a2enmod rewrite.

Configuration Testing

To test your apache configuration you can run apache2ctl configtest

I've Modified apache2.conf, how do I restore it?

First check to see which package installed apache. It was probably apache2.

user@host$ dpkg -S apache2.conf
apache2: /etc/apache2/apache2.conf

Backup the file...

sudo mv apache2.conf apache2.conf.bak

Run the following command to restore apache2.conf...

sudo apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall apache2

You should see a messaging sayin that apache2.conf could not be found, and that the file will be restored. Read more here.