Support #763
Updated by Daniel Curtis almost 9 years ago
This is a guide on setting up Mailgraph on FreeBSD 9. h2. Prepare the Environment * Make sure the system is up date: <pre> pkg update && pkg upgrade </pre> * Edit permissions of mail log so Mailgraph can read it: <pre> chmod 0644 /var/log/maillog </pre> h2. Install Mailgraph * Install mailgraph: <pre> pkg install mailgraph </pre> * Start and enable mailgraph at boot: <pre> echo 'mailgraph_enable="YES"' 'mailgraph_enable' >> /etc/rc.conf service mailgraph start </pre> h2. Install Nginx * Install nginx and fcgiwrap: <pre> pkg install nginx fcgiwrap </pre> * Start and enable uwsgi at boot: <pre> echo 'fcgiwrap_enable="YES"' >> /etc/rc.conf echo 'fcgiwrap_profiles="main"' >> /etc/rc.conf echo 'fcgiwrap_main_socket="unix:/tmp/fcgiwrap.sock"' >> /etc/rc.conf echo 'fcgiwrap_main_user="www"' >> /etc/rc.conf service fcgiwrap start </pre> h2. Mailgraph CGI Website * Create a directory for the web application: <pre> mkdir -p /usr/local/www/mailgraph.example.com </pre> * And copy the mailgraph files to the mailgraph web folder: <pre> cp -Rp /usr/local/www/cgi-bin/mailgraph.cgi /usr/local/www/mailgraph.example.com/ /usr/local/www/mailgraph.example.com/cgi-bin/ cp -r -Rp /usr/local/www/data/mailgraph /usr/local/www/mailgraph.example.com/ </pre> * Add a *mailgraph.example.com server block*: <pre> vi /usr/local/etc/nginx/conf.d/mailgraph.example.com.conf </pre> #* Add the following: <pre> upstream fcgiwrap { server unix:/tmp/fcgiwrap.sock; } server { listen 80; server_name cgi-app.example.com; root /usr/local/www/mailgraph.example.com; access_log /var/log/mailgraph.example.com-access.log; error_log /var/log/mailgraph.example.com-error.log; location / { index mailgraph.cgi; try_files $uri $uri/ =404; } location ~ \.cgi$ /cgi-bin/ { try_files $uri @fcgi; } location @fcgi { include /usr/local/etc/nginx/fastcgi_params; fastcgi_index mailgraph.cgi; fastcgi_pass fcgiwrap; unix:/tmp/fcgiwrap.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } </pre> * Change the ownership of the mailgraph website to the web server user: <pre> chown -R www:www /usr/local/www/mailgraph.example.com </pre> * Restart nginx: <pre> service nginx restart </pre> h2. Resources * https://github.com/schweikert/mailgraph * https://blog.srvbox.com/mailgraph-statistics-for-postfix-running-on-nginx/ * http://www.purplehat.org/?page_id=19