How to configure AppArmor profile for Apache2 on Ubuntu 14.04 LTS?

I am trying to configure an ubuntu (14.04 LTS) linux server with apparmor to protect the Apache2 web server, but I can't find any best practice or how-to guides for this specific purpose, only some basic guides for apparmor with the default profiles which do not include apache2 configuration. The ubuntu web server is running Apache2, Drupal 7, and MySQL. Is there a basic template for the AppArmor-Apache2 config that I should be implementing for basic security or is this something that has to be specific to the site?
Jaime BonillaSystems AdmininistratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dfkeCommented:
Hi,

Here's a template for apache2 that might help you out to start with.

It may be more or less restrictive for what you're running on your website (for example, I don't use MySQL), so you'll need to run it for a while in complain mode until you don't see any more "audit" warnings in /var/log/messages.

You will also need to add read permission for your website's document root.

/usr/sbin/apache2 flags=(complain) {
#include <abstractions/base>

capability kill,
capability net_bind_service,
capability setuid,
capability setgid,
network inet,
network inet6,

/dev/tty rw,
/etc/apache2/** r,
/etc/gai.conf r,
/etc/group r,
/etc/host* r,
/etc/mime.types r,
/etc/nsswitch.conf r,
/etc/passwd r,
/etc/php5/apache2/php.ini r,
/etc/php5/conf.d/ r,
/etc/php5/conf.d/*.ini r,
/etc/protocols r,
/etc/resolv.conf r,
/etc/services r,
/proc/[0-9]*/mounts r,
/proc/filesystems r,
/usr/bin/env rix,
/usr/bin/host rix,
/usr/lib/apache2/modules/** mr,
/usr/lib/php5/[0-9]*/*.so rix,
/usr/sbin/apache2 r,
/usr/share/apache2/icons/* r,
/usr/share/file/magic.mime r,
/usr/share/zoneinfo/ r,
/var/log/apache2/** rw,
/var/run/apache2.pid w,
/tmp/ rw,
/tmp/php* rw,
}

Open in new window

Cheers

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jaime BonillaSystems AdmininistratorAuthor Commented:
Thank you for the response DFKE, that gives me an idea of a basic/starting template.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.