First zip up the contents of mailwizz/latest into a directory named 'mailwizz'. Unless you are running this manually and using the below script as instructions (which I recommend you do), you will want to save the code as a bash script (install.sh) and run on the server you wish to prepare. Move mailwizz.zip into the /tmp directory on your server - I use sFTP with Transmit because I am on mac, but if you're on Windows you can use putty or whatever - or optionally you can throw mailwizz.zip into your dropbox, copy the share/download URL and curl or wget the archive. If you're using the this as an actual install script with bash, you will want to run `chmod a+x install.sh`. Also, because I am terrible - you will want to switch to root before running this script (I know, I know, "one should never work in root" - what the f*** ever:rolleyes:) you may do so by running `sudo su -` and entering your root password if prompted. Alternatively - you may prepend `sudo ` to each command that requires such within the script, but I cannot guarantee stuff will work. This guide/script is intended to be ran as root, it is what it is.
Anyway, enjoy guys! Glad to make any corrections as needed.
Code Is Here
#!/bin/bash -x
foo=bar
: '
I was unable find any good tutorials for this specific stack that is Mailwizz
specific, so here is an attempt at sharing my journey
of installing mailwizz on a clean Ubuntu Xenial (16.04 LTS) server.
This installs nginx, php7-fpm and mariadb with the bare minimal
configurations to get started. I tried to comment this for readability but in format
of bash script so if you are lazy - it will do the work for you ;)
Big thanks to twisted1919 for being so involved in his project and not charging
outrageous prices.
'
echo "Init..."
echo "Please enter your main domain to use for Mailwizz install (e.g., domain.com): "
read maindomain
# update and upgrade os
apt update -y && apt upgrade -y
# If you're running these commands manually:
# it wouldn't hurt to run `reboot` on the server because of possible kernel updates.
# Install helpers
apt install unzip zip curl vim openssl -y
# Install nginx, answer prompts at SSL key creation
pkill apache2
apt install nginx -y
mkdir -p /etc/nginx/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
chown -R www-data:www-data /var/www/html/
chown -R www-data:www-data /var/www/html/*
systemctl enable nginx.service
systemctl start nginx.service
openssl s_client -connect localhost:443 -nextprotoneg ''
mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.backup
cat > /etc/nginx/sites-available/default << EOF
server {
listen 443 ssl http2 default_server;
root /var/www/html;
index index.html index.php;
server_name $maindomain;
location / {
if (!-e \$request_filename){
rewrite ^(/)?api/.*$ /api/index.php;
}
if (!-e \$request_filename){
rewrite ^(/)?customer/.*$ /customer/index.php;
}
if (!-e \$request_filename){
rewrite ^(/)?backend/.*$ /backend/index.php;
}
if (!-e \$request_filename){
rewrite ^(.*)$ /index.php;
}
try_files \$uri \$uri-404 /index.html index.php;
}
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 180m;
resolver 8.8.8.8 8.8.4.4;
add_header Strict-Transport-Security "max-age=31536000;
#includeSubDomains" always;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
server_name $maindomain;
return 301 https://\$server_name\$request_uri;
}
EOF
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
# Install php7-fpm
apt install php7.0 php7.0-fpm -y
apt install php7.0-mysql php7.0-curl php-pear php7.0-imap php7.0-mcrypt php-memcache php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext php7.0-mcrypt php7.0-zip -y
systemctl enable php7.0-fpm.service
systemctl start php7.0-fpm.service
systemctl reload nginx.service
# Create php info file for testing/troubleshooting - uncomment below if you need.
# echo "<?php phpinfo(); ?>" |tee /var/www/html/info.php
# Install mariadb
apt install mariadb-server mariadb-client php7.0-mysql -y
systemctl restart php7.0-fpm.service
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php-fpm.conf
# Secure the database, follow prompts
mysql_secure_installation
systemctl reload php7.0-fpm.service
# This will move mailwizz into root dir /var/www/html/* (if you need within a subdirectory some changes will need to be made)
cd /tmp
unzip mailwizz.zip
mv /tmp/mailwizz/* /var/www/html
# Set cron jobs as per Mailwizz instructions
crontab -l > mwcron
echo "* * * * * /usr/bin/php -q /var/www/html/apps/console/console.php send-campaigns >/dev/null 2>&1" >> mwcron
echo "*/2 * * * * /usr/bin/php -q /var/www/html/apps/console/console.php send-transactional-emails >/dev/null 2>&1" >> mwcron
echo "*/10 * * * * /usr/bin/php -q /var/www/html/apps/console/console.php bounce-handler >/dev/null 2>&1" >> mwcron
echo "*/20 * * * * /usr/bin/php -q /var/www/html/apps/console/console.php feedback-loop-handler >/dev/null 2>&1" >> mwcron
echo "*/3 * * * * /usr/bin/php -q /var/www/html/apps/console/console.php process-delivery-and-bounce-log >/dev/null 2>&1" >> mwcron
echo "0 * * * * /usr/bin/php -q /var/www/html/apps/console/console.php hourly >/dev/null 2>&1" >> mwcron
echo "0 0 * * * /usr/bin/php -q /var/www/html/apps/console/console.php daily >/dev/null 2>&1" >> mwcron
crontab mwcron
rm mwcron
# Go to your domain /install/index.php and run the install, then delete the /install/ directory.
Comments
Post a Comment