<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Debian - Bacon Applications]]></title><description><![CDATA[Follow me while I share with the world useful things I have learned and projects I am working on.]]></description><link>http://www.baconapplications.com/</link><image><url>http://www.baconapplications.com/favicon.png</url><title>Debian - Bacon Applications</title><link>http://www.baconapplications.com/</link></image><generator>Ghost 3.7</generator><lastBuildDate>Sat, 22 Mar 2025 17:47:26 GMT</lastBuildDate><atom:link href="http://www.baconapplications.com/tag/debian/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Setting Up WPA2 on Raspberry Pi Running Raspbian Jessie Lite]]></title><description><![CDATA[There are several years' worth of setting up the Edimax EW-7811N Wi-Fi adapter on a Raspberry Pi B on the internet.  By now (2017) most of it is out of date]]></description><link>http://www.baconapplications.com/setting-up-wpa2-on-raspberry-pi-running-raspbian-jessie-lite/</link><guid isPermaLink="false">5e535ef4ba89970001e0b062</guid><category><![CDATA[Debian]]></category><category><![CDATA[Raspberry Pi]]></category><dc:creator><![CDATA[Randy Bacon]]></dc:creator><pubDate>Tue, 07 Feb 2017 05:06:00 GMT</pubDate><media:content url="http://www.baconapplications.com/content/images/2020/02/cover.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="http://www.baconapplications.com/content/images/2020/02/cover.png" alt="Setting Up WPA2 on Raspberry Pi Running Raspbian Jessie Lite"><p>There are several years' worth of setting up the Edimax EW-7811N Wi-Fi adapter on a Raspberry Pi B on the internet.  By now (2017) most of it is out of date and wrong.  Last week, I wasted several hours trying to make WPA2 authentication work on my Raspberry Pi B.  Hopefully this guide will save someone (or future me) some time.</p>
<h2 id="myhardware">My Hardware</h2>
<img style="height:150px;padding-right:50px;display:inline-block;" align="left" src="http://www.baconapplications.com/content/images/posts/piwpa2wifi/box.png" alt="Setting Up WPA2 on Raspberry Pi Running Raspbian Jessie Lite">
<ul>
<li>Edimax EW-7811N</li>
<li>Raspberry Pi B Revision 2</li>
<li>Rapbian Jessie Lite 1/11/2017</li>
</ul>
<p><br><br><br><br></p>
<h2 id="gettingstarted">Getting Started</h2>
<p>Roll back any changes you have made to the /etc/network/interfaces or /etc/wpa_supplicant/wpa_supplicant.conf files.  I usually make .bak copies of config files before I make changes.  However, if you did not make backups of these files, the contents of each original file is below.</p>
<h3 id="etcnetworkinterfaces">/etc/network/interfaces</h3>
<pre><code># interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

#iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
</code></pre>
<h3 id="etcwpa_supplicantwpa_supplicantconf">/etc/wpa_supplicant/wpa_supplicant.conf</h3>
<pre><code>country=US                                                
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev   
update_config=1                                           
</code></pre>
<p>Additionally, I had installed WICD at some point while trying to configure the adapter.  WICD will eat up to 5% of CPU in idle so you will want to uninstall it if you journeyed down the same rabbit hole I did...</p>
<h3 id="restart">RESTART</h3>
<p>Before continuing (and wasting more of your precious time) RESTART your Pi  (sudo reboot or sudo shutdown -r now).  I probably wasted another 30 minutes with a working solution because I hadn't restarted...</p>
<h2 id="usb">USB?</h2>
<p>Make sure the Wi-Fi adapter is plugged in and showing via the <em>lsusb</em> command:</p>
<img src="http://www.baconapplications.com/content/images/posts/piwpa2wifi/lsusb.png" alt="Setting Up WPA2 on Raspberry Pi Running Raspbian Jessie Lite" class="img-responsive">
<p>The Wi-Fi adapter should be show as &quot;Edimax Technology Co...&quot; as per above.  If it is not showing up, try unplugging and plugging in the adapter and/or restarting.</p>
<h2 id="settingupwpa2">Setting Up WPA2</h2>
<p>To set up WPA2 authentication, you will only need to edit the /etc/wpa_supplicant/wpa_supplicant.conf file.  Edit this file with the following:</p>
<pre><code>country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid=&quot;YOURNETWORKSSIDHERE&quot;
psk=&quot;YOURPASSWORDHERE&quot;
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
group=CCMP
auth_alg=OPEN
}
</code></pre>
<p>Replace YOURNETWORKSSIDHERE with your SSID and YOURPASSWORDHERE with your Wi-Fi password.</p>
<p>At this point restart your Pi.</p>
<p>Once your Pi has restarted fully, run the <em>ifconfig</em> command to confirm your adapter is getting an IP address.  The wireless link should be next to wlan0 or wlan1 in the dump:</p>
<img src="http://www.baconapplications.com/content/images/posts/piwpa2wifi/ifconfig.png" alt="Setting Up WPA2 on Raspberry Pi Running Raspbian Jessie Lite" class="img-responsive">
<h2 id="nosleep">No Sleep</h2>
<p>Finally, if your Pi needs to have Wi-Fi on at all times, be sure to disable power management by creating or editing the /etc/modprobe.d/8192cu.conf file via sudo nano /etc/modprobe.d/8192cu.conf:</p>
<pre><code># Disable power management
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
</code></pre>
<p>After this change, restart your Pi again.</p>
<h2 id="conclusion">Conclusion</h2>
<p>I you found this guide helpful and hopefully it saved you some time!  Until next time - happy coding!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Moving a NodeJS App to Production on Debian Wheezy]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>WOW! Moving this application (my new website and blog) to my Debian VPS was a little harder than I wanted and anticipated.  Of course this was my first time publishing a Node app to production so some learning time was to be expected...</p>
<h3 id="gettingreadyforproduction">Getting Ready for Production</h3>
<p>Before moving from</p>]]></description><link>http://www.baconapplications.com/moving-nodejs-app-to-production-on-debian/</link><guid isPermaLink="false">5e535ef4ba89970001e0b059</guid><category><![CDATA[NodeJS]]></category><category><![CDATA[Debian]]></category><dc:creator><![CDATA[Randy Bacon]]></dc:creator><pubDate>Mon, 08 Sep 2014 04:51:49 GMT</pubDate><media:content url="http://www.baconapplications.com/content/images/2020/02/gitCheckin.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="http://www.baconapplications.com/content/images/2020/02/gitCheckin.png" alt="Moving a NodeJS App to Production on Debian Wheezy"><p>WOW! Moving this application (my new website and blog) to my Debian VPS was a little harder than I wanted and anticipated.  Of course this was my first time publishing a Node app to production so some learning time was to be expected...</p>
<h3 id="gettingreadyforproduction">Getting Ready for Production</h3>
<p>Before moving from PHP to Node on my server I had read several articles and posts about different set ups.  I decided to move to NGINX from Apache as my web server. I have used Apache since my first FreeBSD server - about 15 plus years ago - but it was time to move forward to something faster and with a fun name.  Another post will follow about this move later...</p>
<p>Since I already had NGINX up and running I just needed to adjust my website config to the following (real ports are not below but would be the port of your apps):</p>
<pre><code>server {
	server_name www.hirerandybacon.com;

	location / {
    	proxy_pass http://localhost:&lt;NODEJSPORT&gt;;
    	proxy_http_version 1.1;
    	proxy_set_header Upgrade $http_upgrade;
    	proxy_set_header Connection 'upgrade';
    	proxy_set_header Host $host;
    	proxy_cache_bypass $http_upgrade;
	}

	location /blog {
    	proxy_pass http://localhost:&lt;NODEJSPORT&gt;;
    	proxy_http_version 1.1;
    	proxy_set_header Upgrade $http_upgrade;
    	proxy_set_header Connection 'upgrade';
    	proxy_set_header Host $host;
    	proxy_cache_bypass $http_upgrade;
	}
}
</code></pre>
<p>Additionally, I went the lazy route and published all my web files as is from the raw project.  I plan on building a Grunt script to help with this but for now it was all manual.</p>
<h3 id="whatdidntwork">What didn't work</h3>
<p>I tried several methods to get my node app up and running.  First I installed <a href="https://github.com/nodejitsu/forever" target="_blank"><i>forever</i></a> figuring it would be the easiest way (and I have heard others talking about it).  Running forever from the command line is as simple as (note: the NODE_ENV=production export is for my <a href="http://docs.ghost.org/" target="_blank">ghost</a> blog):</p>
<pre><code>NODE_ENV=production forever start app.js
</code></pre>
<p>The first issue I had found was a warning about sqlite3.  Because of my recent work with node-webkit I figured I needed to do an actual npm install on the machine to compile SQLITE.  I changed to the web directory of my project and ran:</p>
<pre><code>npm install sqlite3
</code></pre>
<p>Of course this yeilded some random error messages about permissions and also one of interest.  I was missing <i>make</i>.  So installing <i>make</i> was needed:</p>
<pre><code>sudo apt-get install build-essential
</code></pre>
<p>After running this, the base application started but now the ghost module was complaining about sqlite3 (the joys of developing on Windows and publishing to Debian).  I changed to the ghost directory inside of my web/node_modules directory and ran the npm install sqlite3 command again.</p>
<p>Finally this worked without issue and I was excited. Time to set it up to run via the cron.  Being the old school Unix guy I was (or maybe more accurately the lack of recent Unix experience) - I rushed to set up an init.d script.</p>
<p>I tried several init.d scripts from git and Google search results.  It seemed each had an issue and did not work well with my flavor of Debian - Wheezy.  Additionally, more errors were caused by creating the scripts on Windows and coping it to my Debian box.  Turns out carriage returns were the cause.</p>
<h3 id="whatfinallyworkedafterawhile">What finally worked after a while...</h3>
<p>After wasting some good football watching time with the init.d I decided to try something simpler from the <a href="http://support.ghost.org/deploying-ghost/" target="_blank">Ghost docs</a> - <a href="http://supervisord.org/" target="_blank">Supervisor</a>.  The installation and config was pretty easy.</p>
<pre><code>sudo apt-get install supervisor
</code></pre>
<p>On step 2 - <code>service supervisor start</code> I received the following a useless error message:</p>
<pre><code>Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
</code></pre>
<p>Great!  A quick google search though indicated I just needed to run this:</p>
<pre><code>sudo unlink /var/run/supervisor.sock
</code></pre>
<p>After running the command and trying again, the service was running.  I banged out a quick config for my node application and saved it to the config.d directory - /etc/supervisor/conf.d/ - (of course the real path below is a little different but you get the idea):</p>
<pre><code>[program:hirerandybacon]
command = node /mysecrectpath/app.js
directory = /mysecrectpath
user = www-data
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/hirerandybacon.log
stderr_logfile = /var/log/supervisor/hirerandybacon_err.log
environment = NODE_ENV=&quot;production&quot;
</code></pre>
<p>Now I went to fire off the supervisor program via:</p>
<pre><code>sudo supervisorctl start hirerandybacon
</code></pre>
<p>And instead of a running app I received the following error message:</p>
<pre><code>hirerandybacon: ERROR (no such process) 
</code></pre>
<p>&quot;GRRR,&quot; said Randy.  This required more Google searching which brought me to this solution:</p>
<pre><code>supervisorctl reread
supervisorctl reload
</code></pre>
<p>FINALLY starting the program yields success and my site is now running.  Or is it?</p>
<h3 id="moreissues">More Issues</h3>
<p>I guess because I'm bored I decided to log into my blog and finish up my first post.  I tired to log in and received no response until a toast popped up saying a server error had occurred.</p>
<p>I checked the supervisor log and of course there where no relevant log items.  At this point I was tired and wanted to brutte force my way though this thing.  I decided to try to run the Node app again via the command line but this time as the www-data user (you know the user I assigned the app to above).  A quick change of the user via:</p>
<pre><code>sudo su www-data
</code></pre>
<p>Firing up the app via:</p>
<pre><code>NODE_ENV=production node app.js
</code></pre>
<p>And finally a useful error message.  The database was opening in read only mode.  Why?  Because when I deployed my database, although I thought I had chown'd the data directory and db to the :www-data group I hadn't changed permissions...  After changing the permissions on the data directory (775) and database (664) and restarting my app, I was in business.</p>
<p>After a few hours (or maybe an evening) my node app and blog is running in production.  I guess the plus side is I had another topic to blog about.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>