How to install Node.js on a Mac OS X 10.12 (All Steps!)

Okay. Node.js install. First, let me say, I’m straight up copying steps from other places, BUT this is TOTALLY different because I’ve patched them all together in one spot for ease of use. Okay, enough funny business.

Here are the places I cribbed such wonderful instructions and Frankensteined them together:

Deep breath. Here we go!

  1. Download and install Apple’s Xcode.
  2. Launch Xcode and agree to the terms. It may install some additional components. Once you agree, then you can close it.
  3. Open your Terminal app (located in Applications > Utilities > Terminal.
  4. Install Xcode’s command line tools:
    xcode-select --install
  5. Reboot in “recovery mode” by restarting your computer and when you hear the start up chime, hold down the “command”+”R” keys until it fully reboots.
  6. Once in Recovery mode, open Utilities > Terminal and run “csrutil disable”. We are going to install Homebrew which needs permissions to the “/usr/local” directory, which Apple restricts.
    csrutil disable
  7. Reboot your computer!
  8. Reopen Terminal.
  9. Set permissions for ‘/usr/local’ by running…
    sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local
  10. Reboot in “recovery mode” again.
  11. Once in Recovery mode, open Utilites > Terminal and run “csrutil enable” to make sure we reinstate Apple’s security measures.
    csrutil enable
  12. Reboot your computer
  13. Open Terminal and install Homebrew through the command line.
    ruby -e "$(curl -fsSL"
  14. Test if Homebrew installed correctly by running…
    brew doctor
  15. Install Node through the command line.

    brew install node
  16. Test to see the node versions
    node -v


    npm -v
  17. Create a test.js with some code in it.
    console.log('I installed Node.js');
  18. Run it with node to prove your install works.
    node test.js
  19. You’re done. Woo hoo!

Be careful when Integer Typecasting / Type Juggling in PHP

There I was, minding my own business checking to see if a string was an integer or not. That’s so simple! We’ll use PHP’s built-in is_int() function. So easy.

$var = "5";
echo is_int($var)?(int)$var:0;

But, wait a second, this outputs a “0” instead of the expected “5”.

Alright, you might say,” of course, Adam, your $var is surrounded by quotes. It’s obviously a string.” Yes, I absolutely agree. The problem is I have form inputs that should pass back numbers (like a year or user id) that were behaving like strings. What’s a guy to do?

To solve this I cast the variable as an integer and tested to see if it was greater than zero. (See PHP’s Type Juggling or, Can Someone Explain PHP Type Juggling on StackOverflow)

Test 1: If casting “5” as integer is greater than zero, then output the variable else zero;

$var = "5";
echo ((int)$var > 0)?(int)$var:0;

Hooray, test 1 works. It output 5.

Test 2: If casting “John Smith” as integer is greater than zero, then output the variable else zero;

$var = "John Smith";
echo ((int)$var > 0)?(int)$var:0;

Hooray, test 2 works. It output zero because it was not an integer.

I’m so glad we solved that. Now, we can go home and rest our heads at night.

Except … something went wrong!


In an odd place somewhere deep within the code, an input gets passed along that could be either an email or a user id. So I tested if the input was a valid email or (in the case below) a valid integer. And, it all works swimmingly.

If it passes an email, then it results in zero.

$var = "";
echo ((int)$var > 0)?(int)$var:0;

If it passes a user id, then it casts the variable as an integer and it’s a happy day.

$var = "5983024";
echo ((int)$var > 0)?(int)$var:0;

But when we pass an email that starts with a number, then it truncates the variable to the beginning number. In the example below, the variable outputs the integer “999”. Ouch!

$var = "";
echo ((int)$var > 0)?(int)$var:0;

In this same way, decimal numbers also get truncated.

$var = "89.78";
echo ((int)$var > 0)?(int)$var:0;

Shoot! Not even rounded. Just truncated. This will not do at all.

Don’t lose hope. There’s a solution!

This is the best solution I could come up with. We compare the character count (“strlen()”) of the variable both as it is and when cast an integer. Also, we see if the variable cast an integer is greater than zero, as we did before.

$var = "";
echo ( strlen($var) == strlen((int)$var) && (int)$var > 0) ? (int)$var : 0;

Finally, this works (crossing my fingers) for now.

As a side note, I found an article detailing how Type Juggling might be used for PHP exploits. It could be a security loophole if not properly used.

Oh, and I put this test into a function for future use.

Install Jira on Linux (A Work In Progress Guide)


***** PRE INSTALL ******

  1. Determine your Linux environment.
    Find the server version on Linux (from• Find Linux version:

    $ cat /proc/version

    output example:

    Linux version 3.13.0-96-generic (buildd@lcy01-09) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) ) #143-Ubuntu SMP Mon Aug 29 20:15:20 UTC 2016

    • find 32 or 64 bit.

    $ uname -a

    output example:

    Linux myserverinstance 3.13.0-96-generic #143-Ubuntu SMP Mon Aug 29 20:15:20 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  2. Download Jira based on your Linux needs.
  3. Find if you have a pre-existing Jira install.
    In our case we had an old outdated version.
    (How to search using SSH via siteground.)
    • Note: you may need to login using the root user.
    • Make sure you’re at root directory of the server .

    find . -name "*jira*"

    • In my case, I found a folder containing the old jira data and renamed it.
    • I also deleted previous jira usernames and groups.
    • And I switched to that folder.

  4. If there are old files, rename the folder ( common ssh commands at Media Temple )
    $ mv atlassian atlassian_old
  5. Upload to your server
    $ scp /local-computer-directory/atlassian-jira-software-7.3.6-x64.bin root@
  6. Move it to the designed directory (if necessary)
    $ mv /var/www/chosendirectory/atlassian-jira-software-7.3.6-x64.bin /var/atlassian-jira-software-7.3.6-x64.bin

    Also, check the file moved correctly and directory contents by using:

    $ ls -l

***** INSTALL ******

1. Give the file the correct permissions

chmod a+x atlassian-jira-software-7.3.6-x64.bin

2. Run the installer

$ sudo ./atlassian-jira-software-X.X.X-x64.bin

• It will start to unpack the JRE and start the installer.
Unpacking JRE … Starting Installer …
• It will ask you if you want to install Jira on your computer
This will install JIRA Software 7.3.6 on your computer. OK [o, Enter], Cancel [c]
• Choose the appropriate installation or upgrade option.
Please choose one of the following:
Express Install (use default settings) [1],
Custom Install (recommended for advanced users) [2, Enter],
Upgrade an existing JIRA installation [3]
(I chose the express option.)
• Verify the default settings details on where JIRA Software will be installed and the settings that will be used.Installation Directory: /opt/atlassian/jiraHome Directory: /var/atlassian/application-data/jiraHTTP Port: 8080RMI Port: 8005Install as service: Yes y
Details on where JIRA Software will be installed and the settings that will be used.Installation Directory: /opt/atlassian/jiraHome Directory: /var/atlassian/application-data/jiraHTTP Port: 8080RMI Port: 8005Install as service: Yes Install [i, Enter], Exit [e]
• start Jira (y/n)?
• It says it’s available at JIRA Software 7.3.6 can be accessed at http://localhost:8080

***** SETUP ******

***** DATABASE SETUP *****
1. Double check that the user doesn’t exist.

SELECT User, Host, Password FROM mysql.user;

2. Create a new user

Create Database UserCREATE USER 'jiradbuser'@'localhost' IDENTIFIED BY 'YOURPASSWORDHERE';
GRANT ALL PRIVILEGES ON * . * TO 'jiradbuser'@'localhost';
flush privileges;

Edit the my.cnf file (my.ini on Windows operating systems) in your MySQL server. (Refer to MySQL Option Files for detailed instructions on editing my.cnf and my.ini.)Locate the [mysqld]section in the file, and add or modify the following parameters:

find . -name myFile.txt

Upload file

$ scp /local-computer-directory/mysql-connector-java-5.1.42-bin.jar root@55.555.555.55:/opt/atlassian/jira/lib

**** Hmm. Not working. **** 

• Check server listening ports# sudo netstat -plnt
• Check if Jira is running
• Check from the server
# ps -ef | grep JIRA
/opt/atlassian/jira/jre//bin/java – Djava.util.logging.config.file=/opt/atlassian/jira/conf/ – Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms384m -Xmx768m – Djava.awt.headless=true -Datlassian.standalone=JIRA – Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true – Dmail.mime.decodeparameters=true – Dorg.dom4j.factory=com.atlassian.core.xml.InterningDocumentFactory -XX:+PrintGCDateStamps – XX:-OmitStackTraceInFastThrow -Datlassian.plugins.startup.options= – Djdk.tls.ephemeralDHKeySize=2048 – Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /opt/atlassian/jira/bin/bootstrap.jar:/opt/atlassian/jira/bin/tomcat-juli.jar – Dcatalina.base=/opt/atlassian/jira -Dcatalina.home=/opt/atlassian/jira – org.apache.catalina.startup.Bootstrap startroot     13745 26042  0 13:19 pts/0    00:00:00 grep –color=auto JIRA

Where should I upload it on the server?
• find if jira is on your server:

$ find . -name "*jira*"What about web access

Check if Jira is running

Start / Stop Jira

sudo ./opt/atlassian/jira/bin/
sudo ./opt/atlassian/jira/bin/
sudo ./opt/atlassian/jira/bin/

Download Jira Logs to your local computer

scp root@55.555.555.55:/opt/atlassian/jira/logs/catalina.out /local-computer-directory/downloadscp root@55.555.555.55:/opt/atlassian/jira/conf/server.xml /local-computer-directory
ps -ef | grep JIRA

Display All users

getent passwd

Display All users with a username

getent passwd | grep username

All groups:

$ getent group

All groups with a specific user:

$ getent group | grep username

Delete User

userdel newuser

Remove User Directory

rm -rf /home/newuser

echo_data_title_die() (My favorite custom PHP function for testing)

Okay, who hasn’t been here.

You need to test some code, so you echo out a variable.

echo "first name: " .  $first_name . "<br/>\r\n";

Or worse yet, you have to echo out an array or object.

echo "<pre>User Info";
echo "</pre>";

Doesn’t seem so bad, right? If you’ve done any testing, then you know you’ll be commenting out, deleting, rewriting, commenting out, deleting, and rewriting those lines over and over again. Tedius. Not fun.

So I’ve come up with my own testing function.


Its purpose and inputs needed are within the name itself:

  • echo: outputs PHP variable to the screen.
  • data: the minimum input needed to output the variable. (This can be a string, a number, an array, or an object. The function will determine what it is and output the correct HTML syntax.)
  • title: this is an optional input for you to put the variable’s name.
  • die: optional command to kill the code after outputting the variable. This can be ‘die’, ‘yes’, ‘y’, or 1 to kill the code. Any other value will allow the code to keep running.

Example uses:

echo_data_title_die($user_array,'user array');
echo_data_title_die($shopping_cart_object, 'shopping cart object', 'die');

Running the above code will output a string with a line break, a <pre> formatted array (so it is more readable), as well as a <pre> formatted object.

Another helpful everyday use:

It’s always a good thing to know what file and line number you are on when debugging.

echo_data_title_die(__LINE__.' '.__FILE__);

The full code: