More specifically, these notes should be of interest to the following groups:
Once you launch the instance, you'll be prompted to create a public key and download its private key file (.pem extension). You'll need this file to SSH into the instance from your computer.
Once the instance is running, you can SSH into it. For example, on a Mac, if your key file file is named myubuntu-1.pem, enter this in a Terminal window:
ssh -i myubuntu-1.pem ubuntu@xx.xx.xx.xxwhere xx.xx.xx.xx is your instance's public IP address, which you can get from the EC2 Dashboard's Instances panel. This will log you into your instance's home folder ("ubuntu"). Enter "exit" to log out.
Important! If you get an error message about permissions for your key file, be sure to do this:
chmod 400 myubuntu-1.pemOnce logged in, you can use sudo on your Ubuntu instance to install just about anything you need. We'll start with installing Free Pascal.
Tip: If you need a text editor on your Ubuntu instance, try the pre-installed nano.
if [ "$1" = "" ]; then echo "No file specified" elif ! [ -e "$1" ]; then echo "File does not exist" else scp -i myubuntu-1.pem "$1" ubuntu@ec2-xx-xx-xx-xx-xxxxx.compute.amazonaws.com:~ fi(The string between the "@" and the ":" is your Ubuntu instance's public DNS, which can be obtained from the Instances panel.)
Now use the script to copy the .deb file to your Ubuntu instance like this:
./copy2ubu.sh fpc_2.6.4-140420_amd64.debInstall the package on your Ubuntu instance like this:
sudo dpkg -i fpc_2.6.4-140420_amd64.debTip: To copy a file from your Ubuntu instance to your computer, you can use a script like this on your computer:
scp -i myubuntu-1.pem ubuntu@ec2-xx-xx-xx-xx-xxxxx.compute.amazonaws.com:"$1" .
curl --remote-name https://macpgmr.github.io/MacXPlatform/p4g.zipUnzip this file in a subfolder under your home folder.
You'll also need the Web Service Toolkit (WST) to compile Part 3's ndfd library, so first install Subversion:
sudo apt-get install subversionNow change to a subfolder where you want to download the WST source and enter this:
svn co https://svn.code.sf.net/p/lazarus-ccr/svn/wst/trunk .Next change to the p4g example code's ndfd subfolder and compile the ndfd library with FPC (adjust the -Fu path to point to your WST source):
ppcx64 -CiroR -O2 -XX -Cg -k-fPIC -Fu~/Tools/WST -olibndfd64.so ndfd.pasTo compile the examples below, you'll need to put the library somewhere that the linker can find it. You can just copy it to /usr/lib like this:
sudo cp -p libndfd64.so /usr/libNow compile the example testndfd.pas console app:
ppcx64 -Fu~/Tools/WST testndfdAnd test the console app:
./testndfd
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable && sudo apt-get updateNow install the GDAL/OGR programs and libraries:
sudo apt-get install gdal-bin libgdal-devCheck to see what version of GDAL is installed by running one of the command-line utilities:
ogr2ogr --versionNow change to the p4g example code's gdal subfolder and compile the example testgdal.pas console app:
ppcx64 testgdalAnd run it:
./testgdalYou should see the same version that ogr2ogr displayed.
sudo apt-get install mono-runtime && sudo apt-get updateNow change to the p4g example code's ndfd subfolder and compile the C# wrapper class and testndfd.cs console app:
./comp-cs-interop.sh ./comp-cs.shBy default, these scripts use the /platform:x86 switch, which sets the Ndfd.Interop.dll assembly's Corflags 32BIT flag, but Mono ignores this .NET flag and still expects a 64-bit ndfd library. However, it will still look for libndfd.so, instead of libndfd64.so. You can change the comp-cs-interop.sh script and add the /define:USE_64_BIT switch to change this behavior, but it's probably easier just to redirect via a symlink:
sudo ln -s /usr/lib/libndfd64.so /usr/lib/libndfd.soNow you can run the test app:
mono testndfd.exe
curl --remote-name https://macpgmr.github.io/MacXPlatform/DotSpatial_p4g.zipUnzip these files in the AspCast example's refs subfolder. Also copy the Ndfd.Interop.dll assembly to the refs subfolder.
Now compile the AspCast ASP.NET Web app with Mono:
xbuild AspCast.slnTo prepare for deployment, zip up these files:
zip aspcast Default.aspx zip aspcast ImageHandler.ashx zip aspcast Global.asax zip aspcast web.config zip aspcast Images/*.* zip aspcast Layers/*.* zip aspcast bin/*.*
sudo apt-get install apache2 libapache2-mod-monoNow deploy the AspCast files (substitute your folder for Tools):
cd /var/www/html sudo mkdir aspcast cd aspcast sudo cp -p ~/Tools/p4g/AspCast/AspCast/aspcast.zip . sudo unzip aspcast.zip sudo rm aspcast.zipMake sure you've created the /usr/lib/libndfd.so symlink as described above.
Also make sure Apache is running:
sudo service apache2 restartFinally, on the EC2 Dashboard's Security Groups panel, edit the Inbound rules for your Ubuntu instance's security group. By default it only allows SSH, so you'll need to add HTTP (don't delete SSH).
Now, in a Web browser back on your computer, paste your Ubuntu instance's public DNS (from Instances panel) and add "/aspcast" to it (without quotes). Enter this URL and the AspCast app should appear in your browser.
sudo apt-get install libpython2.7-dev libpython3.4-devChange to the p4g example code's ndfd subfolder and compile the Python extension modules:
ppcx64 -B -Cg -ondfdmod64.so ndfdmod.pas ppcx64 -B -Cg -dUSE_PYTHON3 -ondfdmod64_3.so ndfdmod.pasTest with both Python 2.7 and 3.4:
python testndfd.py python3 testndfd.py
Once you launch the instance, you'll be prompted to create a public key and download its private key file (.pem extension). You'll need this file to connect to the instance from your computer.
Next install a remote desktop client app on your computer. For example, on a Mac, download the Microsoft Remote Desktop app from the Apple App Store. Then follow Amazon's instructions for connecting to your Windows instance.
Tip: On a Mac, once you've downloaded the .rdp file, you can double-click it to start Microsoft Remote Desktop and connect to your Windows instance. But to customize your setup, you'll need to use File | Import and select the .rdp file. Now you can edit the setup. For example, you can turn off the default full screen mode and scale the Windows desktop to the size of the window on your Mac. You can also set up a shared folder on your Mac for copying files to and from your Windows instance.
To test Part 3's examples, you can download and install whatever software you need, including Free Pascal, Subversion (for retrieving Web Service Toolkit source), Xamarin Studio, Python, etc. Note that .NET 4.0 is already installed.
If you need a text editor, Windows includes both Notepad and WordPad. Notepad does not know how to handle text files with Unix-style line endings, but WordPad does.
Windows Server includes something called PowerShell, but the familiar Command Prompt is also available.
Tip: On a Mac laptop, use a two-finger click on the trackpad to simulate a right-click. The normal control+click combination won't work in Windows.
To prepare for deployment, zip up these files:
zip aspcast Default.aspx zip aspcast ImageHandler.ashx zip aspcast Global.asax zip aspcast web.config zip aspcast Images/*.* zip aspcast Layers/*.* zip aspcast bin/*.*
Next create a subfolder named "aspcast" under C:\inetpub\wwwroot and unzip the AspCast files in this subfolder.
Finally, make sure you've done the following:
macpgmr (at) icloud (dot) com
First posted Sept. 13, 2015; last edited June 10, 2017.