Skip to content

Instantly share code, notes, and snippets.

@mmarum-sugarcrm
Created December 22, 2015 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmarum-sugarcrm/75aac698d11ed6f76190 to your computer and use it in GitHub Desktop.
Save mmarum-sugarcrm/75aac698d11ed6f76190 to your computer and use it in GitHub Desktop.
Set up Apache 2.2 for Ubuntu 12.04 for easy development by Vagrant user
#!/bin/bash
# Add phpinfo to web dir as a convenience
echo "<?php phpinfo();" > /var/www/phpinfo.php
# We will have Apache run as Vagrant user because this will help prevent permissions issues on a dev setup
sed -i "s/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=vagrant/" /etc/apache2/envvars
chown -R vagrant /var/www/
usermod -a -G www-data vagrant
# Enable some important Apache modules
a2enmod headers expires deflate rewrite
# Enable DEFLATE on application/json - this helps speed up downloads of Sugar data
cat >> /etc/apache2/mods-enabled/deflate.conf <<DELIM
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/json
</IfModule>
DELIM
# Update Apache config on web server to AllowOverride
sed -i "s/AllowOverride None/AllowOverride All/" /etc/apache2/sites-enabled/000-default
# Set up port 8080 virtualhost config to allow interactive installs of Sugar from Host system when using Vagrant
# Also make sure sugar directory has AllowOverride enabled
cat >> /etc/apache2/sites-available/sugar <<DELIM
Listen 8080
<VirtualHost *:8080>
ServerName localhost
DocumentRoot /var/www
</VirtualHost>
<Directory "/var/www/sugar">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DELIM
a2ensite sugar
# Restart apache22 when done
apachectl restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment