Support #763
Install Mailgraph on FreeBSD
Description
This is a guide on setting up Mailgraph on FreeBSD 9.
Prepare the Environment¶
- Make sure the system is up date:
pkg update && pkg upgrade
- Edit permissions of mail log so Mailgraph can read it:
chmod 0644 /var/log/maillog
Install Mailgraph¶
- Install mailgraph:
pkg install mailgraph
- Start and enable mailgraph at boot:
echo 'mailgraph_enable="YES"' >> /etc/rc.conf service mailgraph start
Install Nginx¶
- Install nginx and fcgiwrap:
pkg install nginx fcgiwrap
- Start and enable fcgiwrap at boot:
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
Mailgraph Website¶
- Create a directory for the web application:
mkdir -p /usr/local/www/mailgraph.example.com
- And copy the mailgraph files to the mailgraph web folder:
cp /usr/local/www/cgi-bin/mailgraph.cgi /usr/local/www/mailgraph.example.com/ cp -r /usr/local/www/data/mailgraph /usr/local/www/mailgraph.example.com/
- Add a mailgraph.example.com server block:
vi /usr/local/etc/nginx/conf.d/mailgraph.example.com.conf
- Add the following:
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$ { include /usr/local/etc/nginx/fastcgi_params; fastcgi_index mailgraph.cgi; fastcgi_pass fcgiwrap; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
- Add the following:
- Change the ownership of the mailgraph website to the web server user:
chown -R www:www /usr/local/www/mailgraph.example.com
- Restart nginx:
service nginx restart