Created
April 8, 2016 18:06
-
-
Save jalogisch/3f422f40a180d97e0cc5386d111a9a08 to your computer and use it in GitHub Desktop.
install graphite with nginx and uwsgi on ubuntu 14.4 LTS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install needed packages | |
apt-get install python-pip python-dev | |
apt-get install python-twisted python-cairo | |
apt-get install fontconfig python-tz | |
apt-get install python-django python-django-tagging | |
apt-get install nginx uwsgi-plugin-python uwsgi | |
# "little helper" | |
export GRAPHITE=/opt/graphite | |
export PYTHONPATH=/opt/graphite/webapp | |
# install components | |
pip install carbon whisper graphite-web | |
pip install --upgrade twisted | |
cd /opt/graphite/conf/ | |
# Create a directory with all configurations | |
# It will allow us to keep this dir clean and use the original | |
# files as templates | |
mkdir examples; mv *.example examples | |
# create a copy of the required files | |
cp examples/storage-schemas.conf.example storage-schemas.conf | |
cp examples/storage-aggregation.conf.example storage-aggregation.conf | |
cp examples/carbon.conf.example carbon.conf | |
cp examples/graphite.wsgi.example wsgi.py | |
# WebConfiguration Create | |
cp /opt/graphite/webapp/graphite/{local_settings.py.example,local_settings.py} | |
sed -i -e "s|#TIME_ZONE = 'America/Los_Angeles'|TIME_ZONE = 'Europe/Berlin'|g" /opt/graphite/webapp/graphite/local_settings.py | |
sed -i -e "s|#SECRET_KEY = 'UNSAFE_DEFAULT\'|SECRET_KEY = \'ohg3acow8iekahThoquie4jigohmi9th\'|g" /opt/graphite/webapp/graphite/local_settings.py | |
# Allow access to www-data to the webapp and storage directories | |
chown -R www-data:www-data /opt/graphite/webapp/ /opt/graphite/storage/ | |
# create APP | |
cat <<EOT >> /etc/uwsgi/apps-available/graphite.ini | |
[uwsgi] | |
processes = 2 | |
socket = 127.0.0.1:3031 | |
gid = www-data | |
uid = www-data | |
chdir = /opt/graphite/webapp/graphite | |
pythonpath = /opt/graphite/webapp | |
env = DJANGO_SETTINGS_MODULE=graphite.settings | |
module = django.core.handlers.wsgi:WSGIHandler() | |
EOT | |
# activate app | |
ln -s /etc/uwsgi/apps-available/graphite.ini /etc/uwsgi/apps-enabled/ | |
# activate nginx | |
if [ -d /etc/nginx/conf.d ] | |
then | |
NGINXCONFIG=/etc/nginx/conf.d/graphite.conf | |
elif [ -d /etc/nginx/sites-available ] | |
then | |
NGINXCONFIG=/etc/nginx/sites-available/graphite | |
fi | |
cat <<EOT >> ${NGINXCONFIG} | |
server { | |
listen 8080; | |
charset utf-8; | |
access_log /var/log/nginx/graphite.access.log; | |
error_log /var/log/nginx/graphite.error.log; | |
location / { | |
include uwsgi_params; | |
uwsgi_pass 127.0.0.1:3031; | |
} | |
} | |
EOT | |
# create the local database for the webapp | |
python /opt/graphite/webapp/graphite/manage.py syncdb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment