How do you migrate an existing Apache server, to a brand new nginx installation for several websites that use PHP? This is a simple tutorial into changing an Apache installation into a nginx one, without having to change your existing websites.
nginx is a server that scales far better compared to apache running on the same hardware. The tutorial is not super CentOS specific, but all the commands were run on a CentOS.
The Apache server that was migrated, namely this blog, has several virtual hosts, that are all running PHP, some of them Joomla websites. The plan is to take them as they are, and have them available externally the same way as before, using the same virtual host names, the same folder locations, with the same users assigned to them.
The reason is that if we screw up something in the process, we can just revert to our old proven Apache, by just restarting the Apache service and shutting down nginx. Also we can minimize the downtime, since if done right it should be in the end just shutting down apache and starting nginx, but if it doesn't work we can quickly go back to serving the files with Apache until we figure out what is going on.
While it is simple, it is a pretty long read, so grab your coffee, and hack away:
This is as simple as running:
Make sure the /etc/nginx/conf.d/default.conf has the paths pointing to /var/www/html, or whatever was the default site for your Apache configuration. (In my case it was /var/www/blog).
When creating websites performance is one of the main concerns that must be addressed. Fortunately with tools such as Google Page Speed measuring performance, with concrete actual improvement steps that can be taken. So when I've seen that the performance of this website was in the gutter, I know I had to take concrete actions:
The first quick win for a site is to activate compression.
This has the side effect of loosing the stack trace if I break on "uncaught exceptions", and breaking on "all exceptions" is absolutely no option, since many frameworks use the exception handling as mechanisms of detecting various features of the browser environment.
Thus I came up with this pattern:
So if an exception happens, I can still break on all exceptions, but also get my log right.
Can you imagine how cool it would be to chain exceptions like in Java? For example:
At least we can dream about it, and appreciate more languages that do offer chaining of exceptions.
An interesting article is making waves on dzone and twitter:
TL;DR: the sun.misc.* package it's going to be removed, a bunch of libraries are using it, apocalypse will ensue, just because Oracle removes packages for "no reason". (I kid you not, the dripstat author actually states that).
No it's not a new thing. No it's not the apocalypse now either. Let's break it down on why:
1. It's not at all a "no reason" change
It's because Java has become so full of security exploits, it's not even funny at this moment. It's scary to see how in January a patch fixed 19 security holes, with 13 of them being show stoppers. Oracle themselves explains it at length even.
It's not because:
"This engineer hates the Unsafe class for no real reason at all.."
That's a silly statement, to say the least. (To be honest, I get my blood boiling a bit just reading that sentence, because it's insulting to the engineer)
It is because people are loosing trust in the platform. Why would you go with a platform ridden with bugs like that? What's the point in using whatever framework that is allegedly super secure, if the JVM itself it's the weakest link. That is what makes Java now loose billions.
That's the reason why Apple dropped Java altogether, because its security was in the gutter.
2. It's a private package of the JVM
If you're bold enough to use it, you should be bold enough to write your own thing. Why should Oracle be bound by some form of moral requirement to document some whatever cryptic legacy code, that people reverse engineered in the first place? What. The. Hell.
Probably this tweet captures the essence of the whole thing:
"OMG, we've been stupid and used a private API for years, now it's being removed… what do we do? BLAME ORACLE!" http://t.co/P9D9kW6CrF— Michael Klishin (@michaelklishin) July 14, 2015
It's not even such a big deal. I swear!
Do you know what else introduced breaking API changes for public APIs? The endorsed folder. It's what stuff like WebLogic uses to overwrite already published public APIs. I'm going to reiterate this: There is already the endorsed folder, that allows overwriting public APIs from the JVM, and people are using it. This is a great thing actually, especially if the API was not finalized. Why getting stuck with an API for the next two years?
Public APIs! And you see that the universe imploded? Billions of dollars were lost? Calm down people, jeeeez.
3. There will still be YEARS of Java 8 support
Oracle doesn't just throw away JVMs, and then just plugs support out. If the program you're using, and its creepy library that needs the sun.misc.Unsafe are that important, go buy support. I mean, for crying out loud, you can still get Java 6 support that people were using to connect to dinosaurs. And the Java life cycle support it's for 11 (eleven!!) years.
So finally, please all, can you just chill out?
It's all for the better I promise.
PS: I am not affiliated with Oracle in any shape or form, beside I'm developing and using Java, and I'm a certified JEE5 Enterprise Architect.
Do you want your editing of AsciiDoc (or Markdown) to look like this?
In order to get AsciiDoc support working nicely in VIM, you'll need a couple of things:
Then add another syntax file for AsciiDoc, by creating another plugin, with just the /syntax folder in it. (If you use pathogen, it should look something like this). In it configure your SyntaxRange plugin for matching for various languages:
The gherkin one, is there separately, since for the gherkin language, we're going to use the cucumber syntax file.
Since the SyntaxRange registration it's in the syntax file, it will only activate when editing asciidoc files.
PS2: For doing live html visualising of the file, you can use fast-live-reload:
Then just open the http://localhost:9000/test.html in the browser and watch it change as you save.
The one to rule them all. The browsers that is.
SharpKnight is an Android chess game.
MagicGroup is an eclipse plugin.