Tag Archives: install

Bash on Windows 10

I was pleasantly surprised to see that there is beta support for a Ubuntu-based bash on Windows 10.

An introduction is here, along with an Installation Guide on the MSDN website.

apt-get pulls an obsolete version of NodeJS. To load the latest (as of today) NodeJS, use the following commands with root privileges:

apt-get -y update
apt-get install git
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
apt-get install -y nodejs

Install NodeJS and MongoDB on CentOS 7

As always, I’m sharing my personal notes here. I’ve used virtual machines for development since the first version of VMware. I’ve been using DigitalOcean’s services for some time. I generally use their CentOS 7 install.

NodeJS

Update: I have newer install instructions here.

Edit: Removed old instructions.

Some native add-ons from npm require build tools. If you anticipate needing those, install:

yum -y install gcc-c++ make

MongoDB

Installing MongoDB’s community edition requires creating a yum repo file, a a system configuration file, and then a reboot.

vim /etc/yum.repos.d/mongodb-org-3.2.repo

and fill it with the following text:

[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

which allows MongoDB to be installed with a simple:

yum install -y mongodb-org
service mongod start
chkconfig mongod on

Getting Rid of Warnings

If you use the mongo client, you’ll notice the following warnings:

Server has startup warnings:
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]

The soft rlimits warning can be fixed by creating a file:

 vim /etc/security/limits.d/90-nproc.conf

and putting the following line in it:

mongod     soft    nproc     64000

and rebooting the system.

The transparent_hugepage warnings can be fixed by creating a file:

vim /etc/init.d/disable-transparent-hugepages

and filling it with:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.
### END INIT INFO

case $1 in
  start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

    echo 'never' > ${thp_path}/enabled
    echo 'never' > ${thp_path}/defrag

    re='^[0-1]+$'
    if [[ $(cat ${thp_path}/khugepaged/defrag) =~ $re ]]
    then
      # RHEL 7
      echo 0  > ${thp_path}/khugepaged/defrag
    else
      # RHEL 6
      echo 'no' > ${thp_path}/khugepaged/defrag
    fi

    unset re
    unset thp_path
    ;;
esac

ensuring it runs at startup:

chmod 755 /etc/init.d/disable-transparent-hugepages
chkconfig --add disable-transparent-hugepages

and then, finally, rebooting. The mongo client should start without warnings now:

 
MongoDB shell version: 3.2.9
connecting to: test
>

 

 

Installing a PhoneGap App On an iOS Device Using iTunes

Preliminary Steps

To produce an iOS build using the PhoneGap Build web site, one must have created a signing certificate and provisioning list for the devices that the app is allowed to run on. These notes assume that this has been done, and there is a successful build on the PhoneGap Build web site.

Loading into iTunes

The first step, and the first potential roadblock, is loading the app into iTunes.

  1. Plug in the iOS device into the computer and select the device.
  2. Download the .ipa file from the PhoneGap Build site.
  3. Drag and drop the .ipa file onto iTune.

This is where the first “gotcha” may turn up. The .ipa file does not have Apple’s blessing. By default OS X will refuse to load any un-blessed apps.

skitch

This can, however be changed in the Security preferences.

skitch

Use the lock symbol to allow for changes to the security settings, then choose “Anywhere” in the “Allow apps downloaded from:” section.

skitch

OS X will give a final warning about the dangers of doing this, and that the setting will revert to after a certain amount of time.

skitch

 

Now the app should show up in the list of apps to load onto the iOS device, and will be loaded when you sync the device.

Hydration Hanging

Hydration is a wonderful development tool that will automatically fetch the latest version of the app from the PhoneGap Build web site. (It must be removed before submitting the app to Apple for review.) However, when one starts the app,  it will sometimes hang.

To kill the hung app, the Apple support web site has an excellent tip.

Installing Django on CentOS

These are notes for what I did to get Django working on CentOS.

Activate EPEL.

Use the appropriate version, of course. I used:

[bash light=”true”]
$ sudo rpm -Uhv http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[/bash]

Install Prerequisites

  1. Install Apache.
    1. Ensure it’s working, including ensuring the firewall lets traffic through.
  2. Install MySQL
  3. Install revision control or however you pull software, e.g. git.
    1. Create a non-priviledged user, if that’s you install your software.
    2. Ensure Apache can access the software directory.

Install Django

[bash light=”true”]
$ sudo yum install python Django mod_python MySQL-python
[/bash]

Test Django

[python light=”true”]
$ python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print django.get_version()
1.4.5
>>>
[/python]

Install and Test the Software

I create a separate user for managing the code via git.
Put the code somewhere appropriate, e.g. /opt.

  1. The address 0.0.0.0 tells Django to accept external connections.
  2. Ensure the test port is open on the firewall.

[bash light=”true”]
$ cd /opt/foo
$ python manage.py runserver 0.0.0.0:8000
[/bash]

Attempt to connect to your application. Ensure, for example, that the settings allow database access.

Running Django from Apache WSGI

Create an Apache WSGI file.

[bash light=”true”]
$ cd /opt/foo
$ mkdir apache
$ vim apache/django.wsgi
[/bash]

and fill the file with something like:

[python]
import os
import sys

sys.path.append(‘/opt/foo’)
sys.path.append(‘/opt/foo/foo’)

os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘foo.settings’

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

[/python]

Inside of the Apache virtual host:

[php]
<VirtualHost *:80>
ServerName foo.bar.com

WSGIScriptAlias / /opt/foo/apache/django.wsgi

# Alias /robots.txt /opt/foo/static/robots.txt
# Alias /favicon.ico /opt/foo/static/favicon.ico
Alias /static/admin/ /usr/lib/python2.6/site-packages/django/contrib/admin/media/
Alias /static/ /opt/foo/static/

<Directory /opt/foo>
Order allow,deny
Allow from all
</Directory>

<Directory /opt/food/static>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
[/php]

Restart the Apache server.

Test to ensure that you can connect.

Credits

A big shout out to ITek Blog’s article Installing Python / Django on Centos 6.3 is Easy!.

Installing Django on CentOS 6

Django is available as an EPEL package.

First, activate EPEL via

[code lang=”bash”]
$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[/code]

or for 32-bin CentOS,

[code lang=”bash”]
$ sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
[/code]

NOTE: That exact URL will change with time. I took it from the EPEL FAQ.

Next, install the Django package.

[code lang=”bash”]
$ sudo rpm install Django
[/code]

Ensure that Django is working.

[code lang=”python”]
$ python
Python 2.6.6. (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or license" for more informaiton.
>>> import django
>>> print django.get_version()
1.4.5
>>> _
[/code]

Install wget on OS X

These notes assume Xcode and the command-line tools are installed.

Get the current wget from the GNU FTP site. As of the date of this article, wget 1.14 is current. (Update: As Alex notes in the comments, 1.15 is available.)

Building is the typical GNU build sequence, but use the –with-ssl=openssl option with configure.

[code lang=”bash”]
curl -O ftp://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
tar xvzf wget-1.15.tar.gz
cd wget-1.15
./configure –with-ssl=openssl
make
sudo make install
[/code]

And it’s done.

How to Install gcc 4.7 on Mac OS X

XCode installs gcc 4.2 which has some bugs that prevent me from running skeinforge. This is how I installed gcc 4.7.

First install MacPorts. Then use the port command to install and activate the new gcc.

[code language=”bash”]
sudo port install gcc47
sudo port select gcc mp-gcc47
hash gcc
[/code]

To make the previous gcc active, use

[code language=”bash”]
sudo port select gcc none
hash gcc
[/code]