Skip to content
Cliff Ingham edited this page Sep 4, 2020 · 6 revisions

Apache (2.4)

Configuration

I use the Ubuntu apache conf layout, but modify the default site conf. On our servers, we host many web applications in subdirectories, so we can easily proxy them to the outside world. uReport will end up hosted at:

https://hostname/crm

Load modules

The default install does not include all the apache modules we typically use. These are the ones we activate.

sudo a2enmod alias
sudo a2enmod headers
sudo a2enmod remoteip
sudo a2enmod rewrite
sudo a2enmod ssl
sudo service apache2 restart

Create the files and directories we referred to in the configuration

We go ahead and give ownership of the web directories to Apache, and set our users up as the group. That way, the handful of us web developers can all edit the stuff in websites. (To each his own, this is just how we do it)

sudo mkdir -p /etc/apache/sites-enabled/conf.d
sudo mkdir -p /srv/sites
sudo chown -R apache:staff /srv/sites
sudo chmod -R g+rw /srv/sites

Default site setup

Here's a basic working 000-default.conf.

DocumentRoot /var/www/html
<Directory  "/var/www/html">
    Options FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

IncludeOptional sites-enabled/conf.d/*.conf

Include our websites conf file

If you have a bunch of websites to host, it helps to keep default site conf clean and put all your website entries in separate files.

Here's the ureport.conf to put into sites-enabled/conf.d

RewriteEngine On

Alias /crm/COB "/srv/data/ureport/Themes/COB/public"
<Directory "/srv/data/ureport/Themes/COB/public">
    Options FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Alias /crm/media "/srv/data/ureport/media"
<Directory       "/srv/data/ureport/media">
    Options FollowSymLinks
    AllowOverride None
    Require all granted

    RewriteBase /crm
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .? /crm/index.php [NC,L]
</Directory>

Alias /crm "/srv/sites/ureport/public"
<Directory "/srv/sites/ureport/public">
    Options FollowSymLinks
    AllowOverride None
    Require all granted

    RewriteBase /crm
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .? /crm/index.php [NC,L]

    php_value post_max_size 10M
    php_value upload_max_filesize 10M
    php_value error_reporting 32767
    php_value log_errors on
    php_value html_errors off
    php_value arg_separator.output ";"
    php_value arg_separator.input  ";&"

    SetEnv SITE_HOME /srv/data/ureport
</Directory>
Clone this wiki locally