Ubuntu server 12.04/apache2
From Attie's Wiki
(Difference between revisions)
m |
m |
||
Line 16: | Line 16: | ||
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: | 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 !! !! | + | ! Domain / Subdomain !! !! Root Dir |
|- | |- | ||
− | |align="right"| <code>www.attie.co.uk</code> || → || <code>/home/www/attie.co.uk | + | |align="right"| <code>www.attie.co.uk</code> || → || <code>/home/www/attie.co.uk/www</code> |
|- | |- | ||
− | |align="right"| <code>wiki.attie.co.uk</code> || → || <code>/home/www/attie.co.uk/wiki | + | |align="right"| <code>wiki.attie.co.uk</code> || → || <code>/home/www/attie.co.uk/wiki</code> |
|- | |- | ||
− | |align="right"| <code>joke.test.attie.co.uk</code> || → || <code>/home/www/attie.co.uk/test/joke</code> | | + | |align="right"| <code>joke.test.attie.co.uk</code> || → || <code>/home/www/attie.co.uk/test/joke</code> |
+ | |} | ||
+ | |||
+ | As the default configuration will deny access to <code>.ht*</code>, we can use <code>.htinfo</code> to store the configuration and logs. | ||
+ | {| | ||
+ | | Content || <code>${ROOTDIR}/</code> | ||
+ | |- | ||
+ | | Config || <code>${ROOTDIR}/.htinfo/config</code> | ||
+ | |- | ||
+ | | Access Log || <code>${ROOTDIR}/.htinfo/access.log</code> | ||
+ | |- | ||
+ | | Error Log || <code>${ROOTDIR}/.htinfo/error.log</code> | ||
|} | |} | ||
Line 40: | Line 51: | ||
ServerName attie.co.uk | ServerName attie.co.uk | ||
ServerAlias www.attie.co.uk | ServerAlias www.attie.co.uk | ||
− | DocumentRoot "/home/www/attie.co.uk/ | + | DocumentRoot "/home/www/attie.co.uk/www" |
− | CustomLog "/home/www/attie.co.uk/ | + | CustomLog "/home/www/attie.co.uk/www/.htinfo/access.log" combined |
− | ErrorLog "/home/www/attie.co.uk/ | + | ErrorLog "/home/www/attie.co.uk/www/.htinfo/error.log" |
</VirtualHost> | </VirtualHost> | ||
</source> | </source> |
Revision as of 20:43, 2 May 2012
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 | Root Dir | |
---|---|---|
www.attie.co.uk |
→ | /home/www/attie.co.uk/www
|
wiki.attie.co.uk |
→ | /home/www/attie.co.uk/wiki
|
joke.test.attie.co.uk |
→ | /home/www/attie.co.uk/test/joke
|
As the default configuration will deny access to .ht*
, we can use .htinfo
to store the configuration and logs.
Content | ${ROOTDIR}/
|
Config | ${ROOTDIR}/.htinfo/config
|
Access Log | ${ROOTDIR}/.htinfo/access.log
|
Error Log | ${ROOTDIR}/.htinfo/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/www" CustomLog "/home/www/attie.co.uk/www/.htinfo/access.log" combined ErrorLog "/home/www/attie.co.uk/www/.htinfo/error.log" </VirtualHost>