LAMMP Web, or App Server Setup

Note: Ubuntu 14.04, and 16.04 were used, but it should work on most Debian, and RedHat/CentOs (yum install) approach, would follow very closely as well.

This is less of a blog post and more of a how-to, brought about by recent activities on AWS.  Using MSMTP in particular was a new discovery, since it allows php.ini’s sendmail_path directive to point to, and use MSMTP instead of sendmail to send mail on a LAMMP server.  This means that you don’t need to run Postfix on the server in order to relay mail.  You can simply configure an SMTP email account such as noreply@yourdomain.com, and this is the account from which all mail from your app server will be sent.

Running Postfix as a relay comes with other hoops to jump through and MSMTP alleviates all those issues for easy app server setup.  Postfix is actually installed by the mailutils, so be aware of that, and be ready to deal with installing Postfix, if you so choose.

I recommend, that once you set up this, LAMMP Server up, that you save off a snapshot, known as an AMI in AWSso you don’t have to EVER do it again.

Amazon Web Services, will give you a free “micro” instance for a year. So go check it out!  Build the app server, then host your own WordPress web site, for free, for a year.  As for email server administration, and more server hardening, and DNS setup in AWS (otherwise, known as Route 53, cause DNS discovery typically happens on port 53), well those are good topics for a later date.

However, if you have a SMTP email account, it can be used to send all emails from your web site.  This setup works with your existing SMTP email service provider, to seamlessly allow emails to be sent from any form plugins for WordPress (or other CMS).  It can also simply be done in PHP with the built-in mail function.    Additionally, the command line mail command should work too, as demonstrated at the bottom of the page.

The php sendmail_path directive in your php.ini (php.ini typically lives in /etc/phpX/apache2/php.ini , where X may or may not be a version number), should look as follows; of course, change what comes after the -C to reflect where you want the per-host config to live, but for a single host running in the default spot, this will do.  You’ll want to configure this after running the next script, to make sure the /etc/msmtprc file is properly created.

sendmail_path = /usr/bin/msmtp -C /etc/msmtprc -t

Next, copy and paste the next script to a file named setup-msmtp-for-smtp.sh, (or whatever you want) and run it.  It will prompt you through setup msmtp.  This example uses GoDaddy and mileage may vary for other SMTP hosts, you may find that you have to adjust it for your needs.  There’s no guarantees on any of this, so use and run at your own risk.  
 

  1. source
  2. source
  3. source
  4. source
  5. source
  6. source

 

Further steps to take, would be to harden it using ModSecurity for Apache, as well as a few others.  Here’s a great blog entry on hardening ubuntu server.

 

Note

  • You can also use SSMTP in place of MSMTP.

 

Doc Version 1.1
Revision History
  • 1.1 – Updated Jan. 4, 2017 – Updated to reflect new repository (ppa:ondrej/php) and PHP 5.6 instead of PHP 5. Added php-getttext php-mbstring to default php package list, to satisfy phpmyadmin’s dependencies. Now works with Ubuntu 16.04.

 

%d bloggers like this: