Optimzing nginx for Ghost and PHP

Running Ghost on the same server as a PHP application isn’t as difficult as it once was.

nginx.conf:

  • server_tokens off;
    Ensures that your server isn’t displaying the version
  • gzip on;
    In addition to these settings:
    gzipvary on;
    gzip
    proxied any;
    gzip_comp_level 9;
    gzipbuffers 16 8k;
    gzip_http_version 1.1;
    gzip
    types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

As much as I wanted, compiling ngx_pagespeed didn’t seem like the right thing to do at this time. Haven’t had much experience with gzip, but thought turning up compression to the max was the best thing to do for now.

My one PHP app is currently an invision power board site. Initially it had problems with it’s seo settings, and saw that many IPB users were expressing desire to solve the Friendly-URL problems on nginx. Eventually, I found an excellent reference on the Xenforo help documentation on this topic – and used two of the suggestions:

The first goes in the root location block:
try_files $uri $uri/ /index.php?q=$request_uri;

The second added some links to the php files block for fastcgi:
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

Google’s Pagespeed site said that I wasn’t using browser caching, so added this:
location ~*\.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate"; }

Ghost needed a restart to work properly, but the development IPB forum is doing quite well.

The IBP FURLs are now at the same settings as they were when on the Apache server, with no added .htaccess file.

Lake Fayetteville Looking Nice

Since the leg around the NWA Mall was completed a few months ago, I’ve come to the front-end of the lake with less stress as time goes by. The hill beside the go-cart track has taken some getting used to.

My phone doesn’t give this view of the lake the experience it should, but it was late in the day.

I’m burning a bit more calories and reducing the internal time slightly with each ride, but noticed that my phone app isn’t recognizing an increase in speed. There is a particular downhill section around the north-east bend of lake Fayetteville where my phone proclaims my average speed of +/- 13mph. It usually improves on the way back home, but ends up being close to that number at the time I stop/save. Maybe time to consider a change in device or software.

Still have a way to go, someone else has completed 64 trips around the lake this year already.

New Car Stereo for the FJ Cruiser

I occassionally shop around for a new vehicle, but haven’t yet found the right one. Of all the cars I’ve owned, the FJ has been with me more years than any other vehicle.

Fiddled with the iPod a bit too long last weekend, which was both frustrating and risky. The 1st gen factory stereo still sounds good, but the aftermarket iPod/Media gateway wasn’t working out.

Called Crutchfield after a frustrating trip through town last weekend and ordered:

  • Kenwood DPX-500BT
  • Axxess ASWC-1 Steering Wheel Control Adapater
  • Posi-Connectors (suggested by Crutchfield)
  • Scosche Adapter Kit and Hardware (provided by Crutchfield)
  • Metra Wire Harness (provided by Crutchfield)
  • Documentation/Guides normally provided by Crutchfield

Kenwood includes a standard ring, and a separate part designed specifically for Toyota vehicles, but didn’t use either.

The items arrived mid-week and verified the packing list. Did a bike trip Saturday morning and put on some stereo-installer grunge and sandalls.

First thing was to connect the Kenwood’s wiring harness to the two harnesses included with the Metra Kit for my FJ. It took a while to re-learn car stereo wiring, but the Posi-Connectors were very nice. I made two calls to Crutchfield during this phase, never read the directions – they walked me through it. The third Steering Controls harness was overwhelming for me, they emailed a small bit of documentation to help me become familiar with what was happening.

I brought one of the home wireless phones outside and propped it up on the dash, ejected all of the CD’s in the changer, and disconnected the battery’s negative lead.

The Crutchfield documentation was easy enough to follow for getting the dash trim and front/enviromental controls panel removed.

When I removed the four 10mm bolts holding the stock stereo, I put Crutchfiled on the speakerphone sitting on the dash. Shot a pic of the four plugs behind the stereo and emailed it to them for an on-the-spot explanation.

Starting from the left:

  • The first two were being reconnected to the adapter harness
  • The third plug wasn’t being used at all
  • The fourth was going to be tapped for the remaining three wires that needed to be connected to the steering wheel controls adapter and ground

This information was useful for helping me understand the next steps. I’ll admit that there was some doubt about buying the steering wheel controls adapter, but stuck with it.

There was some time alone needed for me to remove the Sirius XM equipment and iPod Media Gateway. It was a lot of cables, harnesses, and devices. Sirius XM never worked well when the vehicle was new and I cancelled the service within the first year. Looking at all of the equipment gave me an indication as to why the iPod Media Gateway never functioned that well either.

Plugging up the new wiring harness I had prepped earlier was when things started to get interesting. Crutchfield walked me through the four wiring connections at this step, but they were very patient with me because I had to tap into a couple wires on the unused controls plug. The picture below was taken when all of the connections were done, before cleaning up and securing the unused wiring.

Crutchfiled walked me through bolting on the stereo installation adapter, had to slip-off the Kenwood metal chassis adapter to make things work properly. I put the steering controls adapter module in my pocket and carried the Kenwood out to the car.

Another Crutchfield tech gave me advice on where to mount the microphone (on top of the steering column) and some additional words on the ASWC module. They let me know that we could test without plugging up the enviromental controls. I assembled the new stereo and bolted in it finger-tight.

There was plenty of space below the stereo to see the ASWC module’s lights, which is hanging below the stereo in the pic above.

The moment of truth wasn’t that eventful. Reconnected the battery, started the FJ, watched the ASWC module lights go through it’s cycles. The Crutchfield tech had me tune to an FM station, check the speakers, and try the steering wheel controls. They all worked the first time!

It didn’t take long to get everything back together and cleaned up.

This particular unit has only a forward-facing USB port, but response was immediate to my 5th Gen 64G iPod. Jammed to some tunes on Pandora as well. Bluetooth connectivity was very easy as well for both the iPod and my Android Phone; Rocket Man via Google Music sounded amazing.

Crutchfiled helped me with some additional infobits and adjustments. Provided the URL to Kenwood’s online manual, and printed a few pages to tweak the color settings to be closer to the stock lighting after washing the FJ. The new stereo’s internal amp generates an interesting-natural sound, that makes all of the speakers sound better. By the time I got back from the car wash, with a cup a single-batch coffee, I figured out how to make the stock subwoofer come alive.

As you may have noticed, I made several phone calls to Crutchfield’s Tech Support throughout the day. It may be part of their normal role and support; but there is no way this could have accomplished this without them. Each call was answered by a different tech who was able to pick up at any point and never need more than a moment to check reference info. 90% of the time they were answering right away. If you decided to tackle stereo installation on your own, Crutchfield makes it amazing, possible, and enjoyable.

Now on multi-site server

ShawnReed.Com now resides on an Nginx server that can host other types of sites. It wasn’t entirely difficult, but still a learning experience.

Server Configuration

These were helpful:
Ghost Installation Doc
Deploy Ghost Blog on Ubuntu Server and serve it to subdirectory using Nginx

I’ve been setting up sites on this server over the last month that were primarily low-traffic domains, with a healthy level of php support.

My normal document root seemed a bit out-of-place, because my experiences with ghost on both Bitnami and Digital Ocean prepackaged Ghost images used ‘ghost’ as the document root. In hindsight I’m not sure if that was worthwhile, but regardless.

Configuring Nginx to use a different document root wasn’t difficult, but getting the proxy settings to work wasn’t fun.

When ghost did finally run (by checking it’s standard port directly), I changed my DNS settings. For a while things still didn’t work properly on port 80. When I removed the document root index file names the issue was cleared up.

Had to revert to a previous theme to resolve some issues with disqus, a project for another weekend.

It was good to see the family on two wheels with me this evening 🙂

Take off the earbuds!

This morning’s ride was a cool 18.46 miles of cool-breeze and sunny skies, thanks to our mid-south location and climate change.

It was also an experience in frequent stalls, stops, and near-misses:

  • If you jog, don’t cross the line. When we’re saying “on your left”, it doesn’t make much sense if you can’t hear us.
  • Many walkers bring their dogs, which is great. Many dogs also like to go wherever the fun is, which isn’t too difficult to navigate as well. However, if your dog makes contact with another dog (which is also expected) that is also being walked by another being zoned out by earbuds it can result in two leashed dogs completely blocking the path. one of you needs to remove the tunes in order to hear what is going on
  • Parents with kids. I wish I brought my son on the path early like you, but a child that you can’t hear is an accident waiting to happen. Even if they are already riding your support will be needed. Leave the music at home, a child’s happiness should be enough
  • Riders experiencing fatigue need to be aware of their surroundings. Some will manage their energy and stop safely, but if you frequently push yourself to the limit it is important to understand how your reaction time is reduced when distracted. Listening to the latest music is fun, but can lead to an overall unpleasant ride and accidents if you are aggressively training. Motorcycle Riders learn reaction time variables in basic training.
  • Stopping in blind curves is something everyone is cautious about, but today’s listeners aren’t aware of their surroundings. It seems that those listening for long periods exhibit a perception that one part of the path is no different than another. If you find yourself stopping without stepping off, that a risk for others

The solution is easy, either turn down the volumne or leave it at home.