HOWTO Ubuntu 16.04 LTS Magento 2 Server Setup


All of our servers will start with this install. This base server is based on CentOS 7. There have been some changes since my 6.x howtos.

Downloading the ISO

Visit the Ubuntu website and download the ubuntu 16.04 server ISO.

Initial Install

Boot the install DVD.  The install is straight forward.  I’m only going to cover items that you should select during the install.

On the package selection screen select the following:
‘Web Server LAMP’
‘Mail Server’

Click ‘Reboot’ when it appears.

First boot

Reboot the machine when the install finishes.
The OS will boot. Log in. All the commands need to be run as root so lets start a shell with root privilleges.
> sudo bash

Get everything updated and install a couple of items.
> apt-get install nano net-tools
> sudo apt-get upgrade

WARNING: My server isn’t directly connected to the internet. The firewall is disabled to help with installation, configuration and testing easier. Once everything is working, turn on the firewall and configure it. I wil remind you to secure your server at the end of this howto.

now reboot the server.

The Second Boot – Installing Additional Packages

We need quite a few other packages. A change in this howto is that I’m installing RPMs reguardless if they were already installed by another dependency. This guards against RPM changes that could cause a package to not be installed. Once again log in to your server.

Now bring everything up to date.
> sudo apt-get update

Install the following RPMs. Multiple lines to make cut and paste easier.
> sudo apt-get install make screen snmp composer libcurl3 unzip

Install some extra PHP libraries.
> sudo apt-get install libapache2-mod-fastcgi php7.0-fpm
> sudo apt-get install php7.0-gd php7.0-snmp php7.0-mbstring php7.0-mysql
> sudo apt-get install php7.0-odbc php7.0-imap
> sudo apt-get install php7.0-xmlrpc php7.0-dba php7.0-mcrypt
> sudo apt-get install php7.0-soap php7.0-zip php7.0-intl php7.0-curl

Configure Apache and PHP

Enable the rewrite module.
> sudo a2enmod rewrite

Enable mcrypt in php.
> sudo phpenmod mcrypt

Reload apache.
> sudo systemctl restart apache2.service

Installing and Configuring phpMyAdmin

I prefer to phpMyAdmin to manage my MySQL databases.

Now install phpMyAdmin.
> sudo apt-get install phpmyadmin

Restart Apache.
> sudo systemctl restart httpd

Installing Postfix

Lets install postfix.
> sudo apt-get install postfix

When prompted select internet site. Next set the mail server name.

Installing cockpit

I’m trying cockpit as my server admin tool.  Do the following to set it up.
> sudo apt-get install cockpit
> sudo systemctl start cockpit
> sudo systemctl enable cockpit.socket

You can now login to https://yourserver.tld:9090 to administer your server.

Getting root’s and other’s mail

You need to get some local system user’s mail. We’ll use postfix’s virtual file to get the emails to the right place.

Add the following to /etc/postfix/virtual

root admin@yourdomain.tld
postmaster admin@yourdomain.tld
abuse admin@yourdomain.tld

Now add the configuration option to
> sudo postconf -e “virtual_alias_maps = hash:/etc/postfix/virtual”
Just a couple commands to wrap everything up.
> sudo postmap /etc/postfix/virtual
> sudo systemctl restart postfix

Setup User for Magento

Login to cockpit https://yourserver.tld:9090
Go to the accounts section and add a user for magento.  I named my user ‘madmin’.

Login to your server with ssh and add your new user to the webserver group
> sudo adduser madmin www-data

Change owner and permissions of the web server directory
> sudo chown -R www-data:www-data /var/www/html
> sudo chmod g+w /var/www/html

Configure Apache for Magento


<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/html
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  <Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all

Restart apache.
> sudo systemctl restart apache2.service

Setup Mysql Database and User for Magento

Now we need to create the database and user for magento.  You will want to use a different username and password.  Type the following.
> mysql -u root -p
> CREATE USER magento@localhost IDENTIFIED BY ‘otnegam’;
> GRANT ALL PRIVILEGES ON magento.* TO magento@localhost IDENTIFIED BY ‘otnegam’;
> exit

Download and Install Magento

Download the latest version of magento.  The version at the time of this howto is ‘2.2.2’. I downloaded the zip version.  Then copy the download to the magento server.  Place the download in ‘/var/www/html’.

Switch to the web root directory and unzip magento.
> cd /var/www/html/
> sudo unzip magento-2.2.2

Fix file permissions owner.
> sudo chown -R www-data:www-data /var/www/html
> sudo chmod g+w -R /var/www.html

Now open your browser and visit magento on your server.  Finish the setup process using the web gui.

Final Settings

You may want to enable the linux firewall.
Set your timezone in /etc/php.ini


That’s it for the basic magento setup. See the other pages for info on configuring servers for virtual webhosting or virtual email hosting. Remember to configure the firewall on the server.

HOWTO: Change Thin LVM to Directory Storage in Proxmox 5.x


In Proxmox 5.x LVM thin is the default local storage for VMs.  However I prefer the old method of directory based storage for local storage.  You can find this information in the proxmox wiki.  These are my terse notes to get the job done.

The Conversion

This should only be done on a new installation of proxmox.  In the gui remove the local lvm thin storate.

Type the following to set everything up.
> lvremove pve/data
> lvcreate –name data -l +100%FREE pve
> mkfs.ext4 /dev/pve/data

Add the following to /etc/fstab

/dev/pve/data /var/lib/vz ext4 defaults 0 1

Restart proxmox.  Thats it.