Ubuntu server 12.04/apache2

From Attie's Wiki
Revision as of 20:34, 2 May 2012 by Attie (Talk | contribs)

Jump to: navigation, search

Contents

Configuring an Apache server

apt-get install apache2 libapache2-mod-php5
# enable modrewrite
ln -s ../mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

Configuration is in /etc/apache2

Store site content in /home/www

mkdir /home/www
chown www-data:www-data -R /home/www

Path goes with TLD first, and a few other rules. Access and Error logs are stored in the TLD's directory, with the subdomain prefixed. E.g:

Domain / Subdomain Content Access log Error Log
www.attie.co.uk /home/www/attie.co.uk/htdocs /home/www/attie.co.uk/logs/access.log /home/www/attie.co.uk/logs/error.log
wiki.attie.co.uk /home/www/attie.co.uk/wiki /home/www/attie.co.uk/logs/wiki_access.log /home/www/attie.co.uk/logs/wiki_error.log
joke.test.attie.co.uk /home/www/attie.co.uk/test/joke /home/www/attie.co.uk/logs/test_joke_access.log /home/www/attie.co.uk/test/logs/test_joke_error.log

Start/Restart

service apache2 restart

Setup sites

Add a site file in /etc/apache2/sites-available. Enable the site by symlinking it into /etc/apache2/sites-enabled.

Sample config

<VirtualHost *:80>
  ServerAdmin webmaster@attie.co.uk
  ServerName attie.co.uk
  ServerAlias www.attie.co.uk
  DocumentRoot "/home/www/attie.co.uk/htdocs"
  CustomLog "/home/www/attie.co.uk/logs/access.log" combined
  ErrorLog "/home/www/attie.co.uk/logs/error.log"
</VirtualHost>
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox