بلوج

Install Postfix

When you are prompted to configure Postfix, push Enter.

Postfix Installation Ajenti Ubuntu Linux

Then make sure Internet Site is selected and push Enter.

Postfix Configuration Internet Site Ubuntu

For System mail name, put your server name without the subdomain and push Tab and then push Enter. For example, if your server’s name is john.example.com, put in example.com in this field.

Postfix Configuration System Mail Name

For Root and postmaster mail recipient, enter in the admin’s username. Push Tab and then push Enter.

Postfix Configuration Root and Postmaster Recipient

For Other destinations to accept mail for, ensure something like the following is entered in:

server1.example.com, example.com, localhost.example.com, localhost

Then push Tab and then push Enter.

Postfix Configuration Other Destinations to Accept Mail

For Force synchronous updates on mail queue, select No. Then push Tab and then push Enter.

Postfix Configuration Force Synchronous Updates Mail Queue

For Local networks, you may leave this blank to use the defaults or enter in 127.0.0.0/8. Then push Tab and then push Enter.

Postfix Configuration Local Networks Ubuntu

For Mailbox size limit (bytes), enter in 0, which means no limit. Then push Tab and then push Enter.

Postfix Configuration Mailbox Size Limit Bytes

For Local address extension character, put in a plus sign: +. Then push Tab and then push Enter.

Postfix Configuration Local Address Extension Character

For Internet protocols to use, select all. Then push Tab and then push Enter.

Postfix Configuration Internet Protocols to Use All

Postfix Configuration Finished Setup

You might see a warning like the following:

WARNING: /etc/aliases exists, but does not have a root alias

If so, type in the following:

postconf -e 'home_mailbox = Maildir/'

Then type this:

postconf -e 'mailbox_command ='

Now, we will configure Postfix to do SMTP AUTH using SASL (saslauthd). To do so, type in the following:

postconf -e 'smtpd_sasl_local_domain =' && postconf -e 'smtpd_sasl_auth_enable = yes' && postconf -e 'smtpd_sasl_security_options = noanonymous' && postconf -e 'broken_sasl_auth_clients = yes' && postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination' && postconf -e 'inet_interfaces = all'

Now, we will add two lines to /etc/postfix/sasl/smtpd.conf by typing in the following:

echo -e "pwcheck_method: saslauthd\nmech_list: plain login" >> /etc/postfix/sasl/smtpd.conf

Now, we will generate certificates to be used for TLS encryption and/or certificate Authentication by typing in the following set of commands, one at a time:

touch smtpd.key
chmod 600 smtpd.key
openssl genrsa 1024 > smtpd.key
openssl req -new -key smtpd.key -x509 -days 3650 -out smtpd.crt

When asked for a Country Name, put in the two-letter code for your country (e.g. US). For State or Province Name, enter in your state (e.g. DC). For Locality Name, enter in your city (e.g. Washington). For Organization Name, enter the name of your organization. For Organizational Unit Name, enter in anything. For the Common Name, enter in the domain name you want associated with your server (or your IP address if you don’t have a domain name). For Email Address, enter in the administrator’s email address.

Now type in the following:

openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

When asked for a PEM pass phrase, enter in a secure password. Then re-enter it when prompted. When asked for a Country Name, put in the two-letter code for your country (e.g. US). For State or Province Name, enter in your state (e.g. DC). For Locality Name, enter in your city (e.g. Washington). For Organization Name, enter the name of your organization. For Organizational Unit Name, enter in anything. For the Common Name, enter in the domain name you want associated with your server (or your IP address if you don’t have a domain name). For Email Address, enter in the administrator’s email address.

Now, enter in the following set of commands:

mv smtpd.key /etc/ssl/private/ && mv smtpd.crt /etc/ssl/certs/ && mv cakey.pem /etc/ssl/private/ && mv cacert.pem /etc/ssl/certs/

Next, enter in the following set of commands to configure Postfix to do TLS encryption for both incoming and outgoing mail:

postconf -e 'smtp_tls_security_level = may' && postconf -e 'smtpd_tls_security_level = may' && postconf -e 'smtpd_tls_auth_only = no' && postconf -e 'smtp_tls_note_starttls_offer = yes' && postconf -e 'smtpd_tls_key_file = /etc/ssl/private/smtpd.key' && postconf -e 'smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt' && postconf -e 'smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem' && postconf -e 'smtpd_tls_loglevel = 1' && postconf -e 'smtpd_tls_received_header = yes' && postconf -e 'smtpd_tls_session_cache_timeout = 3600s' && postconf -e 'tls_random_source = dev:/dev/urandom' && postconf -e 'myhostname = server1.example.com'

In case you accidentally exit the Postfix configuration too early or do not see the Postfix configuration menu, simply type in the following to re-configure Postfix:

dpkg-reconfigure postfix

Best VPS Server Backup Strategy Tutorial

This backup method will back up your local VPS databases, files, and configuration settings to another (remote) server of yours. It will also back up your remote server’s files to your local VPS.

Step 1: Install Zip

We must first make sure the zip package is installed. To do so, type in the following via SSH:

dpkg -l zip

If you get something like dpkg-query: no packages found matching zip, then you do not have the zip package installed. However, if you get something that lists the name and version number of the zip package, this means you have the zip package installed.

If you do not have the zip package installed, type the following to install it:

apt-get install zip

When prompted whether or not you want to continue, type Y and then hit Enter.

Step 2: Generate SSH Keys

On your local server, via SSH, type in the following to generate SSH Keys:

ssh-keygen -t rsa -b 4096

When asked to “Enter file in which to save the key”, hit Enter.

When asked to “Enter passphrase (empty for no passphrase)”, hit Enter.

When asked to “Enter same passphrase again”, hit Enter.

Now, type in the following to copy the public key to the remote server using ssh-copy-id:

ssh-copy-id -i ~/.ssh/id_rsa.pub root@123.123.123.123

When asked “Are you sure you want to continue connecting”, type yes and hit Enter.

When prompted for the password of your remote server, type it in and hit Enter.

Now, test to make sure the SSH keys were properly added by trying to log in to the remote server by typing in the following:

ssh root@123.123.123.123

You should be granted access to your remote server without being prompted for a password.

Repeat these same steps on your remote server if you also want to back up your remote server to your local server.

Log on to your other server. Via SSH, type in the following to generate SSH Keys:

ssh-keygen -t rsa -b 4096

When asked to “Enter file in which to save the key”, hit Enter.

When asked to “Enter passphrase (empty for no passphrase)”, hit Enter.

When asked to “Enter same passphrase again”, hit Enter.

Now, type in the following to copy the public key to your other server using ssh-copy-id:

ssh-copy-id -i ~/.ssh/id_rsa.pub root@321.321.321.321

When asked “Are you sure you want to continue connecting”, type yes and hit Enter.

When prompted for the password of your remote server, type it in and hit Enter.

Now, test to make sure the SSH keys were properly added by trying to log in to the remote server by typing in the following:

ssh root@321.321.321.321

You should be granted access to your remote server without being prompted for a password.

Step 3: Create Backup Directory

We must first create a directory which will store the backups. On each of your servers, type in the following to create the directory which will store the backups:

mkdir /var/backups

Step 4: Create Configuration File for MySQL Database Dumps without using Password

On each of your servers, type in the following to create a new file (with restricted permissions) which will allow us to back up all databases without having to enter in a password each time. Substitute yourpassword with the actual password for your root MySQL user.

echo -e '[mysqldump]\npassword=yourpassword' > /etc/custom/.my.cnf && chmod 0440 /etc/custom/.my.cnf

Step 5: Back Up

On each of your servers you’d like to back up, type in the following to create a backup script:

echo "mysqldump --defaults-file=/etc/custom/.my.cnf --user='root' --all-databases --events --ignore-table=mysql.event > /var/backups/databases.sql && crontab -l > /var/backups/crontab && zip -r /var/backups/firstserver.zip /etc/hosts /etc/hostname /etc/apt/sources.list /etc/ajenti /etc/custom /etc/nginx /etc/nginx.custom.d /etc/ssl/private/pure-ftpd.pem /etc/pure-ftpd/conf/TLS /etc/fail2ban/jail.local /etc/network/if-pre-up.d/firewall /etc/sysctl.conf /etc/sudoers.d/my_sudoers /etc/rc.local /etc/mysql/my.cnf /etc/php5/fpm/php.ini /var/www /var/backups/databases.sql /var/backups/crontab && rm /var/backups/databases.sql && rm /var/backups/crontab && chmod 0440 /var/backups/firstserver.zip && rsync -avz --delete /var/backups/firstserver.zip root@123.123.123.123:/var/backups/firstserver.zip" > backup.sh

Type the following to apply proper permissions to the backup script file we just created:

chmod 0750 /etc/custom/backup.sh

Now, type in the following to run the backup script:

/etc/custom/backup.sh

Step 6: Enable Automatic Backups

To enable automatic backups every day, we must add our newly created backup script to the crontab. To do so, type in the following:

cat <(crontab -l) <(echo "@daily /etc/custom/backup.sh") | crontab -

Fix phpList Error: IMAP is not included in your PHP Installation

It is hard to find a newsletter and email marketing software as nice as phpList. If you have installed this wonderful software on your own VPS/Dedicated server, and are getting the phpList error, Error: IMAP is not included in your PHP Installation, continue reading to learn how to easily fix this error.

phpList Process Bounces Error IMAP PHP not Installed

This error means you do not have the IMAP PHP extension installed. To install it, simply SSH into your server and type in the following:

apt-get install php5-imap

When asked if you want to continue, type Y and hit Enter.

Then, type in the following:

php5enmod imap

Now, restart your PHP processor by typing in the following:

service php5-fpm restart

Finally, restart your Nginx web server by typing in the following:

service nginx restart

If you are using an Apache web server, restart it by typing this instead:

service apache2 restart

Import MySQL Database File via Command Line Ubuntu Linux

Importing a MySQL database from the terminal in Linux is very easy. All it takes is one simple line:

mysql -u username -p database_name < myDatabase.sql

Make sure you enter in your MySQL username in place of username. In place of database_name, enter in the name of the database you are importing in to. After you enter this line of code via SSH, you will be prompted for the password of the MySQL user. Go ahead and enter in the password, and your database should get imported.

Create Email Address Mailbox on Ajenti V in Nginx & Ubuntu

Creating an email address / mailbox in Ajenti V is dead simple. There are only two quick steps for this tutorial. See below how to create an email address / mailbox in Ajenti V.

Step 1: Configure & Create Email Address Mailbox

After logging in to Ajenti V using your browser, click on the Mail tab to the left. Beneath where it says NEW MAILBOX, for Address, enter in the part of the email address before the @ sign that you’d like to create an email address mailbox on (e.g. example). If you have already added domain names to Ajenti V, you may choose the domain name you would like to do create an email mailbox for; otherwise, choose Custom Domain. In the Custom domain field, enter in the domain name of the email address mailbox you’d like to configure. For this example, I am using domain.com as my custom domain. Click the + MAILBOX button.

Ajenti V Create Email Address Mailbox

Step 2: Enter in Password for Email Address Mailbox

Click on the email address you just created. To the right of Password, click Change password. Enter in a strong password. Scroll down and click APPLY CHANGES.

Ajenti V Create Email Address Mailbox Password Change

Troubleshooting

Not Receiving Email

If you are not receiving the email of your newly configured email address mailbox, ensure you have opened up TCP ports 143 and 993 and that these ports are not blocked.

If these two ports are open, ensure you have added the domain name you have configured the email address mailbox for to your Ajenti websites.

If you have added the above domain name you’d like to configure the email address mailbox for, ensure your DNS settings at your domain name’s registrar are correctly pointed at your Ajenti V VPS / Dedicated server’s IP address.

Make sure your installation hasn’t been configured to use non-default ports. To check the ports used by exim, type in the following via SSH:

lsof -i -P | grep exim

Make sure your firewall is not blocking any of these ports.

Try debugging further by checking the delivery path by typing in the following:

exim -bt example@domain.com

If you have made sure of all the above points, try rebooting your server to see if that fixes it and allows you to receive email at your email address mailbox.

Create Forwarding Email Address on Ajenti V in Nginx & Ubuntu

It is very easy to create a forwarding email address in Ajenti V. There are two easy steps. Continue on to see how to create and configure a forwarding email address in Ajenti V.

Step 1: Configure & Create Forwarding Email Settings

After logging in to Ajenti V using your browser, click on the Mail tab to the left. Beneath where it says NEW MAILBOX, for Address, enter in the part of the email address before the @ sign that you’d like to enable email forwarding on (e.g. example). If you have already added domain names to Ajenti V, you may choose the domain name you would like to do email forwarding on; otherwise, choose Custom Domain. In the Custom domain field, enter in the domain name of the forwarding email address you’d like to configure. For this example, I am using domain.com as my custom domain. Click the + FORWARDING button.

Ajenti V Create Forwarding Email Address Custom Domain

Step 2: Enter in Target Email Address You Want to Forward Email to

Click on the forwarding email address you just created. Beneath Target address, click + ADD. Instead of someone@example.com, put in your actual email address that you would like to forward your forwarding email to. Scroll down and click APPLY CHANGES. In this example, I am forwarding all mail that comes in for example@domain.com to example@gmail.com.

Ajenti V Forwarding Email Address Target

Troubleshooting

Not Receiving Forwarding Email

If you are not receiving the email of your newly configured forwarding email address, ensure you have opened up TCP ports 143 and 993 and that these ports are not blocked.

If these two ports are open, ensure you have added the domain name you have configured the forwarding email address for to your Ajenti websites.

If you have added the above domain name you’d like to configure the forwarding email address for, ensure your DNS settings at your domain name’s registrar are correctly pointed at your Ajenti V VPS / Dedicated server’s IP address.

Ensure you have correctly entered in your target email address.

Make sure your installation hasn’t been configured to use non-default ports. To check the ports used by exim, type in the following via SSH:

lsof -i -P | grep exim

Make sure your firewall is not blocking any of these ports.

Try debugging further by checking the delivery path by typing in the following:

exim -bt example@domain.com

If you have made sure of all the above points, try rebooting your server to see if that fixes it and allows you to receive the forwarding email at your target address.

Create Catch-All Email Address on Ajenti V Nginx Ubuntu Linux

Creating a catch-all email address in Ajenti V is very easy. All it takes is two simple steps. Simply scroll down to see how to create and configure a catch-all email address in Ajenti V.

Step 1: Configure & Create Catch-All Email Settings

After logging in to Ajenti V using your browser, click on the Mail tab to the left. Beneath where it says NEW MAILBOX, for Address, enter only an asterisk–*. If you have already added domain names to Ajenti V, you may choose the domain name you would like to do forwarding on; otherwise, choose Custom Domain. In the Custom domain field, enter in the domain name of the catch-all email address you’d like to configure. For this example, I am using domain.com as my custom domain. Click the + FORWARDING button.

Ajenti V Create Catch-All Forwarding Email Address

If you would like to create a catch-all email account for all of your domains, enter in only an asterisk, *, for the Address, just as we have done above. Select Custom domain, and for the Custom domain field, enter in only two quotation marks–“”. Click the + Forwarding button.

Ajenti V Create Catch-All Mail Forwarding Email Address

Step 2: Enter in Target Email Address You Want to Forward Email to

Click on the catch-all email address you just created. Beneath Target address, click + ADD. Instead of someone@example.com, put in your actual email address that you would like to forward your catch-all email to. Scroll down and click APPLY CHANGES. In this example, I am forwarding all mail that comes in for any recipient @domain.com to example@gmail.com.

Ajenti V Catch-All Forwarding Email Target Address

Below is how it looks when you create a catch-all email account that forwards email for all of your domains to your designated target address.

Ajenti V Catch-All Mail Forwarding Target Email Address

Troubleshooting

Not Receiving Catch-All Email

If you are not receiving the email of your newly configured catch-all email address, ensure you have opened up TCP ports 143 and 993 and that these ports are not blocked.

If these two ports are open, ensure you have added the domain name you have configured the catch-all email address for to your Ajenti websites.

If you have added the above domain name you’d like to configure the catch-all email address for, ensure your DNS settings at your domain name’s registrar are correctly pointed at your Ajenti V VPS / Dedicated server’s IP address.

Ensure you have correctly entered in your target email address.

Make sure your installation hasn’t been configured to use non-default ports. To check the ports used by exim, type in the following via SSH:

lsof -i -P | grep exim

Make sure your firewall is not blocking any of these ports.

Try debugging further by checking the delivery path by typing in the following:

exim -bt example@domain.com

If you have made sure of all the above points, try rebooting your server to see if that fixes it and allows you to receive the catch-all email at your target address.

Update Ubuntu Linux from SSH / Terminal / Command Line

Updating Ubuntu Linux via command line is very easy. It only takes two steps.

Step 1: apt-get update

Via SSH, type in the following to make sure your VPS / Dedicated server has the latest packages:

apt-get update

Step 2: apt-get upgrade

Now type in the following to upgrade:

apt-get upgrade

If you are prompted whether or not you want to continue, simply type in Y and then hit Enter.

Troubleshooting

If the above steps do not work, make sure you are a sudo user or logged in as root. Try typing in the same commands as above except with sudo in front of each command (e.g. sudo apt-get update / sudo apt-get upgrade).