Drupal + Postfix Integration Under Ubuntu 8.04 (Hardy) - Page 3

Want to support HowtoForge? Become a subscriber!
 
Submitted by asaavedra (Contact Author) (Forums) on Tue, 2008-10-07 15:46. ::

Apache Configuration

/etc/hosts should have the following line:

127.0.0.1 localhost  myserver.example.com

The web server configuration is mainly a matter of taste. In this tutorial we explain how to setup a Drupal multi-hosted site. The domain example.com will have the application files under /var/www/example.com, a SSL application root under /var/ssl/example.com and the Drupal uploaded files will be stored in private mode under /var/files/example.com. The latter directory will be created when we unpack and install Drupal. This is the reason why the following commands will not create this directory right now.

Create the http folders under /var/www and https folders under /var/ssl:

mkdir /var/www/html
mv /var/www/index.html /var/www/html/
mkdir -p /var/ssl/example.com

The /var/www/html folder will contain default web configuration. For example, if you access to the host using IP address, Apache will serve files contained in this directory.

The /var/ssl folder will contain sites for SSL connections.

At the bottom of /etc/apache2/apache2.conf include the following lines:

NameVirtualHost *:80
NameVirtualHost *:443
ServerName myserver.example.com

The default configuration file /etc/apache2/sites-available/default:

vim /etc/apache2/sites-available/default

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/html/
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /var/www/html/>
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
  </Directory>
  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>
  ErrorLog /var/log/apache2/error.log
  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn
  CustomLog /var/log/apache2/access.log combined
  ServerSignature On
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

The example.com configuration file /etc/apache2/sites-available/example.com:

vim /etc/apache2/sites-available/example.com

<VirtualHost *:80>
  ServerAdmin admin@example.com
  ServerName example.com
  ServerAlias www.example.com
  DirectoryIndex index.php
  DocumentRoot /var/www/example.com/
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /var/www/example.com/>
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
  </Directory>
  ScriptAlias /cgi-bin/ /var/www/example.com/cgi-bin/
  <Directory "/var/www/example.com/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>
  ErrorLog /var/log/apache2/example.com.error.log
  CustomLog /var/log/apache2/example.com.access.log combined
  LogLevel warn
  ServerSignature On
</VirtualHost>
<VirtualHost *:443>
  ServerAdmin admin@example.com
  ServerName example.com
  ServerAlias www.example.com
  DirectoryIndex index.html
  DocumentRoot /var/ssl/example.com/
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /var/ssl/example.com/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
  </Directory>
  ScriptAlias /cgi-bin/ /var/ssl/example.com/cgi-bin/
  <Directory "/var/ssl/example.com/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>
  ErrorLog /var/log/apache2/ssl.example.com.error.log
  CustomLog /var/log/apache2/ssl.example.com.access.log combined
  LogLevel warn
  ServerSignature On
</VirtualHost>

Now we enable both sites and apply the configuration:

cd /etc/apache2/sites-enabled/
ln –s ../sites-available/default 000-default
ln –s ../sites-available/example.com 001-example.com
/etc/init.d/apache2 restart


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.