Thursday, June 4, 2015

Install SSL LAMP stack on Azure Ubuntu 14.04 LTS

Thursday, June 04, 2015 Posted by Andre Broers No comments
sudo apt-get update
sudo apt-get install lamp-server^


sudo a2enmod ssl
sudo service apache2 restart
sudo mkdir /etc/apache2/ssl

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

And fill in all the fields.

sudo vi /etc/apache2/sites-available/default-ssl.conf

alter these lines:
        <VirtualHost _default_:443>
                ServerAdmin admin@example.com
                ServerName mylamp.example.com
                ServerAlias mylamp.example.com
...
                #   SSLCertificateFile directive is needed.
                SSLCertificateFile      /etc/apache2/ssl/apache.crt
                SSLCertificateKeyFile /etc/apache2/ssl/apache.key
...

sudo a2ensite default-ssl.conf

sudo service apache2 restart

browse to the new https endpoint and the ubuntu example page will show up.


Wednesday, June 3, 2015

Install ASP vNext on Azure Ubuntu 14.04 LTS Mono

Wednesday, June 03, 2015 Posted by Andre Broers , , , No comments
I start with a S0 Azure Ubuntu 14.04 LTS virtual machine.
Install swap space in this new virtual machine as I explain here.

Install mono as is explained here.


sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list

sudo apt-get update

sudo apt-get install mono-complete

Now the complete version of mono is installed. This is still needed to run ASP vNext applications on Linux.

Install libuv which is necessary for the webserver used by Mono ASP vNext.

sudo apt-get install make automake libtool git unzip
cd /usr/local/src
sudo git clone https://github.com/libuv/libuv.git
cd libuv
sudo sh autogen.sh
sudo ./configure
sudo make
sudo make install
sudo rm -rf /usr/local/src/libuv && cd ~/
sudo ldconfig


curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh

dnvm upgrade

dnvm list

Active Version              Runtime Arch Location             Alias
------ -------              ------- ---- --------             -----
  *    1.0.0-beta4          mono         ~/.dnx/runtimes      default

Now we are ready to run the examples from ASP vNext on linux.

We can also install the unstable version:

dnvm upgrade -u

dnvm list

Active Version              Runtime Arch Location             Alias
------ -------              ------- ---- --------             -----
  *    1.0.0-beta6-11944    mono         ~/.dnx/runtimes      default
       1.0.0-beta4          mono         ~/.dnx/runtimes      

And we can switch back and forth between the installations:

dnvm use 1.0.0-beta4
Adding /home/azureuser/.dnx/runtimes/dnx-mono.1.0.0-beta4/bin to process PATH
dnvm list

Active Version              Runtime Arch Location             Alias
------ -------              ------- ---- --------             -----
       1.0.0-beta6-11944    mono         ~/.dnx/runtimes      default
  *    1.0.0-beta4          mono         ~/.dnx/runtimes      

And back using the alias:

dnvm use default
Adding /home/azureuser/.dnx/runtimes/dnx-mono.1.0.0-beta6-11944/bin to process PATH
dnvm list

Active Version              Runtime Arch Location             Alias
------ -------              ------- ---- --------             -----
  *    1.0.0-beta6-11944    mono         ~/.dnx/runtimes      default
       1.0.0-beta4          mono         ~/.dnx/runtimes      


Saturday, October 18, 2014

OSX Yosemite Automount NAS Share

Saturday, October 18, 2014 Posted by Andre Broers 3 comments
On my fresh installed Yosemite on my Macbook Air I want a mounted folder in my homedir when I am at home near my NAS. When I'm not at home it must not bother me with the none existing share. And when I'm back home it must silently reconnect.

This can be done by using autofs.

edit the file /etc/auto_master

## Automounter master map
#
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/Users/broersa/Documents/Shares auto_resources
/- -static 


The line starting with /Users is added. This will automount on the path selected. It will pick the resources from auto_resource. This is a new file we have to create:

all -fstype=smbfs ://username:password@192.168.2.254/all 

This will automount the share all on the path /Users/broersa/Documents/Shares/all

do a "chmod 600 auto_resource" to protect the username password from other users then root.

reload the config.

automount -vc

Don't forget to do everything as sudo.

Now you have your share always available when in range.

OSX Yosemite Calibre with books on NAS

Saturday, October 18, 2014 Posted by Andre Broers No comments
I want my book library on the NAS and the database on my local disk.

First start calibre and make a regular library on the NAS. (see my other post on how to mount an autofs (auto mounted) shared folder in your OS X home directory).

Now close calibre.

Set the environment variable CALIBRE_OVERRIDE_DATABASE_PATH.

To do this on Yosemite create an applescript script with the following content:

do shell script "launchctl setenv CALIBRE_OVERRIDE_DATABASE_PATH /Users/broersa/Documents/calibre/metadata.db"

change the path to your own local path. Don't forget to add metadata.db

and save this as an application.

Now go to System Preferences - Users & Groups and click on the tab Login Items. Click on the + and add the saved application as a login item.

Now move the file metadata.db from the library path on the NAS to your local directory.

Now log off and log in again to OS X. This will set the environment setting.

Start calibre and it will use the (faster) local database with the book library on the NAS,



Thursday, October 16, 2014

Create Mysql database and user for PHP applications

Thursday, October 16, 2014 Posted by Andre Broers 7 comments
I always struggle with the syntax to create a new mysql database and user for a php installation.

Hereby a quick reminder.


azureuser@myhost:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 157
Server version: 5.5.40-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database prestashop;
Query OK, 1 row affected (0.00 sec)

mysql> create user 'prestashopuser'@'localhost' identified by 'xxxxxxxxx';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on prestashop.* to 'prestashopuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
azureuser@myhost:~$ mysql -u prestashopuser -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 158
Server version: 5.5.40-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| prestashop         |
+--------------------+
2 rows in set (0.00 sec)

mysql>




Tuesday, September 9, 2014

Mono Trusted Root Certificates missing

Tuesday, September 09, 2014 Posted by Andre Broers 2 comments
When you receive the following exception in mono it means mono wants to make a secure SSL connection but the certificate it gets is not trusted. Most of the time this means the root certificates are not installed in the mono environment.

System.Net.WebException: Error: SendFailure (Error writing headers) ---> System.Net.WebException: Error writing headers ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a

Use the following command to import the current root certificates. (I find it useful to do this only for the current user so that is what the command imports)

 $ mozroots --import --ask-remove

Tuesday, August 19, 2014

Add swap space to Azure Ubuntu IaaS VM

Tuesday, August 19, 2014 Posted by Andre Broers , , , No comments
By default Azure doesn't add swap space to it's Linux Virtual Machines. I don't know why but luckily it's easy to turn it on.

Follow these steps to enable swap:

edit the file /etc/waagent.conf

Toggle the option ResourceDisk.Format from 'n' to 'y'
Toggle the option ResourceDisk.EnableSwap from 'n' to 'y'
Add the swapspace size to the option ResourceDisk.SwapSizeMB. In my case 1000 for 1000MB.


# Format if unformatted. If 'n', resource disk will not be mounted.
ResourceDisk.Format=y

# File system on the resource disk
# Typically ext3 or ext4. FreeBSD images should use 'ufs2' here.
ResourceDisk.Filesystem=ext4

# Mount point for the resource disk
ResourceDisk.MountPoint=/mnt

# Create and use swapfile on resource disk.
ResourceDisk.EnableSwap=y

# Size of the swapfile.
ResourceDisk.SwapSizeMB=1000


Also edit the file /etc/fstab and remove the line:

/dev/sdb1 /mnt auto defaults,nobootwait,comment=cloudconfig 0 2

Now after a reboot the waagent starts creating a swap file and after a while it is enabled:

swapon -s
Filename Type Size Used Priority
/mnt/swapfile                           file 1023996 0 -1